Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-09-04 22:09:57 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-09-04 22:38:33 +0300
commit36e23c95e8f341883fdb5e0933e9430b9f7bdb41 (patch)
treedcc711f6108f5db67121f8ae9be3f7f4e22a706f /source/blender/makesrna/intern/rna_object.c
parente52ad1835a6aaefab389b173728b9bb7ef2e754a (diff)
Python API: add methods for reordering constraints.
Order matters for constraints, but there was no way to change it. The API follows other collections like idprops and node sockets.
Diffstat (limited to 'source/blender/makesrna/intern/rna_object.c')
-rw-r--r--source/blender/makesrna/intern/rna_object.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index c8a0d543b70..6dd75100e71 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1410,6 +1410,22 @@ static void rna_Object_constraints_clear(Object *object, Main *bmain)
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
}
+static void rna_Object_constraints_move(
+ Object *object, Main *bmain, ReportList *reports, int from, int to)
+{
+ if (from == to) {
+ return;
+ }
+
+ if (!BLI_listbase_move_index(&object->constraints, from, to)) {
+ BKE_reportf(reports, RPT_ERROR, "Could not move constraint from index '%d' to '%d'", from, to);
+ return;
+ }
+
+ ED_object_constraint_tag_update(bmain, object, NULL);
+ WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT, object);
+}
+
bool rna_Object_constraints_override_apply(Main *UNUSED(bmain),
PointerRNA *ptr_dst,
PointerRNA *ptr_src,
@@ -2041,6 +2057,15 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Remove all constraint from this object");
+
+ func = RNA_def_function(srna, "move", "rna_Object_constraints_move");
+ RNA_def_function_ui_description(func, "Move a constraint to a different position");
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
+ parm = RNA_def_int(
+ func, "from_index", -1, INT_MIN, INT_MAX, "From Index", "Index to move", 0, 10000);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_int(func, "to_index", -1, INT_MIN, INT_MAX, "To Index", "Target index", 0, 10000);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
/* object.modifiers */