Răsfoiți Sursa

Fixes a bug in createChannel if keyCount=1

In this case the setPoint got keyValues+pointOffset as an argument which pointed to a wrong memory-address
Chris E 12 ani în urmă
părinte
comite
f4b6d37ef9
1 a modificat fișierele cu 5 adăugiri și 3 ștergeri
  1. 5 3
      gameplay/src/Animation.cpp

+ 5 - 3
gameplay/src/Animation.cpp

@@ -341,9 +341,11 @@ Animation::Channel* Animation::createChannel(AnimationTarget* target, int proper
         curve->setPoint(i, normalizedKeyTimes[i], (keyValues + pointOffset), (Curve::InterpolationType) type);
         pointOffset += propertyComponentCount;
     }
-    i = keyCount - 1;
-    normalizedKeyTimes[i] = 1.0f;
-    curve->setPoint(i, normalizedKeyTimes[i], keyValues + pointOffset, (Curve::InterpolationType) type);
+    if (keyCount > 1) {
+        i = keyCount - 1;
+        normalizedKeyTimes[i] = 1.0f;
+        curve->setPoint(i, normalizedKeyTimes[i], keyValues + pointOffset, (Curve::InterpolationType) type);
+    }
 
     SAFE_DELETE_ARRAY(normalizedKeyTimes);