Animation: blend to ease slider #106519

Closed
AresDeveaux wants to merge 11 commits from AresDeveaux/blender:blend_to_ease_slider into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 18 additions and 14 deletions
Showing only changes of commit 181c5389eb - Show all commits

View File

@ -491,19 +491,24 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor
/* ---------------- */
float s_curve(float x, float slope, float width, float height, float xshift, float yshift) {
/* Formula for 'S' curve we use for the "ease" sliders. The shift values move the curve vertiacly or horizontaly.
* The range of the curve used is from 0 to 1 on "x" and "y" so we can scale it (width and height) and move it (xshift and y yshift)
* to crop the part of the curve we need. Slope determins how curvy the shape is */
float curve = height * pow((x - xshift), slope) / (pow((x - xshift), slope) + pow((width - (x - xshift)), slope)) + yshift;
float s_curve(float x, float slope, float width, float height, float xshift, float yshift)
{
/* Formula for 'S' curve we use for the "ease" sliders. The shift values move the curve vertiacly
* or horizontaly. The range of the curve used is from 0 to 1 on "x" and "y" so we can scale it
* (width and height) and move it (xshift and y yshift) to crop the part of the curve we need.
* Slope determins how curvy the shape is */
float curve = height * pow((x - xshift), slope) /

this could be renamed to y or curve_y
after all it's only a single point and not a whole curve

this could be renamed to `y` or `curve_y` after all it's only a single point and not a whole curve
(pow((x - xshift), slope) + pow((width - (x - xshift)), slope)) +
yshift;
/* The curve has some noise beyond our margins so we clamp the values */
if (x > xshift + width) {
curve = height + yshift;
} else if (x < xshift) {
curve = yshift;
}
return curve;
/* The curve has some noise beyond our margins so we clamp the values */
if (x > xshift + width) {
curve = height + yshift;
}
else if (x < xshift) {
curve = yshift;
}
return curve;
}
void blend_to_ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
@ -527,7 +532,7 @@ void blend_to_ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const flo
const bool slider_right_side = factor > 0.5;

you can also set the slider itself to go from -1/1 using ED_slider_is_bidirectional_set

you can also set the slider itself to go from -1/1 using `ED_slider_is_bidirectional_set`
/* The factor goes from 0 to 1, but for this tool it needs to go from -1 to 1. */
const float long_factor = factor * 2 - 1;
const float long_factor = factor * 2 - 1;
float y_delta;
@ -535,7 +540,6 @@ void blend_to_ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const flo
/* For easy calculation of the curve, the values are normalized. */
const float normalized_x = (fcu->bezt[i].vec[1][0] - left_key->vec[1][0]) / key_x_range;
if (slider_right_side) {
const float ease = s_curve(normalized_x, 3, 2.0, 2.0, -1.0, -1.0);
const float base = left_key->vec[1][1] + key_y_range * ease;