From dbbfba942867d907706222e3b0094cb18f517352 Mon Sep 17 00:00:00 2001 From: Wayde Moss Date: Thu, 12 Nov 2020 11:53:12 +0100 Subject: Fix T81813: Keyframe handles don't follow keyframes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- source/blender/editors/space_graph/graph_buttons.c | 7 ++--- source/blender/makesrna/intern/rna_fcurve.c | 33 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index a491ce29bd4..3a4e1883cee 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -423,13 +423,14 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) but_max_width, UI_UNIT_Y, &bezt_ptr, - "co", + "co_ui", 0, 0, 0, 0, 0, NULL); + UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt); uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE); but = uiDefButR(block, @@ -441,7 +442,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) but_max_width, UI_UNIT_Y, &bezt_ptr, - "co", + "co_ui", 1, 0, 0, @@ -450,8 +451,6 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) NULL); UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt); UI_but_unit_type_set(but, unit); - - UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt); } /* previous handle - only if previous was Bezier interpolation */ 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) @@ -2098,6 +2119,18 @@ static void rna_def_fkeyframe(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point"); 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); -- cgit v1.2.3 From d0c1d93b7e7b453016ac83b3b1a57a220618a835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastia=CC=81n=20Barschkis?= Date: Thu, 12 Nov 2020 14:03:03 +0100 Subject: Fluid: Removed clamp from force assignment The clamp is too aggressive and results in forces being too weak. --- source/blender/blenkernel/intern/fluid.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index d93b635d67d..b9f201d8ada 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -3195,8 +3195,7 @@ static void update_effectors_task_cb(void *__restrict userdata, normalize_v3(retvel); mul_v3_fl(retvel, mag); - /* Constrain forces to interval -1 to 1. */ - CLAMP3(retvel, -1.0f, 1.0f); + /* Copy computed force to fluid solver forces. */ data->force_x[index] = retvel[0]; data->force_y[index] = retvel[1]; data->force_z[index] = retvel[2]; -- cgit v1.2.3