diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2016-06-19 12:30:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-19 12:30:22 +0200 |
commit | 3520902194357d77f729ed608bb4c1ea68fe495f (patch) | |
tree | b35be047b50e2609671112ed5a06f4728f069bd0 /scene/animation | |
parent | 400febf58517631651ffdb6707e483db3271f04c (diff) | |
parent | 8884b8f51963553dd1ecc0bc4accf64deb4f645f (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.cpp | 14 |
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; |