Fix #125064 : Cursor Value to Selected wrong with Normalized FCurves

This affected cursor snapping as well as the `Jump to Keyframes`
operator since both use `sum_selected_keyframes` to get the averaged
values of elements. It was already taking into account the normalization
factor, but the way a single `KeyframeEditData` was created from
multiple `bAnimListElem` was wrong:

- first, we should only add to it if we actually have some keys selected
(not a problem without normalization, but with it, we would add values
there
- second, the offset needs to be taken into account for each selected
key when adding to the absolute values

Could go into LTS probably

Pull Request: https://projects.blender.org/blender/blender/pulls/125221
This commit is contained in:
Philipp Oeser 2024-07-25 09:34:37 +02:00
parent 99618031b3
commit c788de853e

View file

@ -2112,9 +2112,13 @@ static KeyframeEditData sum_selected_keyframes(bAnimContext *ac)
ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
}
if (current_ked.i1 == 0) {
continue;
}
ked.f1 += current_ked.f1;
ked.i1 += current_ked.i1;
ked.f2 += (current_ked.f2 + offset) * unit_scale;
ked.f2 += (current_ked.f2 + offset * current_ked.i1) * unit_scale;
ked.i2 += current_ked.i2;
}