COLLADA: Don't write empty libraries for geometry, lights, cameras, controllers

This commit is contained in:
Nathan Letwory 2011-03-17 16:40:53 +00:00
parent 27abad190a
commit a84e43c48b
3 changed files with 32 additions and 7 deletions

@ -987,12 +987,16 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename)
asset.add();
// <library_cameras>
CamerasExporter ce(&sw);
ce.exportCameras(sce);
if(has_object_type(sce, OB_CAMERA)) {
CamerasExporter ce(&sw);
ce.exportCameras(sce);
}
// <library_lights>
LightsExporter le(&sw);
le.exportLights(sce);
if(has_object_type(sce, OB_LAMP)) {
LightsExporter le(&sw);
le.exportLights(sce);
}
// <library_images>
ImagesExporter ie(&sw, filename);
@ -1007,8 +1011,10 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename)
me.exportMaterials(sce);
// <library_geometries>
GeometryExporter ge(&sw);
ge.exportGeom(sce);
if(has_object_type(sce, OB_MESH)) {
GeometryExporter ge(&sw);
ge.exportGeom(sce);
}
// <library_animations>
AnimationExporter ae(&sw);
@ -1016,7 +1022,9 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename)
// <library_controllers>
ArmatureExporter arm_exporter(&sw);
arm_exporter.export_controllers(sce);
if(has_object_type(sce, OB_ARMATURE)) {
arm_exporter.export_controllers(sce);
}
// <library_visual_scenes>
SceneExporter se(&sw, &arm_exporter);

@ -277,3 +277,17 @@ std::string get_material_id(Material *mat)
{
return translate_id(id_name(mat)) + "-material";
}
bool has_object_type(Scene *sce, short obtype)
{
Base *base= (Base*) sce->base.first;
while(base) {
Object *ob = base->object;
if (ob->type == obtype && ob->data) {
return true;
}
base= base->next;
}
return false;
}

@ -39,6 +39,7 @@
#include "DNA_armature_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
class UnitConverter
@ -97,4 +98,6 @@ extern std::string get_camera_id(Object *ob);
extern std::string get_material_id(Material *mat);
extern bool has_object_type(Scene* sce, short obtype);
#endif /* COLLADA_INTERNAL_H */