Fix #123328: Onion skinning causes change in opacity for current frame

Toggling the layer onion skinning toggle would affect the opacity
of strokes on the current frame.

This was caused by the `get_visible_frames_for_layer` function. It computes
a `frame_id` for all the keyframes that are not the currenty visible
keyframe. To skip over the currently visible keyframe on the layer,
it just compared the start frame of the keyframe with the current
scene frame. This only works if the current frame is over the keyframe,
but not for any frames after (even if the same keyframe is still visible).

The fix computes the start frame of the keyframe under the current frame
first, and then uses that to compare to the start frame during the iteration
over all keyframes. This makes sure that we skip over the currently visible
keyframe in that layer.

Pull Request: https://projects.blender.org/blender/blender/pulls/123358
This commit is contained in:
Falk David 2024-06-18 12:29:32 +02:00 committed by Falk David
parent a62860229c
commit fad85d303f

@ -346,9 +346,10 @@ static Array<std::pair<int, int>> get_visible_frames_for_layer(
const int last_frame = sorted_keys.last();
const int last_frame_index = sorted_keys.index_range().last();
const bool is_before_first = (current_frame < sorted_keys.first());
const std::optional<int> current_start_frame = layer.start_frame_at(current_frame);
for (const int frame_i : sorted_keys.index_range()) {
const int frame_number = sorted_keys[frame_i];
if (frame_number == current_frame) {
if (current_start_frame && *current_start_frame == frame_number) {
continue;
}
const GreasePencilFrame &frame = layer.frames().lookup(frame_number);