|
|
@ -508,7 +508,8 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
|
|
|
|
const float beyond_left_y = beyond_left_key->vec[1][1];
|
|
|
|
const float beyond_left_y = beyond_left_key->vec[1][1];
|
|
|
|
|
|
|
|
|
|
|
|
/* One key on the outside right side of the neighboring keys is needed to use as reference. */
|
|
|
|
/* One key on the outside right side of the neighboring keys is needed to use as reference. */
|
|
|
|
const BezTriple *beyond_right_key = fcurve_segment_end_get(fcu, segment->start_index + segment->length + 1);
|
|
|
|
const BezTriple *beyond_right_key = fcurve_segment_end_get(
|
|
|
|
|
|
|
|
fcu, segment->start_index + segment->length + 1);
|
|
|
|
|
|
|
|
|
|
|
|
const float beyond_right_x = beyond_right_key->vec[1][0];
|
|
|
|
const float beyond_right_x = beyond_right_key->vec[1][0];
|
|
|
|
const float beyond_right_y = beyond_right_key->vec[1][1];
|
|
|
|
const float beyond_right_y = beyond_right_key->vec[1][1];
|
|
|
@ -525,7 +526,8 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
|
|
|
|
const bool slider_right_side = factor >= 0.5;
|
|
|
|
const bool slider_right_side = factor >= 0.5;
|
|
|
|
const bool slider_left_side = factor < 0.5;
|
|
|
|
const bool slider_left_side = factor < 0.5;
|
|
|
|
|
|
|
|
|
|
|
|
/* The factor goes from 0 to 1, but for this tool it needs to go from 0 to 1 on each side of the slider. */
|
|
|
|
/* The factor goes from 0 to 1, but for this tool it needs to go from 0 to 1 on each side of the
|
|
|
|
|
|
|
|
* slider. */
|
|
|
|
const float ping_pong_factor = fabs(factor * 2 - 1);
|
|
|
|
const float ping_pong_factor = fabs(factor * 2 - 1);
|
|
|
|
|
|
|
|
|
|
|
|
float x_delta = 0;
|
|
|
|
float x_delta = 0;
|
|
|
@ -533,18 +535,18 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
|
|
|
|
|
|
|
|
|
|
|
|
/* This delta values are used to know the relationship between the bookend keys and the
|
|
|
|
/* This delta values are used to know the relationship between the bookend keys and the
|
|
|
|
* reference keys beyong those. */
|
|
|
|
* reference keys beyong those. */
|
|
|
|
if(slider_right_side){
|
|
|
|
if (slider_right_side) {
|
|
|
|
/* Stop the fucntion if there is no key beyond the the right neighboring one. */
|
|
|
|
/* Stop the fucntion if there is no key beyond the the right neighboring one. */
|
|
|
|
if(segment->start_index + segment->length == fcu->totvert) {
|
|
|
|
if (segment->start_index + segment->length == fcu->totvert) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
y_delta = beyond_right_y - right_y;
|
|
|
|
y_delta = beyond_right_y - right_y;
|
|
|
|
x_delta = beyond_right_x - right_x;
|
|
|
|
x_delta = beyond_right_x - right_x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(slider_left_side){
|
|
|
|
else if (slider_left_side) {
|
|
|
|
/* Stop the fucntion if there is no key beyond the left neighboring one. */
|
|
|
|
/* Stop the fucntion if there is no key beyond the left neighboring one. */
|
|
|
|
if(segment->start_index == 0) {
|
|
|
|
if (segment->start_index == 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
y_delta = beyond_left_y - left_y;
|
|
|
|
y_delta = beyond_left_y - left_y;
|
|
|
|
x_delta = beyond_left_x - left_x;
|
|
|
|
x_delta = beyond_left_x - left_x;
|
|
|
@ -560,7 +562,8 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
|
|
|
|
float new_y_delta = 0;
|
|
|
|
float new_y_delta = 0;
|
|
|
|
float refe = 0;
|
|
|
|
float refe = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* This new deltas are used to determin the relationship between the current key and the bookend ones. */
|
|
|
|
/* This new deltas are used to determin the relationship between the current key and the
|
|
|
|
|
|
|
|
* bookend ones. */
|
|
|
|
if (slider_right_side) {
|
|
|
|
if (slider_right_side) {
|
|
|
|
new_x_delta = fcu->bezt[i].vec[1][0] - right_x;
|
|
|
|
new_x_delta = fcu->bezt[i].vec[1][0] - right_x;
|
|
|
|
refe = right_y;
|
|
|
|
refe = right_y;
|
|
|
@ -570,8 +573,9 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
|
|
|
|
refe = left_key->vec[1][1];
|
|
|
|
refe = left_key->vec[1][1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* we use compound rule of 3 to find the "Y" delta we are missing using the other deltas we know. */
|
|
|
|
/* we use compound rule of 3 to find the "Y" delta we are missing using the other deltas we
|
|
|
|
if(x_delta != 0){
|
|
|
|
* know. */
|
|
|
|
|
|
|
|
if (x_delta != 0) {
|
|
|
|
new_y_delta = new_x_delta * y_delta / x_delta;
|
|
|
|
new_y_delta = new_x_delta * y_delta / x_delta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this can also be clearer.
segment->start_index + segment->length > fcu->totvert
I tried this change as well as the next one and it doesn't work as it should. Remember, we need 2 keys before and after the segment, the way you suggest just account for one. If I don't prevent not having 2 keys at each side of the segment the tool goes crazy.