Skip to content

Commit

Permalink
Merge pull request #90960 from TokageItLab/fix-animation-playback-tra…
Browse files Browse the repository at this point in the history
…ck-seek

Make seeking animation playback track consider internal seeking
  • Loading branch information
akien-mga committed May 1, 2024
2 parents de00cfb + b346e2a commit f89de7a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scene/animation/animation_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
}
if (seeked) {
// Seek.
int idx = a->track_find_key(i, time, is_external_seeking ? Animation::FIND_MODE_NEAREST : Animation::FIND_MODE_EXACT, true);
int idx = a->track_find_key(i, time, Animation::FIND_MODE_NEAREST, true);
if (idx < 0) {
continue;
}
Expand All @@ -1630,6 +1630,9 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
double at_anim_pos = 0.0;
switch (anim->get_loop_mode()) {
case Animation::LOOP_NONE: {
if (!is_external_seeking && ((!backward && time >= pos + (double)anim->get_length()) || (backward && time <= pos))) {
continue; // Do nothing if current time is outside of length when started.
}
at_anim_pos = MIN((double)anim->get_length(), time - pos); // Seek to end.
} break;
case Animation::LOOP_LINEAR: {
Expand All @@ -1641,7 +1644,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
default:
break;
}
if (player2->is_playing()) {
if (player2->is_playing() || !is_external_seeking) {
player2->seek(at_anim_pos, false, p_update_only);
player2->play(anim_name);
t->playing = true;
Expand Down

0 comments on commit f89de7a

Please sign in to comment.