diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-08-06 12:31:02 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-08-06 12:31:02 +0200 |
commit | cd76e36132f82fd6c5afcf8199ff0201bdcabdb0 (patch) | |
tree | cf5d21ed565537e82b3890391da96872bae5a894 /scene/animation/animation_player.cpp | |
parent | 2b65ff9249ddacfabbd1e20f37fc6a0405e279b2 (diff) | |
parent | 8323c3891d87782c40db5b65be8a4ba0f27d7d94 (diff) | |
download | redot-engine-cd76e36132f82fd6c5afcf8199ff0201bdcabdb0.tar.gz |
Merge pull request #95023 from TokageItLab/snap-anim-end
Snap current position to the edge on animation finished
Diffstat (limited to 'scene/animation/animation_player.cpp')
-rw-r--r-- | scene/animation/animation_player.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 19229f405a..24b777e2eb 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -204,19 +204,20 @@ void AnimationPlayer::_process_playback_data(PlaybackData &cd, double p_delta, f } double prev_pos = cd.pos; // The animation may be changed during process, so it is safer that the state is changed before process. - cd.pos = next_pos; // End detection. if (p_is_current) { if (cd.from->animation->get_loop_mode() == Animation::LOOP_NONE) { if (!backwards && Animation::is_less_or_equal_approx(prev_pos, len) && Math::is_equal_approx(next_pos, len)) { // Playback finished. + next_pos = len; // Snap to the edge. end_reached = true; end_notify = Animation::is_less_approx(prev_pos, len); // Notify only if not already at the end. p_blend = 1.0; } if (backwards && Animation::is_greater_or_equal_approx(prev_pos, 0) && Math::is_equal_approx(next_pos, 0)) { // Playback finished. + next_pos = 0; // Snap to the edge. end_reached = true; end_notify = Animation::is_greater_approx(prev_pos, 0); // Notify only if not already at the beginning. p_blend = 1.0; @@ -224,6 +225,8 @@ void AnimationPlayer::_process_playback_data(PlaybackData &cd, double p_delta, f } } + cd.pos = next_pos; + PlaybackInfo pi; if (p_started) { pi.time = prev_pos; |