From f4a2024c448568badb44709b342d4f47002c456b Mon Sep 17 00:00:00 2001 From: Nathan Craddock Date: Tue, 15 Sep 2020 15:09:41 -0600 Subject: Constraints: Add link and copy functions Add functions to copy a single constraint between objects or between bones, and another function to link constraints. This is in preparation for constraint drag and drop in the outliner. Differential Revision: https://developer.blender.org/D8642 --- source/blender/editors/object/object_constraint.c | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to '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 f0a320e42cf..b062ae0c698 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1436,6 +1436,34 @@ bool ED_object_constraint_move_to_index(Object *ob, bConstraint *con, const int return true; } + +void ED_object_constraint_link(Main *bmain, Object *ob_dst, ListBase *dst, ListBase *src) +{ + BKE_constraints_free(dst); + BKE_constraints_copy(dst, src, true); + LISTBASE_FOREACH (bConstraint *, con, dst) { + ED_object_constraint_dependency_tag_update(bmain, ob_dst, con); + } + WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL); +} + +void ED_object_constraint_copy_for_object(Main *bmain, Object *ob_dst, bConstraint *con) +{ + BKE_constraint_copy_for_object(ob_dst, con); + ED_object_constraint_dependency_tag_update(bmain, ob_dst, con); + WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob_dst); +} + +void ED_object_constraint_copy_for_pose(Main *bmain, + Object *ob_dst, + bPoseChannel *pchan, + bConstraint *con) +{ + BKE_constraint_copy_for_pose(ob_dst, pchan, con); + ED_object_constraint_dependency_tag_update(bmain, ob_dst, con); + WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob_dst); +} + /** \} */ /* ------------------------------------------------------------------- */ -- cgit v1.2.3