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:
Diffstat (limited to 'source/blender/collada/MaterialExporter.cpp')
-rw-r--r--source/blender/collada/MaterialExporter.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp
index 0030f2a6285..9d29177578d 100644
--- a/source/blender/collada/MaterialExporter.cpp
+++ b/source/blender/collada/MaterialExporter.cpp
@@ -35,14 +35,38 @@
MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryMaterials(sw){}
-void MaterialsExporter::exportMaterials(Scene *sce)
+void MaterialsExporter::exportMaterials(Scene *sce, bool export_selected)
{
- openLibrary();
+ if(hasMaterials(sce)) {
+ openLibrary();
- MaterialFunctor mf;
- mf.forEachMaterialInScene<MaterialsExporter>(sce, *this);
+ 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)