Animation: Gaussian Smooth operator for Graph Editor #105635

Merged
Christoph Lendenfeld merged 15 commits from ChrisLend/blender:graph_gauss_smooth into main 2023-03-24 12:11:33 +01:00
1 changed files with 2 additions and 1 deletions
Showing only changes of commit f1a2c21ae1 - Show all commits

View File

@ -435,7 +435,8 @@ void smooth_fcurve_segment(FCurve *fcu,
for (int j = -kernel_size; j <= kernel_size; j++) {

This comment should swap with the line above it, as double filter_result = samples[sample_index] * kernel[0]; is already part of applying the kernel.

This comment should swap with the line above it, as `double filter_result = samples[sample_index] * kernel[0];` is already part of applying the kernel.
filter_result += samples[sample_index + j] * kernel[abs(j)];

What do you think would be faster? The current approach? Or halving the loop and avoiding the call to abs(j)?

    double filter_result = samples[sample_index] * kernel[0];
    for (int j = 1; j <= kernel_size; j++) {
      const double kernel_value = kernel[j];
      filter_result += samples[sample_index + j] * kernel_value;
      filter_result += samples[sample_index - j] * kernel_value;
    }
What do you think would be faster? The current approach? Or halving the loop and avoiding the call to `abs(j)`? ```c double filter_result = samples[sample_index] * kernel[0]; for (int j = 1; j <= kernel_size; j++) { const double kernel_value = kernel[j]; filter_result += samples[sample_index + j] * kernel_value; filter_result += samples[sample_index - j] * kernel_value; } ```
}
fcu->bezt[i].vec[1][1] = interpf((float)filter_result, samples[sample_index], factor);
const float key_y_value = interpf((float)filter_result, samples[sample_index], factor);
move_key(&fcu->bezt[i], key_y_value);
}
}
/* ---------------- */