diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/collada/ExportSettings.h | 1 | ||||
-rw-r--r-- | source/blender/collada/collada.cpp | 5 | ||||
-rw-r--r-- | source/blender/collada/collada.h | 1 | ||||
-rw-r--r-- | source/blender/collada/collada_utils.cpp | 28 | ||||
-rw-r--r-- | source/blender/collada/collada_utils.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene_api.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 6 |
7 files changed, 46 insertions, 1 deletions
diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index 97ea6873856..e856eefab99 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -39,6 +39,7 @@ struct ExportSettings bool include_armatures; bool include_children; bool use_object_instantiation; + bool sort_by_name; bool second_life; char *filepath; LinkNode *export_set; diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index bc03bdc970c..9a4fd44b9e9 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -59,6 +59,7 @@ int collada_export( int include_children, int use_object_instantiation, + int sort_by_name, int second_life) { ExportSettings export_settings; @@ -79,6 +80,7 @@ int collada_export( 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.sort_by_name = sort_by_name != 0; export_settings.filepath = (char *)filepath; int includeFilter = OB_REL_NONE; @@ -88,6 +90,9 @@ int collada_export( eObjectSet objectSet = (export_settings.selected) ? OB_SET_SELECTED : OB_SET_ALL; export_settings.export_set = BKE_object_relational_superset(sce, objectSet, (eObRelationTypes)includeFilter); + if (export_settings.sort_by_name) + bc_bubble_sort_by_Object_name(export_settings.export_set); + DocumentExporter exporter(&export_settings); exporter.exportCurrentScene(sce); diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index da2179ca135..8daf2b65fe2 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -47,6 +47,7 @@ extern "C" { int include_children, int use_object_instantiation, + int sort_by_name, int second_life); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index f481de994a3..3d9aa8e542d 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -226,3 +226,31 @@ void bc_remove_mark(Object *ob) { ob->id.flag &= ~LIB_DOIT; } + +// Use bubble sort algorithm for sorting the export set +void bc_bubble_sort_by_Object_name(LinkNode *export_set) +{ + int i, j; // loop indices + bool unsorted = true; + + LinkNode *current; + int set_size = BLI_linklist_length(export_set); + for(i = 0; (i < set_size) && unsorted; i++) { + unsorted = false; + + for (current=export_set; current->next; current = current->next) { + Object *a = (Object *)current->link; + Object *b = (Object *)current->next->link; + + std::string str_a (a->id.name); + std::string str_b (b->id.name); + + if (str_a.compare(str_b) > 0) { + current->link = b; + current->next->link = a; + unsorted = true; + } + + } + } +}
\ No newline at end of file diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index 71365ffb8d0..139a2cb93bd 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -71,4 +71,6 @@ 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); +extern void bc_bubble_sort_by_Object_name(LinkNode *export_set); + #endif diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 76fe5a656b6..76366efe0d1 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -93,11 +93,12 @@ static void rna_Scene_collada_export( int include_armatures, int include_children, int use_object_instantiation, + int sort_by_name, int second_life) { collada_export(scene, filepath, selected, apply_modifiers, include_armatures, include_children, - use_object_instantiation, second_life); + use_object_instantiation, sort_by_name, second_life); } #endif @@ -130,6 +131,7 @@ void RNA_api_scene(StructRNA *srna) parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Include armature(s) used by the exported objects"); 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, "sort_by_name", 0, "Sort by Object name", "Sort exported data by Object name"); 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 e16a7befdd5..b4bec014b9c 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2167,6 +2167,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) int apply_modifiers; int include_children; int use_object_instantiation; + int sort_by_name; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); @@ -2182,6 +2183,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) include_armatures = RNA_boolean_get(op->ptr, "include_armatures"); include_children = RNA_boolean_get(op->ptr, "include_children"); use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); + sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name"); second_life = RNA_boolean_get(op->ptr, "second_life"); /* get editmode results */ @@ -2195,6 +2197,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) include_armatures, include_children, use_object_instantiation, + sort_by_name, second_life)) { return OPERATOR_FINISHED; } @@ -2232,6 +2235,9 @@ static void WM_OT_collada_export(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instantiation", "Instantiate multiple Objects from same Data"); + RNA_def_boolean(ot->srna, "sort_by_name", 0, "Sort by Object name", + "Sort exported data by Object name"); + RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); } |