Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/collada/MeshImporter.cpp12
-rw-r--r--source/blender/collada/MeshImporter.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 86dc1a44671..b6576858c51 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -803,6 +803,18 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
return NULL;
}
+ // different nodes can point to same geometry, but still also specify the same materials
+ // again. Make sure we don't overwrite them on the next occurrences, so keep list of
+ // what we already have handled.
+ std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId>::iterator it;
+ it=materials_mapped_to_geom.find(*geom_uid);
+ while(it!=materials_mapped_to_geom.end()) {
+ if(it->second == ma_uid) return NULL; // do nothing if already found
+ it++;
+ }
+ // first time we get geom_uid, ma_uid pair. Save for later check.
+ materials_mapped_to_geom.insert(std::pair<COLLADAFW::UniqueId, COLLADAFW::UniqueId>(*geom_uid, ma_uid));
+
Material *ma = uid_material_map[ma_uid];
assign_material(ob, ma, ob->totcol + 1);
diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h
index 1a9f698a7ce..20fdb0dcc6e 100644
--- a/source/blender/collada/MeshImporter.h
+++ b/source/blender/collada/MeshImporter.h
@@ -91,6 +91,7 @@ private:
};
typedef std::map<COLLADAFW::MaterialId, std::vector<Primitive> > MaterialIdPrimitiveArrayMap;
std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap> geom_uid_mat_mapping_map; // crazy name!
+ std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId> materials_mapped_to_geom; //< materials that have already been mapped to a geometry. A pair of geom uid and mat uid, one geometry can have several materials
void set_face_indices(MFace *mface, unsigned int *indices, bool quad);