Sfoglia il codice sorgente

Bugfix: Fixing a crash in animation evaluation when attempting to interpolate between identical keyframes

BearishSun 8 anni fa
parent
commit
ba95818f12
1 ha cambiato i file con 11 aggiunte e 1 eliminazioni
  1. 11 1
      Source/BansheeCore/Animation/BsAnimationCurve.cpp

+ 11 - 1
Source/BansheeCore/Animation/BsAnimationCurve.cpp

@@ -252,7 +252,17 @@ namespace bs
 		cache.cachedCurveEnd = rightKey.time;
 
 		float length = rightKey.time - leftKey.time;
-		assert(length > 0.0f);
+
+		// Handle the case where both keys are identical, or close enough to cause precision issues
+		if(length < 0.000001f)
+		{
+			cache.cachedCubicCoefficients[0] = getZero<T>();
+			cache.cachedCubicCoefficients[1] = getZero<T>();
+			cache.cachedCubicCoefficients[2] = getZero<T>();
+			cache.cachedCubicCoefficients[3] = leftKey.value;
+
+			return leftKey.value;
+		}
 
 		Math::cubicHermiteCoefficients(leftKey.value, rightKey.value, leftKey.outTangent, rightKey.inTangent, length,
 			cache.cachedCubicCoefficients);