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
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.
-rw-r--r--source/blender/makesrna/intern/rna_animation.c3
-rw-r--r--source/blender/makesrna/intern/rna_animation_api.c27
-rw-r--r--source/blender/makesrna/intern/rna_internal.h1
3 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 5970149273e..6a5bae28cc1 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -1303,6 +1303,9 @@ static void rna_def_animdata(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Use NLA Tweak Mode", "Whether to enable or disable tweak mode in NLA");
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, "rna_AnimData_update");
+
+ /* Animation Data API */
+ RNA_api_animdata(srna);
}
/* --- */
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
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 3653f28c880..fc0950c1bb0 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -342,6 +342,7 @@ char *rna_Node_ImageUser_path(struct PointerRNA *ptr);
/* API functions */
void RNA_api_action(StructRNA *srna);
+void RNA_api_animdata(struct StructRNA *srna);
void RNA_api_armature_edit_bone(StructRNA *srna);
void RNA_api_bone(StructRNA *srna);
void RNA_api_camera(StructRNA *srna);