[Bf-blender-cvs] [47cf8bd9284] blender2.8: Multiple-Objects: ARMATURE_OT_flip_names

Dalai Felinto noreply at git.blender.org
Fri Sep 28 23:26:02 CEST 2018


Commit: 47cf8bd92847c6837e7af5bd0edbfe1d62fdcaf5
Author: Dalai Felinto
Date:   Fri Sep 28 18:20:34 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB47cf8bd92847c6837e7af5bd0edbfe1d62fdcaf5

Multiple-Objects: ARMATURE_OT_flip_names

===================================================================

M	source/blender/editors/armature/armature_naming.c

===================================================================

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;
 }



More information about the Bf-blender-cvs mailing list