diff options
author | Arystanbek Dyussenov <arystan.d@gmail.com> | 2010-10-04 07:38:37 +0400 |
---|---|---|
committer | Arystanbek Dyussenov <arystan.d@gmail.com> | 2010-10-04 07:38:37 +0400 |
commit | c0a7b5c2a85f15a714ff0b00a3dbc54688cd039e (patch) | |
tree | b5c6530018df8a5ab68414156e3ad6caef1ec906 /source/blender/collada | |
parent | 314121ee65a5d2aadb9be56afcc31201e0eda596 (diff) |
COLLADA exporter fix: do not create a duplicate <polylist> if an object has NULL materials linked along with normal materials.
Diffstat (limited to 'source/blender/collada')
-rw-r--r-- | source/blender/collada/DocumentExporter.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index c2d937f3d43..d10fa4ca94c 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -497,13 +497,11 @@ public: // XXX slow if (ob->totcol) { for(int a = 0; a < ob->totcol; a++) { - // account for NULL materials, this should not normally happen? - Material *ma = give_current_material(ob, a + 1); - createPolylist(ma != NULL, a, has_uvs, has_color, ob, geom_id, norind); + createPolylist(a, has_uvs, has_color, ob, geom_id, norind); } } else { - createPolylist(false, 0, has_uvs, has_color, ob, geom_id, norind); + createPolylist(0, has_uvs, has_color, ob, geom_id, norind); } closeMesh(); @@ -515,8 +513,7 @@ public: } // powerful because it handles both cases when there is material and when there's not - void createPolylist(bool has_material, - int material_index, + void createPolylist(int material_index, bool has_uvs, bool has_color, Object *ob, @@ -536,7 +533,7 @@ public: for (i = 0; i < totfaces; i++) { MFace *f = &mfaces[i]; - if ((has_material && f->mat_nr == material_index) || !has_material) { + if (f->mat_nr == material_index) { faces_in_polylist++; if (f->v4 == 0) { vcount_list.push_back(3); @@ -549,17 +546,18 @@ public: // no faces using this material if (faces_in_polylist == 0) { + fprintf(stderr, "%s: no faces use material %d\n", id_name(ob).c_str(), material_index); return; } - Material *ma = has_material ? give_current_material(ob, material_index + 1) : NULL; + Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL; COLLADASW::Polylist polylist(mSW); // sets count attribute in <polylist> polylist.setCount(faces_in_polylist); // sets material name - if (has_material) { + if (ma) { polylist.setMaterial(translate_id(id_name(ma))); } @@ -603,7 +601,7 @@ public: for (i = 0; i < totfaces; i++) { MFace *f = &mfaces[i]; - if ((has_material && f->mat_nr == material_index) || !has_material) { + if (f->mat_nr == material_index) { unsigned int *v = &f->v1; unsigned int *n = &norind[i].v1; |