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:
authorWayde Moss <wbmoss_dev@yahoo.com>2020-11-12 13:53:12 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-11-12 14:02:49 +0300
commitdbbfba942867d907706222e3b0094cb18f517352 (patch)
tree624a6683bb3c1a746a6c65b4ebc1d07a454d2e69 /source/blender/makesrna/intern/rna_fcurve.c
parent9067cd64a5083c214fd37fd65bea374312abad10 (diff)
Fix T81813: Keyframe handles don't follow keyframes
Add a new property `co_ui` to Keyframes, the modification of which will apply to the keyframe itself as well as its Bézier handles. Dragging the "Keyframe" slider in the properties panel now maintains the deltas between the keyframe and its handles, just like moving the key in the graph editor would. Reviewed by @sybren in T81813.
Diffstat (limited to 'source/blender/makesrna/intern/rna_fcurve.c')
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 1c5e3688312..38328628f11 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -463,6 +463,27 @@ static void rna_FKeyframe_ctrlpoint_set(PointerRNA *ptr, const float *values)
bezt->vec[1][1] = values[1];
}
+static void rna_FKeyframe_ctrlpoint_ui_set(PointerRNA *ptr, const float *values)
+{
+ BezTriple *bezt = (BezTriple *)ptr->data;
+
+ const float frame_delta = values[0] - bezt->vec[1][0];
+ const float value_delta = values[1] - bezt->vec[1][1];
+
+ /** To match the behavior of transforming the keyframe Co using the Graph Editor
+ * (transform_convert_graph.c) flushTransGraphData(), we will also move the handles by
+ * the same amount as the Co delta. */
+
+ bezt->vec[0][0] += frame_delta;
+ bezt->vec[0][1] += value_delta;
+
+ bezt->vec[1][0] = values[0];
+ bezt->vec[1][1] = values[1];
+
+ bezt->vec[2][0] += frame_delta;
+ bezt->vec[2][1] += value_delta;
+}
+
/* ****************************** */
static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value)
@@ -2099,6 +2120,18 @@ static void rna_def_fkeyframe(BlenderRNA *brna)
RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
prop = RNA_def_property(
+ srna, "co_ui", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
+ RNA_def_property_array(prop, 2);
+ RNA_def_property_float_funcs(
+ prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_ui_set", NULL);
+ RNA_def_property_ui_text(
+ prop,
+ "Control Point",
+ "Coordinates of the control point. Note: Changing this value also updates the handles "
+ "similar to using the graph editor transform operator");
+ RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
+
+ prop = RNA_def_property(
srna, "handle_right", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(