summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-11-14 12:29:02 +0100
committerGitHub <noreply@github.com>2017-11-14 12:29:02 +0100
commitbd775aa0bd25eaa331952c8cdaf0cabb66cbc213 (patch)
treedafd5d0eb940436803cdb190742b67c0d6f26cef
parent468567438974ccfea11bcd5525cdeece3e1e546a (diff)
parente477fa2bd2d6cca37540e1c0791288f52bbb50b2 (diff)
Merge pull request #12898 from RandomShaper/improve-anim-loop
Change AnimationPlayer looping logic
-rw-r--r--scene/animation/animation_player.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 80b7748078..6be3ff88d9 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -545,7 +545,14 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f
} else {
- next_pos = Math::fposmod(next_pos, len);
+ float looped_next_pos = Math::fposmod(next_pos, len);
+ if (looped_next_pos == 0 && next_pos != 0) {
+ // Loop multiples of the length to it, rather than 0
+ // so state at time=length is previewable in the editor
+ next_pos = len;
+ } else {
+ next_pos = looped_next_pos;
+ }
}
cd.pos = next_pos;