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-10-05 23:02:37 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-10-05 23:02:37 +0300
commit8882b3d7b67e5047bb57ae056226a4d5385d93c7 (patch)
tree7e6c94c01e55597877901bea08b1435763de2301 /source/blender/editors/armature/armature_naming.c
parenta33a4e132eef24261b12acecfe69a8d41aebfaa1 (diff)
Multi-Objects: ARMATURE_OT_autoside_names
Diffstat (limited to 'source/blender/editors/armature/armature_naming.c')
-rw-r--r--source/blender/editors/armature/armature_naming.c60
1 files changed, 37 insertions, 23 deletions
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)