[Bf-blender-cvs] [a6434ff4170] master: Cleanup: Extract editor function from constraint_move_to_index_exec

Nathan Craddock noreply at git.blender.org
Tue Sep 15 23:35:59 CEST 2020


Commit: a6434ff4170b8a45228de688894b5b12185dc617
Author: Nathan Craddock
Date:   Tue Sep 15 14:56:13 2020 -0600
Branches: master
https://developer.blender.org/rBa6434ff4170b8a45228de688894b5b12185dc617

Cleanup: Extract editor function from constraint_move_to_index_exec

No functional changes. Move the constraint reordering logic into an ED_
level function to be used by outliner constraint drag and drop.

Differential Revision: https://developer.blender.org/D8642

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

M	source/blender/editors/include/ED_object.h
M	source/blender/editors/object/object_constraint.c

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

diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 8762ac6d0bb..282df25172f 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -343,6 +343,9 @@ void ED_object_constraint_dependency_tag_update(struct Main *bmain,
                                                 struct Object *ob,
                                                 struct bConstraint *con);
 
+bool ED_object_constraint_move_to_index(struct Object *ob,
+                                        struct bConstraint *con,
+                                        const int index);
 /* object_modes.c */
 bool ED_object_mode_compat_test(const struct Object *ob, eObjectMode mode);
 bool ED_object_mode_compat_set(struct bContext *C,
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 85522209e29..f0a320e42cf 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1421,6 +1421,21 @@ void ED_object_constraint_dependency_tag_update(Main *bmain, Object *ob, bConstr
   DEG_relations_tag_update(bmain);
 }
 
+bool ED_object_constraint_move_to_index(Object *ob, bConstraint *con, const int index)
+{
+  BLI_assert(con != NULL);
+  BLI_assert(index >= 0);
+
+  ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL);
+  int current_index = BLI_findindex(conlist, con);
+  BLI_assert(current_index >= 0);
+
+  BLI_listbase_link_move(conlist, con, index - current_index);
+
+  WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT, ob);
+
+  return true;
+}
 /** \} */
 
 /* ------------------------------------------------------------------- */
@@ -1613,13 +1628,7 @@ static int constraint_move_to_index_exec(bContext *C, wmOperator *op)
   }
 
   if (con) {
-    ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL);
-    int current_index = BLI_findindex(conlist, con);
-    BLI_assert(current_index >= 0);
-
-    BLI_listbase_link_move(conlist, con, new_index - current_index);
-
-    WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
+    ED_object_constraint_move_to_index(ob, con, new_index);
 
     return OPERATOR_FINISHED;
   }



More information about the Bf-blender-cvs mailing list