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_pose.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_pose.c')
-rw-r--r--source/blender/makesrna/intern/rna_pose.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 33d7d7d99cf..2f460e79ec9 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -601,6 +601,24 @@ static void rna_PoseChannel_constraints_remove(
}
}
+static void rna_PoseChannel_constraints_move(
+ ID *id, bPoseChannel *pchan, Main *bmain, ReportList *reports, int from, int to)
+{
+ Object *ob = (Object *)id;
+
+ if (from == to) {
+ return;
+ }
+
+ if (!BLI_listbase_move_index(&pchan->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, ob, NULL);
+ WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT, ob);
+}
+
bool rna_PoseChannel_constraints_override_apply(Main *UNUSED(bmain),
PointerRNA *ptr_dst,
PointerRNA *ptr_src,
@@ -929,6 +947,15 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro
parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+
+ func = RNA_def_function(srna, "move", "rna_PoseChannel_constraints_move");
+ RNA_def_function_ui_description(func, "Move a constraint to a different position");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | 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);
}
static void rna_def_pose_channel(BlenderRNA *brna)