Fix #123352: Time offset chain mode inserts wrong keys

The time offset modifier inserts keys sequentially, overwriting earlier
frames with later ones, and only the last relevant frame remains used.

In chain mode this process is repeated for every chain segment and then
all segments are repeated to fill the entire timeline. However, because
all keyframes are inserted for every repetition, they can overwrite
keyframes from earlier repetitions as well.

Clamping the insert keyframe makes sure that no keys are inserted
outside of the target range for a give repetition.

Pull Request: https://projects.blender.org/blender/blender/pulls/123423
This commit is contained in:
Lukas Tönne
2024-06-19 12:42:21 +02:00
parent 5b572bd913
commit c714aa64e8

View File

@@ -248,12 +248,12 @@ static void insert_keys_forward(const TimeMapping &mapping,
const int offset = gp_dst_range.sfra - gp_src_range.sfra;
for (const int i : sorted_keys.index_range()) {
const int gp_key = sorted_keys[i];
const int gp_start_key = std::max(gp_key, gp_src_range.sfra);
if (gp_start_key > gp_src_range.efra) {
const int gp_insert_key = std::max(gp_key, gp_src_range.sfra);
if (gp_insert_key > gp_src_range.efra) {
continue;
}
const int scene_key = mapping.scene_frame_after_local_frame(gp_key + offset);
const int scene_key = mapping.scene_frame_after_local_frame(gp_insert_key + offset);
dst_frames.add_overwrite(scene_key, frames.lookup(gp_key));
}
}