Animation: Match Slope slider #110567

Merged
Christoph Lendenfeld merged 24 commits from ChrisLend/blender:blend_to_infinity_slider into main 2023-08-17 10:28:56 +02:00
2 changed files with 17 additions and 14 deletions
Showing only changes of commit 5761ec49be - Show all commits

View File

@ -500,8 +500,6 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
* slider. */
const float bidirectional_factor = fabs(factor * 2 - 1);
float x_delta = 1;
float y_delta = 1;
BezTriple beyond_key;
const BezTriple *reference_key;
@ -510,7 +508,7 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
if (factor >= 0.5) {
/* Stop the function if there is no key beyond the the right neighboring one. */
if (segment->start_index + segment->length >= fcu->totvert - 1) {
if (segment->start_index + segment->length > fcu->totvert - 1) {
return;
}
@ -520,7 +518,7 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
else {
/* Stop the function if there is no key beyond the left neighboring one. */
if (segment->start_index <= 1) {
if (segment->start_index == 1) {
return;
}
@ -528,17 +526,14 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
beyond_key = fcu->bezt[segment->start_index - 2];
}
y_delta = beyond_key.vec[1][1] - reference_key->vec[1][1];
x_delta = beyond_key.vec[1][0] - reference_key->vec[1][0];
const float y_delta = beyond_key.vec[1][1] - reference_key->vec[1][1];
const float x_delta = beyond_key.vec[1][0] - reference_key->vec[1][0];
/* Avoids dividing by 0. */
if (x_delta == 0) {
return;
}
float new_x_delta;
float new_y_delta;
if (factor >= 0.5) {
reference_key = right_key;
}
@ -550,8 +545,8 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
/* These new deltas are used to determine the relationship between the current key and the
* bookend ones. */
new_x_delta = fcu->bezt[i].vec[1][0] - reference_key->vec[1][0];
new_y_delta = new_x_delta * y_delta / x_delta;
const float new_x_delta = fcu->bezt[i].vec[1][0] - reference_key->vec[1][0];
const float new_y_delta = new_x_delta * y_delta / x_delta;
const float delta = reference_key->vec[1][1] + new_y_delta - fcu->bezt[i].vec[1][1];

View File

@ -1074,9 +1074,17 @@ static void blend_to_infinity_graph_keys(bAnimContext *ac, const float factor)
ListBase segments = find_fcurve_segments(fcu);
LISTBASE_FOREACH (FCurveSegment *, segment, &segments) {
if (segment->start_index + segment->length >= fcu->totvert - 1 ||
segment->start_index <= 1) {
WM_report(RPT_WARNING, "You need at least 2 keys to eider side of the selection.");
if (factor >= 0.5){
if (segment->start_index + segment->length >= fcu->totvert - 1) {
WM_report(RPT_WARNING, "You need at least 2 keys to the right side of the selection.");
continue;
}
}
else {
if (segment->start_index <= 1) {
WM_report(RPT_WARNING, "You need at least 2 keys to the left side of the selection.");
continue;
}
}
blend_to_infinity_fcurve_segment(fcu, segment, factor);
}