Skip to content

Commit

Permalink
Merge pull request #89794 from TokageItLab/animationplayback-seek
Browse files Browse the repository at this point in the history
Fix AnimationPlaybackTrack seeking behavior overall
  • Loading branch information
akien-mga committed Mar 24, 2024
2 parents 3895639 + c1741fe commit f79896f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scene/animation/animation_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
}
} break;
case Animation::TYPE_ANIMATION: {
if (p_update_only || Math::is_zero_approx(blend)) {
if (Math::is_zero_approx(blend)) {
continue;
}
TrackCacheAnimation *t = static_cast<TrackCacheAnimation *>(track);
Expand All @@ -1623,25 +1623,25 @@ 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: {
at_anim_pos = MAX((double)anim->get_length(), time - pos); //seek to end
at_anim_pos = MIN((double)anim->get_length(), time - pos); // Seek to end.
} break;
case Animation::LOOP_LINEAR: {
at_anim_pos = Math::fposmod(time - pos, (double)anim->get_length()); //seek to loop
at_anim_pos = Math::fposmod(time - pos, (double)anim->get_length()); // Seek to loop.
} break;
case Animation::LOOP_PINGPONG: {
at_anim_pos = Math::pingpong(time - pos, (double)a->get_length());
} break;
default:
break;
}
if (player2->is_playing() || seeked) {
player2->seek(at_anim_pos);
if (player2->is_playing()) {
player2->seek(at_anim_pos, false, p_update_only);
player2->play(anim_name);
t->playing = true;
playing_caches.insert(t);
} else {
player2->set_assigned_animation(anim_name);
player2->seek(at_anim_pos, true);
player2->seek(at_anim_pos, true, p_update_only);
}
} else {
// Find stuff to play.
Expand Down

0 comments on commit f79896f

Please sign in to comment.