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-05-13 21:01:03 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-05-13 22:09:42 +0300
commit27d097e92d543b14ad5400c61fb3ae674064d0d5 (patch)
tree48e83f6ef4ca78f73deb6e503ff1d5cb7eb9cea3 /source/blender/makesrna/intern/rna_animation_api.c
parentc6f975e3e58996cfdeec56741ea652e3f06f9b25 (diff)
Python API: expose conversion between tweaked NLA strip and scene time.
This is necessary to correctly do low-level keyframe manipulation in tweak mode, and the logic is complex enough that re-implementing it in Python is impractical.
Diffstat (limited to 'source/blender/makesrna/intern/rna_animation_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_animation_api.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c
index f201b8e6e99..e063e5de22c 100644
--- a/source/blender/makesrna/intern/rna_animation_api.c
+++ b/source/blender/makesrna/intern/rna_animation_api.c
@@ -37,6 +37,7 @@
# include "BKE_context.h"
# include "BKE_report.h"
+# include "BKE_nla.h"
# include "ED_keyframing.h"
@@ -59,6 +60,11 @@ static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList
}
}
+static float rna_AnimData_nla_tweak_strip_time_to_scene(AnimData *adt, float frame, bool invert)
+{
+ return BKE_nla_tweakedit_remap(adt, frame, invert ? NLATIME_CONVERT_UNMAP : NLATIME_CONVERT_MAP);
+}
+
#else
void RNA_api_keyingset(StructRNA *srna)
@@ -75,4 +81,25 @@ void RNA_api_keyingset(StructRNA *srna)
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
}
+void RNA_api_animdata(StructRNA *srna)
+{
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ /* Convert between action time and scene time when tweaking a NLA strip. */
+ func = RNA_def_function(
+ srna, "nla_tweak_strip_time_to_scene", "rna_AnimData_nla_tweak_strip_time_to_scene");
+ RNA_def_function_ui_description(func,
+ "Convert a time value from the local time of the tweaked strip "
+ "to scene time, exactly as done by built-in key editing tools. "
+ "Returns the input time unchanged if not tweaking.");
+ parm = RNA_def_float(
+ func, "frame", 0.0, MINAFRAME, MAXFRAME, "", "Input time", MINAFRAME, MAXFRAME);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_boolean(func, "invert", false, "Invert", "Convert scene time to action time");
+ parm = RNA_def_float(
+ func, "result", 0.0, MINAFRAME, MAXFRAME, "", "Converted time", MINAFRAME, MAXFRAME);
+ RNA_def_function_return(func, parm);
+}
+
#endif