diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2011-03-18 17:06:13 +0300 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2011-03-18 17:06:13 +0300 |
commit | 7e53769d09863b59beae4155ea0ad13c6ab2fac2 (patch) | |
tree | cb5ef0f99fa4c171fb1ce1128db19db42b14b0be /source/blender/collada/EffectExporter.cpp | |
parent | b4743ccd8fdb577670d16ffdd6b3ad2132fa3fea (diff) |
COLLADA conformance: don't write empty libraries for effect, image and animation
Diffstat (limited to 'source/blender/collada/EffectExporter.cpp')
-rw-r--r-- | source/blender/collada/EffectExporter.cpp | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index ee0ade53e99..323b90fe1cc 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -55,15 +55,38 @@ static std::string getActiveUVLayerName(Object *ob) return ""; } - EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw) : COLLADASW::LibraryEffects(sw){} + +bool EffectsExporter::hasEffects(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 EffectsExporter::exportEffects(Scene *sce) { - openLibrary(); - MaterialFunctor mf; - mf.forEachMaterialInScene<EffectsExporter>(sce, *this); + if(hasEffects(sce)) { + openLibrary(); + MaterialFunctor mf; + mf.forEachMaterialInScene<EffectsExporter>(sce, *this); - closeLibrary(); + closeLibrary(); + } } void EffectsExporter::operator()(Material *ma, Object *ob) |