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
committed by Philipp Oeser
parent d80f0aa068
commit 163baad17e

View File

@@ -2162,9 +2162,13 @@ static KeyframeEditData sum_selected_keyframes(bAnimContext *ac)
&current_ked, static_cast<FCurve *>(ale->key_data), nullptr, bezt_calc_average, nullptr);
}
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;
}