Skip to content

Commit

Permalink
#10 first part of bezier curves solved (first keyframe show correct r…
Browse files Browse the repository at this point in the history
…esult)
  • Loading branch information
nicloay committed Feb 11, 2014
1 parent 02d59f5 commit 505e693
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Assets/UnitySpineImporter/Scripts/Editor/Util/SpineUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,13 @@ public static void setCustomTangents(AnimationCurve curve, int i, int nextI, Jso
object nextKeyframeBoxed = curve[nextI];


if (!KeyframeUtil.isKeyBroken(thisKeyframeBoxed)){
//if (!KeyframeUtil.isKeyBroken(thisKeyframeBoxed)){
KeyframeUtil.SetKeyBroken(thisKeyframeBoxed, true);
}
//}
KeyframeUtil.SetKeyTangentMode(thisKeyframeBoxed, 1, TangentMode.Editable);
if (KeyframeUtil.isKeyBroken(nextKeyframeBoxed)){
//if (KeyframeUtil.isKeyBroken(nextKeyframeBoxed)){
KeyframeUtil.SetKeyBroken(nextKeyframeBoxed, true);
}
//}
KeyframeUtil.SetKeyTangentMode(nextKeyframeBoxed, 0, TangentMode.Editable);

Keyframe thisKeyframe = (Keyframe)thisKeyframeBoxed;
Expand All @@ -604,17 +604,18 @@ public static void setCustomTangents(AnimationCurve curve, int i, int nextI, Jso
bool ok = true;
float startTime = thisKeyframe.time;
float lastTime = nextKeyframe.time;

float startValue = thisKeyframe.value;

for (float j=0; j < 25f; j++) {
float timeInS = j/25;
Vector2 t1 = getBezierPoint(p0, cOrig1, cOrig2, p3, timeInS);
Vector2 t2 = getBezierPoint(p0, c1, c2orig, p3, timeInS);
t1 *= diffValue;
t2 *= diffValue;
float curveValue = curve.Evaluate(startTime + diffTime / 25.0f * j);
if (t1.y!=t2.y || t1.y!=curveValue || t2.y!=curveValue){
Debug.LogError("time = "+ timeInS + " t1 = "+t1.y+" t2 = "+t2.y+" curve"+curveValue);
float curveValue = curve.Evaluate(startTime + diffTime / 25.0f * j) - startValue;

if (Mathf.Abs((Mathf.Abs(t1.y) - Mathf.Abs(t2.y))) > 0.000001f || Mathf.Abs(Mathf.Abs(t2.y) - Mathf.Abs(curveValue)) > 0.000001f){
Debug.LogError("time = "+ timeInS + " t1 = "+t1.y.ToString("N8")+" t2 = "+t2.y.ToString("N8")+" curve="+curveValue.ToString("N8"));
ok = false;
}
}
Expand Down

0 comments on commit 505e693

Please sign in to comment.