Преглед изворни кода

Fixes bug in Animation framework when AnimationController is shutting down and there is some code to trigger an animation to play on an animation end event. It was causing the animation code to never exit.

Kieran Cunney пре 14 година
родитељ
комит
3927011582
3 измењених фајлова са 15 додато и 14 уклоњено
  1. 10 11
      gameplay/src/AnimationClip.cpp
  2. 3 2
      gameplay/src/AnimationController.cpp
  3. 2 1
      gameplay/src/AnimationController.h

+ 10 - 11
gameplay/src/AnimationClip.cpp

@@ -441,6 +441,16 @@ bool AnimationClip::update(unsigned long elapsedTime)
     if (!_isPlaying)
     if (!_isPlaying)
     {
     {
         onEnd();
         onEnd();
+        // Notify end listeners if any.
+        if (_endListeners)
+        {
+            std::vector<Listener*>::iterator listener = _endListeners->begin();
+            while (listener != _endListeners->end())
+            {
+                (*listener)->animationEvent(this, Listener::END);
+                listener++;
+            }
+        }
     }
     }
 
 
     return !_isPlaying;
     return !_isPlaying;
@@ -494,17 +504,6 @@ void AnimationClip::onEnd()
 
 
     _blendWeight = 1.0f;
     _blendWeight = 1.0f;
     _timeStarted = 0;
     _timeStarted = 0;
-
-    // Notify end listeners if any.
-    if (_endListeners)
-    {
-        std::vector<Listener*>::iterator listener = _endListeners->begin();
-        while (listener != _endListeners->end())
-        {
-            (*listener)->animationEvent(this, Listener::END);
-            listener++;
-        }
-    }
 }
 }
 
 
 }
 }

+ 3 - 2
gameplay/src/AnimationController.cpp

@@ -7,7 +7,7 @@ namespace gameplay
 {
 {
 
 
 AnimationController::AnimationController()
 AnimationController::AnimationController()
-    : _state(IDLE), _animations(NULL)
+    : _state(STOPPED), _animations(NULL)
 {
 {
 }
 }
 
 
@@ -112,6 +112,7 @@ void AnimationController::stopAllAnimations()
         clip->_isPlaying = false;
         clip->_isPlaying = false;
         clip->onEnd();
         clip->onEnd();
         SAFE_RELEASE(clip);
         SAFE_RELEASE(clip);
+        clipIter++;
     }
     }
     _runningClips.clear();
     _runningClips.clear();
 
 
@@ -269,7 +270,7 @@ void AnimationController::initialize()
 void AnimationController::finalize()
 void AnimationController::finalize()
 {
 {
     stopAllAnimations();
     stopAllAnimations();
-    _state = PAUSED;
+    _state = STOPPED;
 }
 }
 
 
 void AnimationController::resume()
 void AnimationController::resume()

+ 2 - 1
gameplay/src/AnimationController.h

@@ -117,7 +117,8 @@ private:
     {
     {
         RUNNING,
         RUNNING,
         IDLE,
         IDLE,
-        PAUSED
+        PAUSED,
+        STOPPED
     };
     };
 
 
     /**
     /**