Browse Source

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
Zer..om 12 years ago
parent
commit
4d16f05f23
1 changed files with 7 additions and 3 deletions
  1. 7 3
      engine/src/core/com/jme3/animation/AnimChannel.java

+ 7 - 3
engine/src/core/com/jme3/animation/AnimChannel.java

@@ -60,6 +60,7 @@ public final class AnimChannel {
     private float speed;
     private float speed;
     private float timeBlendFrom;
     private float timeBlendFrom;
     private float speedBlendFrom;
     private float speedBlendFrom;
+    private boolean notified=false;
 
 
     private LoopMode loopMode, loopModeBlendFrom;
     private LoopMode loopMode, loopModeBlendFrom;
     
     
@@ -262,6 +263,7 @@ public final class AnimChannel {
         time = 0;
         time = 0;
         speed = 1f;
         speed = 1f;
         loopMode = LoopMode.Loop;
         loopMode = LoopMode.Loop;
+        notified = false;
     }
     }
 
 
     /**
     /**
@@ -360,6 +362,7 @@ public final class AnimChannel {
             }
             }
         }
         }
         animation = null;
         animation = null;
+        notified = false;
     }
     }
 
 
     void update(float tpf, TempVars vars) {
     void update(float tpf, TempVars vars) {
@@ -392,10 +395,11 @@ public final class AnimChannel {
         time += tpf * speed;
         time += tpf * speed;
 
 
         if (animation.getLength() > 0){
         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());
                 control.notifyAnimCycleDone(this, animation.getName());
+                if (loopMode == LoopMode.DontLoop) {
+                    notified = true;
+                }
             } 
             } 
         }
         }