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/ImageExporter.cpp | |
parent | b4743ccd8fdb577670d16ffdd6b3ad2132fa3fea (diff) |
COLLADA conformance: don't write empty libraries for effect, image and animation
Diffstat (limited to 'source/blender/collada/ImageExporter.cpp')
-rw-r--r-- | source/blender/collada/ImageExporter.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index a2d9cb15ab1..b7a5ef4c4e4 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -46,13 +46,40 @@ ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const char* filename) : COLLADASW::LibraryImages(sw), mfilename(filename) {} +bool ImagesExporter::hasImages(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; + int b; + for (b = 0; b < MAX_MTEX; b++) { + MTex *mtex = ma->mtex[b]; + if (mtex && mtex->tex && mtex->tex->ima) return true; + } + + } + base= base->next; + } + return false; +} + void ImagesExporter::exportImages(Scene *sce) { - openLibrary(); - MaterialFunctor mf; - mf.forEachMaterialInScene<ImagesExporter>(sce, *this); + if(hasImages(sce)) { + openLibrary(); + MaterialFunctor mf; + mf.forEachMaterialInScene<ImagesExporter>(sce, *this); - closeLibrary(); + closeLibrary(); + } } void ImagesExporter::operator()(Material *ma, Object *ob) |