Selaa lähdekoodia

Minor fix animation bug.[ci skip]

Aster Jian 11 vuotta sitten
vanhempi
sitoutus
0fef66f780
1 muutettua tiedostoa jossa 13 lisäystä ja 10 poistoa
  1. 13 10
      Source/Engine/Scene/AttributeAnimationInstance.cpp

+ 13 - 10
Source/Engine/Scene/AttributeAnimationInstance.cpp

@@ -72,18 +72,21 @@ bool AttributeAnimationInstance::Update(float timeStep)
     bool finished = false;
     bool finished = false;
     float scaledTime = CalculateScaledTime(currentTime_, finished);
     float scaledTime = CalculateScaledTime(currentTime_, finished);
 
 
-    for (unsigned i = 1; i < keyFrames.Size(); ++i)
+    unsigned index = 1;
+    for (; index < keyFrames.Size(); ++index)
     {
     {
-        const AttributeKeyFrame& currKeyFrame = keyFrames[i];
-        if (scaledTime <= currKeyFrame.time_)
-        {
-            const AttributeKeyFrame& prevKeyFrame = keyFrames[i - 1];
-            if (!attributeAnimation_->IsInterpolatable())
-                animatable_->OnSetAttribute(attributeInfo_, prevKeyFrame.value_);
-            else
-                animatable_->OnSetAttribute(attributeInfo_, Interpolation(prevKeyFrame, currKeyFrame, scaledTime));
+        const AttributeKeyFrame& currKeyFrame = keyFrames[index];
+        if (scaledTime < currKeyFrame.time_)
             break;
             break;
-        }
+    }
+
+    const AttributeKeyFrame& prevKeyFrame = keyFrames[index - 1];
+    if (index >= keyFrames.Size() || !attributeAnimation_->IsInterpolatable())
+        animatable_->OnSetAttribute(attributeInfo_, prevKeyFrame.value_);
+    else
+    {
+        const AttributeKeyFrame& currKeyFrame = keyFrames[index];
+        animatable_->OnSetAttribute(attributeInfo_, Interpolation(prevKeyFrame, currKeyFrame, scaledTime));
     }
     }
 
 
     if (attributeAnimation_->HasEventFrames())
     if (attributeAnimation_->HasEventFrames())