summaryrefslogtreecommitdiff
path: root/scene/animation
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2016-06-19 12:30:22 +0200
committerGitHub <noreply@github.com>2016-06-19 12:30:22 +0200
commit3520902194357d77f729ed608bb4c1ea68fe495f (patch)
treeb35be047b50e2609671112ed5a06f4728f069bd0 /scene/animation
parent400febf58517631651ffdb6707e483db3271f04c (diff)
parent8884b8f51963553dd1ecc0bc4accf64deb4f645f (diff)
Merge pull request #4724 from Cybolic/optional-loop-interpolation
Added toggle for loop interpolation based on adolson's code
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/animation_player.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 30af9b0094..0ff6931dcd 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -540,6 +540,7 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd,float p_delta,flo
float len=cd.from->animation->get_length();
bool loop=cd.from->animation->has_loop();
+ bool loop_interpolation=cd.from->animation->has_loop_interpolation();
if (!loop) {
@@ -565,10 +566,21 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd,float p_delta,flo
}
- } else {
+ } else if (loop_interpolation) {
next_pos=Math::fposmod(next_pos,len);
+ } else {
+
+ if (next_pos<0 or next_pos>len) {
+ if (!backwards)
+ next_pos=0;
+ else if (backwards)
+ next_pos=len;
+ }
+ // fix delta - not sure if needed here
+ delta=next_pos-cd.pos;
+
}
cd.pos=next_pos;