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:
authorDalai Felinto <dfelinto@gmail.com>2018-09-29 00:20:34 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-09-29 00:23:32 +0300
commit47cf8bd92847c6837e7af5bd0edbfe1d62fdcaf5 (patch)
tree4d4a34f0008da65549bb430c263a9dd7fce32283 /source/blender/editors/armature/armature_naming.c
parentf4fe3f197552cf24ea4d950356829785c1722a54 (diff)
Multiple-Objects: ARMATURE_OT_flip_names
Diffstat (limited to 'source/blender/editors/armature/armature_naming.c')
-rw-r--r--source/blender/editors/armature/armature_naming.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index 4440ccb3e42..8769d6573e4 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -31,6 +31,8 @@
#include <string.h>
+#include "MEM_guardedalloc.h"
+
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
@@ -51,6 +53,7 @@
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_global.h"
+#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_gpencil_modifier.h"
@@ -402,38 +405,52 @@ void ED_armature_bones_flip_names(Main *bmain, bArmature *arm, ListBase *bones_n
static int armature_flip_names_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- Object *ob = CTX_data_edit_object(C);
- bArmature *arm;
-
- /* paranoia checks */
- if (ELEM(NULL, ob, ob->pose))
- return OPERATOR_CANCELLED;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob_active = CTX_data_edit_object(C);
const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers");
- arm = ob->data;
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob = objects[ob_index];
+ bArmature *arm = ob->data;
- ListBase bones_names = {NULL};
+ /* Paranoia check. */
+ if (ob_active->pose == NULL) {
+ continue;
+ }
- CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
- {
- BLI_addtail(&bones_names, BLI_genericNodeN(ebone->name));
- }
- CTX_DATA_END;
+ ListBase bones_names = {NULL};
- ED_armature_bones_flip_names(bmain, arm, &bones_names, do_strip_numbers);
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (EBONE_VISIBLE(arm, ebone)) {
+ if (ebone->flag & BONE_SELECTED) {
+ BLI_addtail(&bones_names, BLI_genericNodeN(ebone->name));
+ }
+ }
+ }
- BLI_freelistN(&bones_names);
+ if (BLI_listbase_is_empty(&bones_names)) {
+ continue;
+ }
- /* since we renamed stuff... */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ ED_armature_bones_flip_names(bmain, arm, &bones_names, do_strip_numbers);
+
+ BLI_freelistN(&bones_names);
+
+ /* since we renamed stuff... */
+ DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
- /* copied from #rna_Bone_update_renamed */
- /* redraw view */
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+ /* copied from #rna_Bone_update_renamed */
+ /* redraw view */
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
- /* update animation channels */
- WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, ob->data);
+ /* update animation channels */
+ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, ob->data);
+
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}