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:
authorNathan Letwory <nathan@letworyinteractive.com>2011-07-28 04:08:03 +0400
committerNathan Letwory <nathan@letworyinteractive.com>2011-07-28 04:08:03 +0400
commit7e87165eea9af2e0e9b9e2192341a5a0842bc81e (patch)
treecb074dfa26dead2ba2c8d35fc977429206a4389b /source/blender/collada/MaterialExporter.cpp
parentf532ccedf5c3898a5726ba4295297ebb58ba4909 (diff)
Don't write library_materials tag when there are no materials.
Diffstat (limited to 'source/blender/collada/MaterialExporter.cpp')
-rw-r--r--source/blender/collada/MaterialExporter.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp
index a44fa6802f2..9d29177578d 100644
--- a/source/blender/collada/MaterialExporter.cpp
+++ b/source/blender/collada/MaterialExporter.cpp
@@ -37,12 +37,36 @@ MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw): COLLADASW::Li
void MaterialsExporter::exportMaterials(Scene *sce, bool export_selected)
{
- openLibrary();
+ if(hasMaterials(sce)) {
+ openLibrary();
- MaterialFunctor mf;
- mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, export_selected);
+ MaterialFunctor mf;
+ mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, export_selected);
- closeLibrary();
+ closeLibrary();
+ }
+}
+
+
+bool MaterialsExporter::hasMaterials(Scene *sce)
+{
+ Base *base = (Base *)sce->base.first;
+
+ while(base) {
+ Object *ob= base->object;
+ int a;
+ for(a = 0; a < ob->totcol; a++)
+ {
+ Material *ma = give_current_material(ob, a+1);
+
+ // no material, but check all of the slots
+ if (!ma) continue;
+
+ return true;
+ }
+ base= base->next;
+ }
+ return false;
}
void MaterialsExporter::operator()(Material *ma, Object *ob)