summaryrefslogtreecommitdiff
path: root/scene/animation
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2016-09-12 04:33:40 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2016-09-12 04:33:40 +0200
commit83df74a17d4de3c32a752a56ad01e3f962749021 (patch)
tree47d3123fc89971420d94b504ee3892a9e3ddf3c5 /scene/animation
parent6f7b2d277fc068264b72b0a39d464da03807c628 (diff)
Fix/improve AnimationPlayer blending logic
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/animation_player.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 30af9b0094..37cd30b309 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -583,35 +583,26 @@ void AnimationPlayer::_animation_process2(float p_delta) {
Playback &c=playback;
- float prev_blend=1.0;
accum_pass++;
- int pop_count=1;
- int pop=0; // if >0, then amount of elements to pop from the back
+ _animation_process_data(c.current,p_delta,1.0f);
-
- for (List<Blend>::Element *E=c.blend.back();E;E=E->prev(),pop_count++) {
+ List<Blend>::Element *prev = NULL;
+ for (List<Blend>::Element *E=c.blend.back();E;E=prev) {
Blend& b=E->get();
- _animation_process_data(b.data,p_delta,prev_blend);
-
- prev_blend=1.0-b.blend_left/b.blend_time;
+ float blend=b.blend_left/b.blend_time;
+ _animation_process_data(b.data,p_delta,blend);
b.blend_left-=Math::absf(speed_scale*p_delta);
+ prev = E->prev();
if (b.blend_left<0) {
- pop=pop_count;
+ c.blend.erase(E);
}
}
-
- while(pop--) {
-
- c.blend.pop_back();
- }
-
-
- _animation_process_data(c.current,p_delta,prev_blend);
+
}