Commit: 418c16bd3b799a95f9dc4d458213c60fba42626c
Author: Dalai Felinto
Date:   Tue Oct 16 19:20:01 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB418c16bd3b799a95f9dc4d458213c60fba42626c

Multi-Objects: POSE_OT_constraints_copy (refactor)

This was already supporting multiple objects, but I changed it to use the API
we are using elsewhere.

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

M       source/blender/editors/object/object_constraint.c

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

diff --git a/source/blender/editors/object/object_constraint.c 
b/source/blender/editors/object/object_constraint.c
index cfb781fcc28..0956bd4bf36 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1497,8 +1497,6 @@ static int pose_constraint_copy_exec(bContext *C, 
wmOperator *op)
 {
        Main *bmain = CTX_data_main(C);
        bPoseChannel *pchan = CTX_data_active_pose_bone(C);
-       ListBase lb;
-       CollectionPointerLink *link;
 
        /* don't do anything if bone doesn't exist or doesn't have any 
constraints */
        if (ELEM(NULL, pchan, pchan->constraints.first)) {
@@ -1506,23 +1504,25 @@ static int pose_constraint_copy_exec(bContext *C, 
wmOperator *op)
                return OPERATOR_CANCELLED;
        }
 
-       /* copy all constraints from active posebone to all selected posebones 
*/
-       CTX_data_selected_pose_bones(C, &lb);
-       for (link = lb.first; link; link = link->next) {
-               Object *ob = link->ptr.id.data;
-               bPoseChannel *chan = link->ptr.data;
+       Object *prev_ob = NULL;
 
+       /* copy all constraints from active posebone to all selected posebones 
*/
+       CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, chan, selected_pose_bones, 
Object *, ob)
+       {
                /* if we're not handling the object we're copying from, copy 
all constraints over */
                if (pchan != chan) {
                        BKE_constraints_copy(&chan->constraints, 
&pchan->constraints, true);
                        /* update flags (need to add here, not just copy) */
                        chan->constflag |= pchan->constflag;
 
-                       BKE_pose_tag_recalc(bmain, ob->pose);
-                       DEG_id_tag_update((ID *)ob, OB_RECALC_DATA);
+                       if (prev_ob != ob) {
+                               BKE_pose_tag_recalc(bmain, ob->pose);
+                               DEG_id_tag_update((ID *)ob, OB_RECALC_DATA);
+                               prev_ob = ob;
+                       }
                }
        }
-       BLI_freelistN(&lb);
+       CTX_DATA_END;
 
        /* force depsgraph to get recalculated since new relationships added */
        DEG_relations_tag_update(bmain);

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

Reply via email to