Animation: blend to ease slider #106519
|
@ -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) {
|
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)
|
/* Formula for 'S' curve we use for the "ease" sliders. The shift values move the curve vertiacly
|
||||||
* to crop the part of the curve we need. Slope determins how curvy the shape is */
|
* or horizontaly. The range of the curve used is from 0 to 1 on "x" and "y" so we can scale it
|
||||||
float curve = height * pow((x - xshift), slope) / (pow((x - xshift), slope) + pow((width - (x - xshift)), slope)) + yshift;
|
* (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;
|
||||||
|
|
||||||
/* The curve has some noise beyond our margins so we clamp the values */
|
/* The curve has some noise beyond our margins so we clamp the values */
|
||||||
if (x > xshift + width) {
|
if (x > xshift + width) {
|
||||||
curve = height + yshift;
|
curve = height + yshift;
|
||||||
} else if (x < xshift) {
|
}
|
||||||
curve = yshift;
|
else if (x < xshift) {
|
||||||
}
|
curve = yshift;
|
||||||
return curve;
|
}
|
||||||
|
return curve;
|
||||||
}
|
}
|
||||||
|
|
||||||
void blend_to_ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
|
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;
|
const bool slider_right_side = factor > 0.5;
|
||||||
|
|
||||||
/* The factor goes from 0 to 1, but for this tool it needs to go from -1 to 1. */
|
/* 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;
|
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. */
|
/* 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;
|
const float normalized_x = (fcu->bezt[i].vec[1][0] - left_key->vec[1][0]) / key_x_range;
|
||||||
|
|
||||||
|
|
||||||
if (slider_right_side) {
|
if (slider_right_side) {
|
||||||
const float ease = s_curve(normalized_x, 3, 2.0, 2.0, -1.0, -1.0);
|
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;
|
const float base = left_key->vec[1][1] + key_y_range * ease;
|
||||||
|
|
Loading…
Reference in New Issue
this could be renamed to
y
orcurve_y
after all it's only a single point and not a whole curve