[Bf-blender-cvs] [b178a1c9ca1] soc-2020-outliner: Outliner: Add constraint copy all

Nathan Craddock noreply at git.blender.org
Sat Jul 25 22:03:52 CEST 2020


Commit: b178a1c9ca18e68f5d61c6526cb187404b20f239
Author: Nathan Craddock
Date:   Sat Jul 25 12:00:28 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rBb178a1c9ca18e68f5d61c6526cb187404b20f239

Outliner: Add constraint copy all

Dragging the TSE_CONSTRAINT_BASE to another object or bone will copy all
of the constraints to the target from the source.

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

M	source/blender/editors/space_outliner/outliner_dragdrop.c

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

diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 43d108490a6..e16f5bc0503 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -26,6 +26,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_collection_types.h"
+#include "DNA_constraint_types.h"
 #include "DNA_material_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
@@ -906,6 +907,7 @@ static bool uistack_drop_poll(bContext *C,
 
 static void uistack_drop_link(bContext *C, OutlinerDropData *drop_data)
 {
+  Main *bmain = CTX_data_main(C);
   TreeStoreElem *tselem = TREESTORE(drop_data->drop_te);
   Object *ob_dst = (Object *)tselem->id;
 
@@ -915,6 +917,29 @@ static void uistack_drop_link(bContext *C, OutlinerDropData *drop_data)
     DEG_id_tag_update(&ob_dst->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
   }
   else if (drop_data->drag_tselem->type == TSE_CONSTRAINT_BASE) {
+    ListBase *src;
+
+    if (drop_data->bone_parent) {
+      src = &drop_data->bone_parent->constraints;
+    }
+    else {
+      src = &drop_data->ob_parent->constraints;
+    }
+
+    ListBase *dst;
+    if (tselem->type == TSE_POSE_CHANNEL) {
+      bPoseChannel *pchan = (bPoseChannel *)drop_data->drop_te->directdata;
+      dst = &pchan->constraints;
+    }
+    else {
+      dst = &ob_dst->constraints;
+    }
+
+    BKE_constraints_copy(dst, src, true);
+    LISTBASE_FOREACH (bConstraint *, con, dst) {
+      ED_object_constraint_dependency_tag_update(bmain, ob_dst, con);
+    }
+    WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL);
   }
   else if (drop_data->drag_tselem->type == TSE_EFFECT_BASE) {
   }



More information about the Bf-blender-cvs mailing list