diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2011-03-09 04:13:28 +0300 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2011-03-09 04:13:28 +0300 |
commit | 3f9bbde4a6668b19a7a7f291dc2305e6341d5b5d (patch) | |
tree | 1422c11b03e606fca02651160e8c02b595061307 /source/blender/collada/MeshImporter.cpp | |
parent | b3ad45aef6409669bed8ae8b88e74ca9d12b3d72 (diff) |
Fix [#26037] Import Collada crashes Blender
Submitted by David Roy
Multiple nodes can reference the same geometry, and specify the same materials. This lead
to the import code overwriting material mappings of faces in a destructive way. Instead of
just writing the material bindings always we now keep book of what geometry+material mapping
we've already handled.
Diffstat (limited to 'source/blender/collada/MeshImporter.cpp')
-rw-r--r-- | source/blender/collada/MeshImporter.cpp | 12 |
1 files changed, 12 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); |