Fix: Animation playback loop mode 'Stop at End' only works once

The animation playback loop mode 'Stop at End' stops playback at the
scene end frame (or the preview range end frame, if it's active). This
means that restarting playback from where it stopped (so on the end
frame) would immediately stop again. This is now resolved, by detecting
this special case and actually restarting playback at the start frame.

This takes into account reverse playback, where the meaning of 'start'
and 'end' are flipped.

Pull Request: https://projects.blender.org/blender/blender/pulls/160236
This commit is contained in:
Sybren A. Stüvel 2026-06-16 16:23:35 +02:00
parent efcc50166e
commit 6e052dab76

View file

@ -6798,6 +6798,22 @@ static wmOperatorStatus start_playback(bContext *C, int sync, int mode)
if (!scene) {
return OPERATOR_CANCELLED;
}
/* The SCE_LOOP_MODE_STOP_END_FRAME loop mode is special: playback should stop at the end frame,
* but when playback starts, in this mode, already at the end frame, it should actually start
* playback from the start frame. This way, you can repeatedly play back the scene, each time
* ending at the last frame. */
if (scene->playback_loop_mode == SCE_LOOP_MODE_STOP_END_FRAME) {
/* What are the actual start/end frames depends on whether playback is reversed or not. */
const bool is_playing_forward = mode > 0;
const int end_frame = is_playing_forward ? scene->playback_end() : scene->playback_start();
if (scene->r.cfra == end_frame) {
const int start_frame = is_playing_forward ? scene->playback_start() : scene->playback_end();
scene->r.cfra = start_frame;
scene->r.subframe = 0.0f;
}
}
ViewLayer *view_layer = is_sequencer ? BKE_view_layer_default_render(scene) :
CTX_data_view_layer(C);
Depsgraph *depsgraph = is_sequencer ? BKE_scene_ensure_depsgraph(bmain, scene, view_layer) :