[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32297] trunk/blender/source/blender/ collada/DocumentExporter.cpp: COLLADA exporter fix: do not create a duplicate <polylist> if an object has NULL materials linked along with normal materials.
Arystanbek Dyussenov
arystan.d at gmail.com
Mon Oct 4 05:38:38 CEST 2010
Revision: 32297
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32297
Author: kazanbas
Date: 2010-10-04 05:38:37 +0200 (Mon, 04 Oct 2010)
Log Message:
-----------
COLLADA exporter fix: do not create a duplicate <polylist> if an object has NULL materials linked along with normal materials.
Modified Paths:
--------------
trunk/blender/source/blender/collada/DocumentExporter.cpp
Modified: trunk/blender/source/blender/collada/DocumentExporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/DocumentExporter.cpp 2010-10-04 01:18:47 UTC (rev 32296)
+++ trunk/blender/source/blender/collada/DocumentExporter.cpp 2010-10-04 03:38:37 UTC (rev 32297)
@@ -497,13 +497,11 @@
// 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 @@
}
// 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 @@
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 @@
// 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 @@
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;
More information about the Bf-blender-cvs
mailing list