From 4d16f05f23f81afa9d99dec2c4a1fc0d21e38717 Mon Sep 17 00:00:00 2001 From: "Zer..om" Date: Tue, 2 Apr 2013 13:35:16 +0000 Subject: [PATCH] Fixed a bug in AnimChannel which would cause it to keep repeatedly issuing Animation Complete callbacks every frame once the animation did complete rather than issueing one once each time the animation completed. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10509 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/animation/AnimChannel.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/engine/src/core/com/jme3/animation/AnimChannel.java b/engine/src/core/com/jme3/animation/AnimChannel.java index 83638038c..00f2d1e49 100644 --- a/engine/src/core/com/jme3/animation/AnimChannel.java +++ b/engine/src/core/com/jme3/animation/AnimChannel.java @@ -60,6 +60,7 @@ public final class AnimChannel { private float speed; private float timeBlendFrom; private float speedBlendFrom; + private boolean notified=false; private LoopMode loopMode, loopModeBlendFrom; @@ -262,6 +263,7 @@ public final class AnimChannel { time = 0; speed = 1f; loopMode = LoopMode.Loop; + notified = false; } /** @@ -360,6 +362,7 @@ public final class AnimChannel { } } animation = null; + notified = false; } void update(float tpf, TempVars vars) { @@ -392,10 +395,11 @@ public final class AnimChannel { time += tpf * speed; if (animation.getLength() > 0){ - if (time >= animation.getLength()) { - control.notifyAnimCycleDone(this, animation.getName()); - } else if (time < 0) { + if (!notified && (time >= animation.getLength() || time < 0)) { control.notifyAnimCycleDone(this, animation.getName()); + if (loopMode == LoopMode.DontLoop) { + notified = true; + } } }