diff options
Diffstat (limited to 'source')
25 files changed, 246 insertions, 177 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 5898d5da670..beb098ba0fc 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -25,16 +25,12 @@ #include "MaterialExporter.h" template<class Functor> -void forEachObjectInScene(Scene *sce, Functor &f) +void forEachObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set) { - Base *base= (Base*) sce->base.first; - - while (base) { - Object *ob = base->object; - + LinkNode *node; + for(node=export_set; node; node=node->next) { + Object *ob = (Object *)node->link; f(ob); - - base= base->next; } } @@ -45,7 +41,7 @@ void AnimationExporter::exportAnimations(Scene *sce) openLibrary(); - forEachObjectInScene(sce, *this); + forEachObjectInExportSet(sce, *this, this->export_settings->export_set); closeLibrary(); } diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 6324853d91c..d6a93a36c6e 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -41,11 +41,13 @@ #include "COLLADAFWEffect.h" #include "COLLADAFWInstanceGeometry.h" +extern "C" { #include "DNA_anim_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_lamp_types.h" #include "DNA_camera_types.h" +} //#include "ArmatureImporter.h" #include "TransformReader.h" diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 107a3fc5796..e5548acadb5 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -112,7 +112,7 @@ void ArmatureExporter::export_controllers(Scene *sce) openLibrary(); GeometryFunctor gf; - gf.forEachMeshObjectInScene<ArmatureExporter>(sce, *this, this->export_settings->selected); + gf.forEachMeshObjectInExportSet<ArmatureExporter>(sce, *this, this->export_settings->export_set); closeLibrary(); } diff --git a/source/blender/collada/CameraExporter.cpp b/source/blender/collada/CameraExporter.cpp index ce46c681c8c..4e7f2f0434f 100644 --- a/source/blender/collada/CameraExporter.cpp +++ b/source/blender/collada/CameraExporter.cpp @@ -29,10 +29,10 @@ #include <string> #include "COLLADASWCamera.h" -#include "COLLADASWCameraOptic.h" +extern "C" { #include "DNA_camera_types.h" - +} #include "CameraExporter.h" #include "collada_internal.h" @@ -40,16 +40,15 @@ CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryCameras(sw), export_settings(export_settings) {} template<class Functor> -void forEachCameraObjectInScene(Scene *sce, Functor &f, bool export_selected) +void forEachCameraObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set) { - Base *base = (Base*) sce->base.first; - while (base) { - Object *ob = base->object; + LinkNode *node; + for(node=export_set; node; node = node->next) { + Object *ob = (Object *)node->link; - if (ob->type == OB_CAMERA && ob->data && !(export_selected && !(ob->flag & SELECT))) { + if (ob->type == OB_CAMERA && ob->data) { f(ob, sce); } - base = base->next; } } @@ -57,7 +56,7 @@ void CamerasExporter::exportCameras(Scene *sce) { openLibrary(); - forEachCameraObjectInScene(sce, *this, this->export_settings->selected); + forEachCameraObjectInExportSet(sce, *this, this->export_settings->export_set); closeLibrary(); } diff --git a/source/blender/collada/CameraExporter.h b/source/blender/collada/CameraExporter.h index 1b5898984ba..5405df8ab9e 100644 --- a/source/blender/collada/CameraExporter.h +++ b/source/blender/collada/CameraExporter.h @@ -31,8 +31,10 @@ #include "COLLADASWStreamWriter.h" #include "COLLADASWLibraryCameras.h" +extern "C" { #include "DNA_object_types.h" #include "DNA_scene_types.h" +} #include "ExportSettings.h" diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index e224ffce731..4e84eba500c 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -111,7 +111,8 @@ extern char build_rev[]; #include "collada_internal.h" #include "DocumentExporter.h" -#include "ExportSettings.h" + +extern bool bc_has_object_type(LinkNode *export_set, short obtype); // can probably go after refactor is complete #include "InstanceWriter.h" @@ -227,14 +228,15 @@ void DocumentExporter::exportCurrentScene(Scene *sce) asset.getContributor().mAuthoringTool = version_buf; asset.add(); + LinkNode *export_set = this->export_settings->export_set; // <library_cameras> - if (has_object_type(sce, OB_CAMERA)) { + if (bc_has_object_type(export_set, OB_CAMERA)) { CamerasExporter ce(&sw, this->export_settings); ce.exportCameras(sce); } // <library_lights> - if (has_object_type(sce, OB_LAMP)) { + if (bc_has_object_type(export_set, OB_LAMP)) { LightsExporter le(&sw, this->export_settings); le.exportLights(sce); } @@ -252,7 +254,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce) me.exportMaterials(sce); // <library_geometries> - if (has_object_type(sce, OB_MESH)) { + if (bc_has_object_type(export_set, OB_MESH)) { GeometryExporter ge(&sw, this->export_settings); ge.exportGeom(sce); } @@ -263,10 +265,8 @@ void DocumentExporter::exportCurrentScene(Scene *sce) // <library_controllers> ArmatureExporter arm_exporter(&sw, this->export_settings); - if (this->export_settings->include_armatures) { - if (has_object_type(sce, OB_ARMATURE)) { - arm_exporter.export_controllers(sce); - } + if (bc_has_object_type(export_set, OB_ARMATURE)) { + arm_exporter.export_controllers(sce); } // <library_visual_scenes> diff --git a/source/blender/collada/DocumentExporter.h b/source/blender/collada/DocumentExporter.h index 314ba2868e5..05620087d76 100644 --- a/source/blender/collada/DocumentExporter.h +++ b/source/blender/collada/DocumentExporter.h @@ -29,6 +29,10 @@ #include "ExportSettings.h" +extern "C" { +#include "DNA_customdata_types.h" +} + struct Scene; class DocumentExporter diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 6dca7828cc2..fa85e7527ff 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -49,6 +49,7 @@ #include "COLLADASaxFWLLoader.h" #include "COLLADASaxFWLIExtraDataCallbackHandler.h" +extern "C" { #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" @@ -75,6 +76,8 @@ #include "MEM_guardedalloc.h" +} + #include "ExtraHandler.h" #include "ErrorHandler.h" #include "DocumentImporter.h" diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 36ed6867525..644c350e8fe 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -31,6 +31,7 @@ #include "COLLADASWEffectProfile.h" #include "EffectExporter.h" +#include "DocumentExporter.h" #include "MaterialExporter.h" #include "DNA_mesh_types.h" @@ -82,7 +83,7 @@ void EffectsExporter::exportEffects(Scene *sce) this->scene = sce; openLibrary(); MaterialFunctor mf; - mf.forEachMaterialInScene<EffectsExporter>(sce, *this, this->export_settings->selected); + mf.forEachMaterialInExportSet<EffectsExporter>(sce, *this, this->export_settings->export_set); closeLibrary(); } diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index a6ae29bf2b2..97ea6873856 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -24,6 +24,10 @@ * \ingroup collada */ +extern "C" { +#include "BLI_linklist.h" +} + #ifndef __EXPORTSETTINGS_H__ #define __EXPORTSETTINGS_H__ @@ -33,10 +37,11 @@ struct ExportSettings bool selected; bool apply_modifiers; bool include_armatures; - bool include_bone_children; + bool include_children; bool use_object_instantiation; bool second_life; char *filepath; + LinkNode *export_set; }; #endif diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 53d7f1e6449..bc06de4d56b 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -61,7 +61,7 @@ void GeometryExporter::exportGeom(Scene *sce) mScene = sce; GeometryFunctor gf; - gf.forEachMeshObjectInScene<GeometryExporter>(sce, *this, this->export_settings->selected); + gf.forEachMeshObjectInExportSet<GeometryExporter>(sce, *this, this->export_settings->export_set); closeLibrary(); } diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h index 23cdcc0a5ba..f14775b9f44 100644 --- a/source/blender/collada/GeometryExporter.h +++ b/source/blender/collada/GeometryExporter.h @@ -42,6 +42,8 @@ #include "ExportSettings.h" +extern Object *bc_get_highest_selected_ancestor_or_self(Object *ob); + // TODO: optimize UV sets by making indexed list with duplicates removed class GeometryExporter : COLLADASW::LibraryGeometries { @@ -112,21 +114,15 @@ struct GeometryFunctor { // f should have // void operator()(Object* ob) template<class Functor> - void forEachMeshObjectInScene(Scene *sce, Functor &f, bool export_selected) + void forEachMeshObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set) { - - Base *base= (Base*) sce->base.first; - while (base) { - Object *ob = base->object; - - if (ob->type == OB_MESH && ob->data && - !(export_selected && !(ob->flag & SELECT)) && - ((sce->lay & ob->lay)!=0)) + LinkNode *node; + for (node=export_set; node; node = node->next) { + Object *ob = (Object *)node->link; + if (ob->type == OB_MESH) { f(ob); } - base= base->next; - } } }; diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index 4d7c56ab419..1999c68307e 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -73,7 +73,7 @@ void ImagesExporter::exportImages(Scene *sce) if (hasImages(sce)) { openLibrary(); MaterialFunctor mf; - mf.forEachMaterialInScene<ImagesExporter>(sce, *this, this->export_settings->selected); + mf.forEachMaterialInExportSet<ImagesExporter>(sce, *this, this->export_settings->export_set); closeLibrary(); } diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index 6d276cd782f..44306616a85 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -36,16 +36,15 @@ #include "collada_internal.h" template<class Functor> -void forEachLampObjectInScene(Scene *sce, Functor &f, bool export_selected) +void forEachLampObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set) { - Base *base= (Base*) sce->base.first; - while (base) { - Object *ob = base->object; + LinkNode *node; + for (node=export_set; node; node = node->next) { + Object *ob = (Object *)node->link; - if (ob->type == OB_LAMP && ob->data && !(export_selected && !(ob->flag & SELECT))) { + if (ob->type == OB_LAMP && ob->data) { f(ob); } - base= base->next; } } @@ -55,7 +54,7 @@ void LightsExporter::exportLights(Scene *sce) { openLibrary(); - forEachLampObjectInScene(sce, *this, this->export_settings->selected); + forEachLampObjectInExportSet(sce, *this, this->export_settings->export_set); closeLibrary(); } diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index 48fa5b690be..ec075e7dcf8 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -39,7 +39,7 @@ void MaterialsExporter::exportMaterials(Scene *sce) openLibrary(); MaterialFunctor mf; - mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, this->export_settings->selected); + mf.forEachMaterialInExportSet<MaterialsExporter>(sce, *this, this->export_settings->export_set); closeLibrary(); } diff --git a/source/blender/collada/MaterialExporter.h b/source/blender/collada/MaterialExporter.h index 4a5422184d4..f65c8849c84 100644 --- a/source/blender/collada/MaterialExporter.h +++ b/source/blender/collada/MaterialExporter.h @@ -89,11 +89,11 @@ struct MaterialFunctor { // f should have // void operator()(Material* ma) template<class Functor> - void forEachMaterialInScene(Scene *sce, Functor &f, bool export_selected) + void forEachMaterialInExportSet(Scene *sce, Functor &f, LinkNode *export_set) { ForEachMaterialFunctor<Functor> matfunc(&f); GeometryFunctor gf; - gf.forEachMeshObjectInScene<ForEachMaterialFunctor<Functor> >(sce, matfunc, export_selected); + gf.forEachMeshObjectInExportSet<ForEachMaterialFunctor<Functor> >(sce, matfunc, export_set); } }; diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index 510107272cd..603a700c4a9 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -26,6 +26,7 @@ #include "SceneExporter.h" #include "collada_utils.h" +#include "BKE_object.h" SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings) : COLLADASW::LibraryVisualScenes(sw), arm_exporter(arm), export_settings(export_settings) @@ -41,112 +42,89 @@ void SceneExporter::exportScene(Scene *sce) closeLibrary(); } -// Returns true if the parent chain does not contain any selected object -// Otherwise return false (ob has selected predecessor) -bool is_exported_base_node(Object *ob, bool selection_only) { - - if (selection_only && ob->flag & SELECT) { - // Move up towards root object, - // stop at first selected predecessor's child, - // or at root, if no parent was selected - while (ob->parent && (ob->parent->type==OB_ARMATURE || !(ob->parent->flag & SELECT))) +void SceneExporter::exportHierarchy(Scene *sce) +{ + LinkNode *node; + std::vector<Object *> base_objects; + + // Ensure all objects in the export_set are marked + for(node = this->export_settings->export_set; node; node = node->next) { + Object *ob = (Object*) node->link; + ob->id.flag |= LIB_DOIT; + } + + // Now find all exportable base ojects (highest in export hierarchy) + for(node = this->export_settings->export_set; node; node = node->next) { + Object *ob = (Object*) node->link; + if (bc_is_base_node(this->export_settings->export_set, ob)) { - ob = ob->parent; + switch (ob->type) { + case OB_MESH: + case OB_CAMERA: + case OB_LAMP: + case OB_EMPTY: + case OB_ARMATURE: + base_objects.push_back(ob); + break; + } } } - return !ob->parent; -} - -void SceneExporter::exportHierarchy(Scene *sce) -{ - Base *base= (Base*) sce->base.first; - while (base) { - Object *ob = base->object; - - bool is_export_base_node = is_exported_base_node(ob, this->export_settings->selected); - if (is_export_base_node) { - if (sce->lay & ob->lay) { - switch (ob->type) { - case OB_MESH: - case OB_CAMERA: - case OB_LAMP: - case OB_EMPTY: - if (this->export_settings->selected && !(ob->flag & SELECT)) { - break; - } - // write nodes.... - writeNodes(ob, sce); - break; - } - } + // And now export the base objects: + for(int index=0; index < base_objects.size(); index++) { + Object *ob = base_objects[index]; + if (bc_is_marked(ob)) { + bc_remove_mark(ob); + writeNodes(ob, sce); } - - base= base->next; } } void SceneExporter::writeNodes(Object *ob, Scene *sce) { - // Add associated armature first if available - if (this->export_settings->include_armatures) { - Object *ob_arm = bc_get_assigned_armature(ob); - if(ob_arm != NULL) - writeNodes(ob_arm, sce); + Object *ob_arm = bc_get_assigned_armature(ob); + if(ob_arm != NULL && bc_is_marked(ob_arm)) { + bc_remove_mark(ob_arm); + writeNodes(ob_arm, sce); } - COLLADASW::Node node(mSW); - node.setNodeId(translate_id(id_name(ob))); - node.setNodeName(translate_id(id_name(ob))); - node.setType(COLLADASW::Node::NODE); + COLLADASW::Node colladaNode(mSW); + colladaNode.setNodeId(translate_id(id_name(ob))); + colladaNode.setNodeName(translate_id(id_name(ob))); + colladaNode.setType(COLLADASW::Node::NODE); - node.start(); + colladaNode.start(); bool is_skinned_mesh = arm_exporter->is_skinned_mesh(ob); std::list<Object*> child_objects; - // XXX Not sure about this. - // For me this looks more like a very special case for a very special purpose. - // Wouldn't it be better to have only one option here ? - // - // - include children - // - // Instead of "include_bone_children" ? - // then we could just ask: - // if (this->export_settings->include_children) - // ... - if (this->export_settings->include_armatures - && this->export_settings->include_bone_children) { - - // list child objects - Base *b = (Base*) sce->base.first; - while (b) { - // cob - child object - Object *cob = b->object; - - if (cob->parent == ob) { - switch (cob->type) { - case OB_MESH: - case OB_CAMERA: - case OB_LAMP: - case OB_EMPTY: - case OB_ARMATURE: + // list child objects + LinkNode *node = this->export_settings->export_set ; + while (node) { + // cob - child object + Object *cob = (Object *)node->link; + + if (cob->parent == ob) { + switch (cob->type) { + case OB_MESH: + case OB_CAMERA: + case OB_LAMP: + case OB_EMPTY: + case OB_ARMATURE: + if (bc_is_marked(cob)) child_objects.push_back(cob); - break; - } + break; } - - b = b->next; } + node = node->next; } - if (ob->type == OB_MESH && this->export_settings->include_armatures && is_skinned_mesh) // for skinned mesh we write obmat in <bind_shape_matrix> - TransformWriter::add_node_transform_identity(node); + TransformWriter::add_node_transform_identity(colladaNode); else - TransformWriter::add_node_transform_ob(node, ob); + TransformWriter::add_node_transform_ob(colladaNode, ob); // <instance_geometry> if (ob->type == OB_MESH) { @@ -167,9 +145,6 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) // <instance_controller> else if (ob->type == OB_ARMATURE) { arm_exporter->add_armature_bones(ob, sce, this, child_objects); - - // XXX this looks unstable... - node.end(); } // <instance_camera> @@ -196,12 +171,19 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) } } - for (std::list<Object*>::iterator i= child_objects.begin(); i != child_objects.end(); ++i) { - writeNodes(*i, sce); + if (ob->type == OB_ARMATURE) { + colladaNode.end(); } + for (std::list<Object*>::iterator i= child_objects.begin(); i != child_objects.end(); ++i) { + if(bc_is_marked(*i)) { + bc_remove_mark(*i); + writeNodes(*i, sce); + } + } - if (ob->type != OB_ARMATURE) - node.end(); + if (ob->type != OB_ARMATURE) { + colladaNode.end(); + } } diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index e880082c9ec..b852190dd4c 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -56,20 +56,12 @@ extern "C" int apply_modifiers, int include_armatures, - int include_bone_children, + int include_children, int use_object_instantiation, int second_life ) { ExportSettings export_settings; - - export_settings.selected = selected != 0; - export_settings.apply_modifiers = apply_modifiers != 0; - export_settings.include_armatures = include_armatures != 0; - export_settings.include_bone_children = include_bone_children != 0; - export_settings.second_life = second_life != 0; - export_settings.use_object_instantiation = use_object_instantiation != 0; - export_settings.filepath = (char *)filepath; /* annoying, collada crashes if file cant be created! [#27162] */ if (!BLI_exists(filepath)) { @@ -80,9 +72,27 @@ extern "C" } /* end! */ + + export_settings.selected = selected != 0; + export_settings.apply_modifiers = apply_modifiers != 0; + export_settings.include_armatures = include_armatures != 0; + export_settings.include_children = include_children != 0; + export_settings.second_life = second_life != 0; + export_settings.use_object_instantiation = use_object_instantiation != 0; + export_settings.filepath = (char *)filepath; + + int includeFilter = OB_REL_NONE; + if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE; + if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE; + + eObjectSet objectSet = (export_settings.selected) ? OB_SET_SELECTED : OB_SET_ALL; + export_settings.export_set = BKE_object_relational_superset(sce, objectSet, (eObRelationTypes)includeFilter); + DocumentExporter exporter(&export_settings); exporter.exportCurrentScene(sce); + BLI_linklist_free(export_settings.export_set, NULL); + return 1; } } diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index 646c8469e6b..da2179ca135 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -44,11 +44,13 @@ extern "C" { int apply_modifiers, int include_armatures, - int include_bone_children, + int include_children, int use_object_instantiation, int second_life); + + #ifdef __cplusplus } #endif diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index 81e5f88a3f8..06e688a93ac 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -27,9 +27,10 @@ /* COLLADABU_ASSERT, may be able to remove later */ #include "COLLADABUPlatform.h" - #include "collada_internal.h" +#include "BLI_linklist.h" + UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) {} void UnitConverter::read_asset(const COLLADAFW::FileInfo* asset) @@ -277,17 +278,3 @@ 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; -} diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h index d00af791a1f..b64c75e7960 100644 --- a/source/blender/collada/collada_internal.h +++ b/source/blender/collada/collada_internal.h @@ -39,6 +39,8 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BLI_math.h" +#include "BLI_math.h" +#include "BLI_linklist.h" class UnitConverter { @@ -96,6 +98,4 @@ 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__ */ diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 8693441d7c8..c92131d5359 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -32,6 +32,8 @@ #include "COLLADAFWMeshPrimitive.h" #include "COLLADAFWMeshVertexData.h" +#include "collada_utils.h" + #include "DNA_modifier_types.h" #include "DNA_customdata_types.h" #include "DNA_object_types.h" @@ -49,6 +51,7 @@ extern "C" { #include "BKE_DerivedMesh.h" +#include "BLI_linklist.h" } #include "WM_api.h" // XXX hrm, see if we can do without this @@ -164,3 +167,64 @@ Object *bc_get_assigned_armature(Object *ob) return ob_arm; } +// Returns the highest selected ancestor +// returns NULL if no ancestor is selected +// IMPORTANT: This function expects that +// all exported objects have set: +// ob->id.flag & LIB_DOIT +Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob) +{ + Object *ancestor = ob; + while (ob->parent && bc_is_marked(ob->parent)) + { + ob = ob->parent; + ancestor = ob; + } + return ancestor; +} + +bool bc_is_base_node(LinkNode *export_set, Object *ob) +{ + Object *root = bc_get_highest_selected_ancestor_or_self(export_set, ob); + return (root == ob); +} + +bool bc_is_in_Export_set(LinkNode *export_set, Object *ob) +{ + LinkNode *node = export_set; + + while (node) { + Object *element = (Object *)node->link; + + if (element == ob) + return true; + + node= node->next; + } + return false; +} + +bool bc_has_object_type(LinkNode *export_set, short obtype) +{ + LinkNode *node = export_set; + + while (node) { + Object *ob = (Object *)node->link; + + if (ob->type == obtype && ob->data) { + return true; + } + node= node->next; + } + return false; +} + +int bc_is_marked(Object *ob) +{ + return ob && (ob->id.flag & LIB_DOIT); +} + +void bc_remove_mark(Object *ob) +{ + ob->id.flag &= ~LIB_DOIT; +} diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index 9882b44d94c..71365ffb8d0 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -40,18 +40,35 @@ #include "DNA_customdata_types.h" #include "DNA_texture_types.h" #include "BKE_context.h" +#include "BKE_object.h" + #include "DNA_scene_types.h" +extern "C" { +#include "BKE_DerivedMesh.h" +#include "BLI_linklist.h" +} + +#include "ExportSettings.h" + typedef std::map<COLLADAFW::TextureMapId, std::vector<MTex*> > TexIndexTextureArrayMap; extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index); - extern int bc_test_parent_loop(Object *par, Object *ob); extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space=true); -extern char *bc_CustomData_get_layer_name(const CustomData *data, int type, int n); -extern char *bc_CustomData_get_active_layer_name(const CustomData *data, int type); extern Object *bc_add_object(Scene *scene, int type, const char *name); extern Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob); + extern Object *bc_get_assigned_armature(Object *ob); +extern Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob); +extern bool bc_is_base_node(LinkNode *export_set, Object *ob); +extern bool bc_is_in_Export_set(LinkNode *export_set, Object *ob); +extern bool bc_has_object_type(LinkNode *export_set, short obtype); + +extern int bc_is_marked(Object *ob); +extern void bc_remove_mark(Object *ob); + +extern char *bc_CustomData_get_layer_name(const CustomData *data, int type, int n); +extern char *bc_CustomData_get_active_layer_name(const CustomData *data, int type); #endif diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index b2ff36285e6..8d18f9dd1c2 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -91,12 +91,12 @@ static void rna_Scene_collada_export( int selected, int apply_modifiers, int include_armatures, - int include_bone_children, + int include_children, int use_object_instantiation, int second_life) { collada_export(scene, filepath, selected, apply_modifiers, - include_armatures, include_bone_children, + include_armatures, include_children, use_object_instantiation, second_life); } @@ -128,7 +128,7 @@ void RNA_api_scene(StructRNA *srna) parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements"); parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers (in Preview resolution)"); parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Include armature(s) used by the exported objects"); - parm = RNA_def_boolean(func, "include_bone_children", 0, "Include Bone Children", "Include all objects attached to bones of selected Armature(s)"); + parm = RNA_def_boolean(func, "include_children", 0, "Include Children", "Include all children even if not selected"); parm = RNA_def_boolean(func, "use_object_instantiation", 1, "Use Object Instantiation", "Instantiate multiple Objects from same Data"); parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); RNA_def_function_ui_description(func, "Export to collada file"); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 425baac25fd..5f4a536d18f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2165,7 +2165,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) int selected, second_life, include_armatures, apply_modifiers, - include_bone_children, + include_children, use_object_instantiation; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { @@ -2179,7 +2179,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) selected = RNA_boolean_get(op->ptr, "selected"); apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); include_armatures = RNA_boolean_get(op->ptr, "include_armatures"); - include_bone_children = RNA_boolean_get(op->ptr, "include_bone_children"); + include_children = RNA_boolean_get(op->ptr, "include_children"); use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); second_life = RNA_boolean_get(op->ptr, "second_life"); @@ -2192,7 +2192,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) selected, apply_modifiers, include_armatures, - include_bone_children, + include_children, use_object_instantiation, second_life)) { return OPERATOR_FINISHED; @@ -2225,8 +2225,8 @@ static void WM_OT_collada_export(wmOperatorType *ot) RNA_def_boolean(ot->srna, "include_armatures", 0, "Include Armatures", "Include armature(s) used by the exported objects"); - RNA_def_boolean(ot->srna, "include_bone_children", 0, "Include Bone Children", - "Include all objects attached to bones of selected Armature(s)"); + RNA_def_boolean(ot->srna, "include_children", 0, "Include Children", + "Include all children even if not selected"); RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instantiation", "Instantiate multiple Objects from same Data"); |