Animation: blend to infinity slider #106517

Closed
AresDeveaux wants to merge 15 commits from AresDeveaux/blender:blend_to_infinity_slider into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 21 additions and 15 deletions
Showing only changes of commit 0c3f7500be - Show all commits

View File

@ -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];
/* 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);

this can also be clearer.
segment->start_index + segment->length > fcu->totvert

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.

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.
const float beyond_right_x = beyond_right_key->vec[1][0];
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;

shouldn't this return false?
also now that I think about it, I am not sure x_delta can ever be 0. It would only be 0 if the beyond key and the reference key are the same, which they cannot be since you are getting different indices.
Hm ok writing this now, you can have the curve in a state where two keys are at the same point in time. Shouldn't happen, but could...

Anyway, the function should return true if it ran and false if it didn't. Since you are exiting early here, I think it should return false.

shouldn't this return false? also now that I think about it, I am not sure x_delta can ever be 0. It would only be 0 if the beyond key and the reference key are the same, which they cannot be since you are getting different indices. Hm ok writing this now, you can have the curve in a state where two keys are at the same point in time. Shouldn't happen, but could... Anyway, the function should return true if it ran and false if it didn't. Since you are exiting early here, I think it should return false.
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);

since this is now outside of the if else, you can to
const float y_delta = ...
and then remove the lines 503 and 504

since this is now outside of the if else, you can to `const float y_delta = ...` and then remove the lines 503 and 504
float x_delta = 0;
@ -560,7 +562,8 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
float new_y_delta = 0;
float refe = 0;

generally it is better to not shorten variables. I assume this means reference
I think it would be even better to be more concrete and call it reference_y

Also I think this, including the if(slider_right_side), can be moved outside of the for loop.
It seems to not change within the for loop

generally it is better to not shorten variables. I assume this means `reference` I think it would be even better to be more concrete and call it `reference_y` Also I think this, including the `if(slider_right_side)`, can be moved outside of the for loop. It seems to not change within the for loop
/* 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

These new deltas are used to determine...

These new deltas are used to determine...
* bookend ones. */
if (slider_right_side) {
new_x_delta = fcu->bezt[i].vec[1][0] - right_x;
refe = right_y;
@ -570,7 +573,8 @@ void blend_to_infinity_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const
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

We ...
comments start with capital letters.

We ... comments start with capital letters.
* know. */
if (x_delta != 0) {
new_y_delta = new_x_delta * y_delta / x_delta;
}

View File

@ -437,7 +437,9 @@ void smooth_fcurve_segment(struct FCurve *fcu,
int kernel_size,
double *kernel);
void ease_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor);
void blend_to_infinity_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor);
void blend_to_infinity_fcurve_segment(struct FCurve *fcu,
struct FCurveSegment *segment,
float factor);
bool decimate_fcurve(struct bAnimListElem *ale, float remove_ratio, float error_sq_max);
void blend_to_default_fcurve(struct PointerRNA *id_ptr, struct FCurve *fcu, float factor);
/**