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-12 20:23:06 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-10-12 20:42:08 +0300
commitc7bbcfe95444e730eacf655fd982f5091d5e2ff6 (patch)
treef58ca3c81b1869673db364e6da921727e32bf188
parent2677e99217050e69193c0eab881e4d64c505a932 (diff)
Multi-Objects: POSE_OT_autoside_names
Using CTX_DATA_BEGIN_WITH_ID here. Unlike the edit mode counter-part this operator is well served with the macro above. ARMATURE_OT_autoside_names needs to treat mirrored bones separately, while for pose we don't handle those cases. Be ware that using this macro makes the code smaller, however it also tags every single (selected) pose to update, regardless of whether we changed the names of the bones. In this case it is fine since we most likely renamed all the bones. But In other cases I'm still a bit wary of using CTX_DATA_BEGIN_WITH_ID instead of BKE_view_layer_array_from_objects_in_mode_unique_data. To be seen in upcoming commits. Stay tuned.
-rw-r--r--source/blender/editors/armature/pose_edit.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 13a54770338..b4651c82f5c 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -775,30 +775,29 @@ void POSE_OT_flip_names(wmOperatorType *ot)
static int pose_autoside_names_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm;
char newname[MAXBONENAME];
short axis = RNA_enum_get(op->ptr, "axis");
-
- /* paranoia checks */
- if (ELEM(NULL, ob, ob->pose))
- return OPERATOR_CANCELLED;
- arm = ob->data;
+ Object *ob_prev = NULL;
/* loop through selected bones, auto-naming them */
- CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
+ CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob)
{
+ bArmature *arm = ob->data;
BLI_strncpy(newname, pchan->name, sizeof(newname));
- if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis]))
+ if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis])) {
ED_armature_bone_rename(bmain, arm, pchan->name, newname);
- }
- CTX_DATA_END;
+ }
- /* since we renamed stuff... */
- DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ if (ob_prev != ob) {
+ /* 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);
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+ ob_prev = ob;
+ }
+ }
+ CTX_DATA_END;
return OPERATOR_FINISHED;
}