[Bf-blender-cvs] [8882b3d7b67] blender2.8: Multi-Objects: ARMATURE_OT_autoside_names

Dalai Felinto noreply at git.blender.org
Fri Oct 5 22:03:52 CEST 2018


Commit: 8882b3d7b67e5047bb57ae056226a4d5385d93c7
Author: Dalai Felinto
Date:   Fri Oct 5 17:02:37 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB8882b3d7b67e5047bb57ae056226a4d5385d93c7

Multi-Objects: ARMATURE_OT_autoside_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 8769d6573e4..dd9cd0f9d05 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -474,36 +474,50 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot)
 	                "(WARNING: may result in incoherent naming in some cases)");
 }
 
-
 static int armature_autoside_names_exec(bContext *C, wmOperator *op)
 {
+	ViewLayer *view_layer = CTX_data_view_layer(C);
 	Main *bmain = CTX_data_main(C);
-	Object *ob = CTX_data_edit_object(C);
-	bArmature *arm;
 	char newname[MAXBONENAME];
-	short axis = RNA_enum_get(op->ptr, "type");
-
-	/* paranoia checks */
-	if (ELEM(NULL, ob, ob->pose))
-		return OPERATOR_CANCELLED;
-	arm = ob->data;
-
-	/* loop through selected bones, auto-naming them */
-	CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
-	{
-		BLI_strncpy(newname, ebone->name, sizeof(newname));
-		if (bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis]))
-			ED_armature_bone_rename(bmain, arm, ebone->name, newname);
-	}
-	CTX_DATA_END;
+	const short axis = RNA_enum_get(op->ptr, "type");
+	bool multi_changed = false;
 
-	/* since we renamed stuff... */
-	DEG_id_tag_update(&ob->id, OB_RECALC_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;
+		bool changed = false;
 
-	/* note, notifier might evolve */
-	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+		/* Paranoia checks. */
+		if (ELEM(NULL, ob, ob->pose)) {
+			continue;
+		}
 
-	return OPERATOR_FINISHED;
+		for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+			if (EBONE_EDITABLE(ebone)) {
+				BLI_strncpy(newname, ebone->name, sizeof(newname));
+				if (bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis])) {
+					ED_armature_bone_rename(bmain, arm, ebone->name, newname);
+					changed = true;
+				}
+			}
+		}
+
+		if (!changed) {
+			continue;
+		}
+
+		multi_changed = true;
+
+		/* Since we renamed stuff... */
+		DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+
+		/* Note, notifier might evolve. */
+		WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+	}
+	MEM_freeN(objects);
+	return multi_changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
 
 void ARMATURE_OT_autoside_names(wmOperatorType *ot)



More information about the Bf-blender-cvs mailing list