Animation: shear left slider #106521
|
@ -494,26 +494,17 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor
|
||||||
void shear_left_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
|
void shear_left_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
|
||||||
{
|
{
|
||||||
const BezTriple *left_key = fcurve_segment_start_get(fcu, segment->start_index);
|
const BezTriple *left_key = fcurve_segment_start_get(fcu, segment->start_index);
|
||||||
const float left_x = left_key->vec[1][0];
|
|
||||||
const float left_y = left_key->vec[1][1];
|
|
||||||
|
|
||||||
const BezTriple *right_key = fcurve_segment_end_get(fcu, segment->start_index + segment->length);
|
const BezTriple *right_key = fcurve_segment_end_get(fcu, segment->start_index + segment->length);
|
||||||
|
|
||||||
const float key_x_range = right_key->vec[1][0] - left_x;
|
const float key_x_range = right_key->vec[1][0] - left_key->vec[1][0];
|
||||||
const float key_y_range = right_key->vec[1][1] - left_y;
|
const float key_y_range = right_key->vec[1][1] - left_key->vec[1][1];
|
||||||
|
|
||||||
/* Happens if there is only 1 key on the FCurve. Needs to be skipped because it
|
|
||||||
* would be a divide by 0. */
|
|
||||||
if (IS_EQF(key_x_range, 0.0f)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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;
|
||||||
|
|
||||||
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
||||||
/* 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_x) / key_x_range;
|
const float normalized_x = (fcu->bezt[i].vec[1][0] - left_key->vec[1][0]) / key_x_range;
|
||||||
|
|
||||||
const float lineal = key_y_range * normalized_x;
|
const float lineal = key_y_range * normalized_x;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue