Explorar el Código

Add closed spline end point's tangent calculate.[ci skip]

aster2013 hace 11 años
padre
commit
21a14f12e5
Se han modificado 1 ficheros con 5 adiciones y 2 borrados
  1. 5 2
      Source/Engine/Scene/AttributeAnimation.cpp

+ 5 - 2
Source/Engine/Scene/AttributeAnimation.cpp

@@ -407,8 +407,11 @@ void AttributeAnimation::UpdateSplineTangents()
     for (unsigned i = 1; i < size - 1; ++i)
         splineTangents_[i] = SubstractAndMultiply(keyFrames_[i + 1].value_, keyFrames_[i - 1].value_, splineTension_);
 
-    // Make end point's tangent zero
-    splineTangents_[0] = splineTangents_[size - 1] = SubstractAndMultiply(keyFrames_[0].value_, keyFrames_[0].value_, splineTension_);
+    // If spline is not closed, make end point's tangent zero
+    if (keyFrames_[0].value_ != keyFrames_[size - 1].value_)
+        splineTangents_[0] = splineTangents_[size - 1] = SubstractAndMultiply(keyFrames_[0].value_, keyFrames_[0].value_, splineTension_);
+    else 
+        splineTangents_[0] = splineTangents_[size - 1] = SubstractAndMultiply(keyFrames_[1].value_, keyFrames_[size - 2].value_, splineTension_);
 
     splineTangentsDirty_ = false;
 }