diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2011-07-28 04:08:03 +0400 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2011-07-28 04:08:03 +0400 |
commit | 7e87165eea9af2e0e9b9e2192341a5a0842bc81e (patch) | |
tree | cb074dfa26dead2ba2c8d35fc977429206a4389b /source/blender/collada/MaterialExporter.cpp | |
parent | f532ccedf5c3898a5726ba4295297ebb58ba4909 (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.cpp | 32 |
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) |