Selaa lähdekoodia

Fixes crash when playing back a "pose" AnimationClip caused by a mod (%) of 0.
Now check to see if the duration is 0 before calculating the current time within the AnimationClip.
A "pose" AnimationClip is a clip that has a duration of 0 because it starts and ends on the same frame.

Kieran Cunney 14 vuotta sitten
vanhempi
sitoutus
2894f78989
1 muutettua tiedostoa jossa 16 lisäystä ja 5 poistoa
  1. 16 5
      gameplay/src/AnimationClip.cpp

+ 16 - 5
gameplay/src/AnimationClip.cpp

@@ -271,9 +271,17 @@ bool AnimationClip::update(unsigned long elapsedTime, std::list<AnimationTarget*
         resetClipStateBit(CLIP_IS_STARTED_BIT);
         if (_speed >= 0.0f)
         {
-            currentTime = _activeDuration % _duration; // Get's the fractional part of the final repeat.
-            if (currentTime == 0L)
-                currentTime = _duration;
+            // If _duration == 0, we have a "pose". Just set currentTime to 0.
+            if (_duration == 0)
+            {
+                currentTime = 0L;
+            }
+            else
+            {
+                currentTime = _activeDuration % _duration; // Get's the fractional part of the final repeat.
+                if (currentTime == 0L)
+                    currentTime = _duration;
+            }
         }
         else
         {
@@ -282,8 +290,11 @@ bool AnimationClip::update(unsigned long elapsedTime, std::list<AnimationTarget*
     }
     else
     {
-        // Gets portion/fraction of the repeat.
-        currentTime = _elapsedTime % _duration;
+        // If _duration == 0, we have a "pose". Just set currentTime to 0.
+        if (_duration == 0)
+            currentTime = 0L;
+        else // Gets portion/fraction of the repeat.
+            currentTime = _elapsedTime % _duration;
     }
 
     // Notify any listeners of Animation events.