diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/collada/ExportSettings.h | 1 | ||||
-rw-r--r-- | source/blender/collada/SceneExporter.cpp | 37 | ||||
-rw-r--r-- | source/blender/collada/collada.cpp | 17 | ||||
-rw-r--r-- | source/blender/collada/collada.h | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene_api.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 24 |
6 files changed, 68 insertions, 30 deletions
diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index 41fa7e1ed38..b875282ac33 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -32,6 +32,7 @@ struct ExportSettings public: bool selected; bool apply_modifiers; + bool include_bone_children; bool second_life; char *filepath; }; diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index cd36267fd56..f79ae2b52a9 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -79,25 +79,28 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) bool is_skinned_mesh = arm_exporter->is_skinned_mesh(ob); std::list<Object*> child_objects; - // 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: - child_objects.push_back(cob); - break; + + if (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: + child_objects.push_back(cob); + break; + } } - } - b = b->next; + b = b->next; + } } diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index ae024ec52a7..c947144412a 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -49,14 +49,21 @@ extern "C" return 0; } - int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life) + int collada_export( + Scene *sce, + const char *filepath, + int selected, + int apply_modifiers, + int include_bone_children, + int second_life) { ExportSettings export_settings; - export_settings.selected = selected != 0; - export_settings.apply_modifiers = apply_modifiers != 0; - export_settings.second_life = second_life != 0; - export_settings.filepath = (char *)filepath; + export_settings.selected = selected != 0; + export_settings.apply_modifiers = apply_modifiers != 0; + export_settings.include_bone_children = include_bone_children != 0; + export_settings.second_life = second_life != 0; + export_settings.filepath = (char *)filepath; /* annoying, collada crashes if file cant be created! [#27162] */ if (!BLI_exists(filepath)) { diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index f335796f799..d5c26bb402c 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -37,7 +37,13 @@ extern "C" { * both return 1 on success, 0 on error */ int collada_import(bContext *C, const char *filepath); - int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life); + int collada_export( + Scene *sce, + const char *filepath, + int selected, + int apply_modifiers, + int include_bone_children, + int second_life); #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 429f1d48df3..439335e69b4 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -85,9 +85,15 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ #include "../../collada/collada.h" -static void rna_Scene_collada_export(Scene *scene, const char *filepath, int selected, int apply_modifiers, int second_life) +static void rna_Scene_collada_export( + Scene *scene, + const char *filepath, + int selected, + int apply_modifiers, + int include_bone_children, + int second_life) { - collada_export(scene, filepath, selected, apply_modifiers, second_life); + collada_export(scene, filepath, selected, apply_modifiers, include_bone_children, second_life); } #endif @@ -117,6 +123,7 @@ void RNA_api_scene(StructRNA *srna) RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */ 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_bone_children", 0, "Include Bone Children", "Include all objects attached to bones of selected Armature(s)"); 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"); #endif diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 4c396d2d6d3..05af3c04573 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2155,7 +2155,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED static int wm_collada_export_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; - int selected, second_life, apply_modifiers; + int selected, second_life, apply_modifiers, include_bone_children; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); @@ -2165,14 +2165,22 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", filename); /* Options panel */ - selected = RNA_boolean_get(op->ptr, "selected"); - second_life = RNA_boolean_get(op->ptr, "second_life"); - apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); + selected = RNA_boolean_get(op->ptr, "selected"); + apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); + include_bone_children = RNA_boolean_get(op->ptr, "include_bone_children"); + + second_life = RNA_boolean_get(op->ptr, "second_life"); /* get editmode results */ ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ - if (collada_export(CTX_data_scene(C), filename, selected, apply_modifiers, second_life)) { + if (collada_export( + CTX_data_scene(C), + filename, + selected, + apply_modifiers, + include_bone_children, + second_life)) { return OPERATOR_FINISHED; } else { @@ -2193,10 +2201,16 @@ static void WM_OT_collada_export(wmOperatorType *ot) ot->flag |= OPTYPE_PRESET; WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + RNA_def_boolean(ot->srna, "selected", 0, "Selection Only", "Export only selected elements"); + RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers (Preview Resolution)"); + + 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, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); } |