Fix: Stepping issue with Butterworth filter

The same issue for Smooth (Gaussian) which was reported in #109799 also affects the Butterworth filter.
When keys were not exactly on the frame, but offset even by minimal values the filter would introduce stepping.
Fix it by using `round()` instead of `(int)` when calculating the index to the filtered values array

Pull Request: https://projects.blender.org/blender/blender/pulls/110060
This commit is contained in:
Christoph Lendenfeld
2023-07-13 15:47:29 +02:00
committed by Christoph Lendenfeld
parent 4724147479
commit 39cc72ea25

View File

@@ -557,7 +557,9 @@ void butterworth_smooth_fcurve_segment(FCurve *fcu,
}
const float x_delta = fcu->bezt[i].vec[1][0] - left_bezt.vec[1][0] + filter_order;
const int filter_index = (int)(x_delta * sample_rate);
/* Using round() instead of casting to int. Casting would introduce a stepping issue when the
* x-value is just below a full frame. */
const int filter_index = round(x_delta * sample_rate);
const float blend_value = butterworth_calculate_blend_value(samples,
filtered_values,
samples_start_index,