Commit: ce7c6e3894b0787f0feadccea893b4574374d6ae
Author: Joshua Leung
Date:   Wed Apr 25 17:52:02 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBce7c6e3894b0787f0feadccea893b4574374d6ae

Multi-Pose: Port POSE_OT_select_mirror

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

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

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

diff --git a/source/blender/editors/armature/pose_select.c 
b/source/blender/editors/armature/pose_select.c
index 67e1572abfa..c1c5afaca54 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -925,59 +925,60 @@ void POSE_OT_select_grouped(wmOperatorType *ot)
 static int pose_select_mirror_exec(bContext *C, wmOperator *op)
 {
        Object *ob_act = CTX_data_active_object(C);
-       Object *ob = BKE_object_pose_armature_get(ob_act);
-       bArmature *arm;
-       bPoseChannel *pchan, *pchan_mirror_act = NULL;
-       const bool active_only = RNA_boolean_get(op->ptr, "only_active");
-       const bool extend = RNA_boolean_get(op->ptr, "extend");
+       ViewLayer *view_layer = CTX_data_view_layer(C);
 
-       if ((ob && (ob->mode & OB_MODE_POSE)) == 0) {
-               return OPERATOR_CANCELLED;
-       }
+       FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, OB_MODE_POSE, ob)
+       {
+               bArmature *arm;
+               bPoseChannel *pchan, *pchan_mirror_act = NULL;
+               const bool active_only = RNA_boolean_get(op->ptr, 
"only_active");
+               const bool extend = RNA_boolean_get(op->ptr, "extend");
 
-       arm = ob->data;
+               arm = ob->data;
 
-       for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-               const int flag = (pchan->bone->flag & BONE_SELECTED);
-               PBONE_PREV_FLAG_SET(pchan, flag);
-       }
-
-       for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-               if (PBONE_SELECTABLE(arm, pchan->bone)) {
-                       bPoseChannel *pchan_mirror;
-                       int flag_new = extend ? PBONE_PREV_FLAG_GET(pchan) : 0;
+               for (pchan = ob->pose->chanbase.first; pchan; pchan = 
pchan->next) {
+                       const int flag = (pchan->bone->flag & BONE_SELECTED);
+                       PBONE_PREV_FLAG_SET(pchan, flag);
+               }
 
-                       if ((pchan_mirror = 
BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) &&
-                           (PBONE_VISIBLE(arm, pchan_mirror->bone)))
-                       {
-                               const int flag_mirror = 
PBONE_PREV_FLAG_GET(pchan_mirror);
-                               flag_new |= flag_mirror;
+               for (pchan = ob->pose->chanbase.first; pchan; pchan = 
pchan->next) {
+                       if (PBONE_SELECTABLE(arm, pchan->bone)) {
+                               bPoseChannel *pchan_mirror;
+                               int flag_new = extend ? 
PBONE_PREV_FLAG_GET(pchan) : 0;
+
+                               if ((pchan_mirror = 
BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) &&
+                                   (PBONE_VISIBLE(arm, pchan_mirror->bone)))
+                               {
+                                       const int flag_mirror = 
PBONE_PREV_FLAG_GET(pchan_mirror);
+                                       flag_new |= flag_mirror;
+
+                                       if (pchan->bone == arm->act_bone) {
+                                               pchan_mirror_act = pchan_mirror;
+                                       }
 
-                               if (pchan->bone == arm->act_bone) {
-                                       pchan_mirror_act = pchan_mirror;
+                                       /* skip all but the active or its 
mirror */
+                                       if (active_only && !ELEM(arm->act_bone, 
pchan->bone, pchan_mirror->bone)) {
+                                               continue;
+                                       }
                                }
 
-                               /* skip all but the active or its mirror */
-                               if (active_only && !ELEM(arm->act_bone, 
pchan->bone, pchan_mirror->bone)) {
-                                       continue;
-                               }
+                               pchan->bone->flag = (pchan->bone->flag & 
~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) | flag_new;
                        }
-
-                       pchan->bone->flag = (pchan->bone->flag & 
~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) | flag_new;
                }
-       }
 
-       if (pchan_mirror_act) {
-               arm->act_bone = pchan_mirror_act->bone;
+               if (pchan_mirror_act) {
+                       arm->act_bone = pchan_mirror_act->bone;
 
-               /* in weightpaint we select the associated vertex group too */
-               if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
-                       ED_vgroup_select_by_name(ob_act, 
pchan_mirror_act->name);
-                       DEG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
+                       /* in weightpaint we select the associated vertex group 
too */
+                       if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
+                               ED_vgroup_select_by_name(ob_act, 
pchan_mirror_act->name);
+                               DEG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
+                       }
                }
-       }
 
-       WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+               WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+       }
+       FOREACH_OBJECT_IN_MODE_END;
 
        return OPERATOR_FINISHED;
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to