From 163baad17ebcf656be68cbc0fe7997c297ee799a Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 25 Jul 2024 09:34:37 +0200 Subject: [PATCH] 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 --- source/blender/editors/space_graph/graph_edit.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_graph/graph_edit.cc b/source/blender/editors/space_graph/graph_edit.cc index 9d8e7649e40..c1f1eca39db 100644 --- a/source/blender/editors/space_graph/graph_edit.cc +++ b/source/blender/editors/space_graph/graph_edit.cc @@ -2162,9 +2162,13 @@ static KeyframeEditData sum_selected_keyframes(bAnimContext *ac) ¤t_ked, static_cast(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; }