diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs index 951bc35c29..d0073137e3 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs @@ -848,7 +848,7 @@ public struct Pair { keys.Add(new Keyframe(0, rotation, 0, 0)); - int listIndex = 1; + int listIndex = 0; float r = rotation; @@ -865,7 +865,7 @@ public struct Pair { animation.Apply(skeleton, 0, currentTime, true, null, 1f, MixBlend.Setup, MixDirection.In); skeleton.UpdateWorldTransform(); - int pIndex = listIndex - 1; + int pIndex = listIndex; Keyframe pk = keys[pIndex]; @@ -919,16 +919,16 @@ public struct Pair { xKeys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[1] + boneData.X, 0, 0)); yKeys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[2] + boneData.Y, 0, 0)); - int listIndex = 1; - int frameIndex = 1; + int listIndex = 0; + int frameIndex = 0; int f = TranslateTimeline.ENTRIES; float[] frames = timeline.Frames; skeleton.SetToSetupPose(); float lastTime = 0; while (currentTime < endTime) { - int pIndex = listIndex - 1; + int pIndex = listIndex; - float curveType = timeline.GetCurveType(frameIndex - 1); + float curveType = timeline.GetCurveType(frameIndex); if (curveType == 0) { //linear Keyframe px = xKeys[pIndex]; @@ -999,8 +999,8 @@ public struct Pair { timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); - px = xKeys[listIndex - 1]; - py = yKeys[listIndex - 1]; + px = xKeys[listIndex]; + py = yKeys[listIndex]; float xOut = (bone.X - px.value) / (currentTime - px.time); float yOut = (bone.Y - py.value) / (currentTime - py.time); @@ -1011,8 +1011,8 @@ public struct Pair { xKeys.Add(new Keyframe(currentTime, bone.X, xOut, 0)); yKeys.Add(new Keyframe(currentTime, bone.Y, yOut, 0)); - xKeys[listIndex - 1] = px; - yKeys[listIndex - 1] = py; + xKeys[listIndex] = px; + yKeys[listIndex] = py; listIndex++; lastTime = currentTime; @@ -1055,16 +1055,16 @@ public struct Pair { List keys = new List(); keys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[1] + boneDataOffset, 0, 0)); - int listIndex = 1; - int frameIndex = 1; + int listIndex = 0; + int frameIndex = 0; int f = TranslateXTimeline.ENTRIES; float[] frames = timeline.Frames; skeleton.SetToSetupPose(); float lastTime = 0; while (currentTime < endTime) { - int pIndex = listIndex - 1; + int pIndex = listIndex; - float curveType = timeline.GetCurveType(frameIndex - 1); + float curveType = timeline.GetCurveType(frameIndex); if (curveType == 0) { //linear Keyframe p = keys[pIndex]; @@ -1112,13 +1112,13 @@ public struct Pair { timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); - p = keys[listIndex - 1]; + p = keys[listIndex]; float boneOffset = isXTimeline ? bone.X : bone.Y; float valueOut = (boneOffset - p.value) / (currentTime - p.time); p.outTangent = valueOut; keys.Add(new Keyframe(currentTime, boneOffset, valueOut, 0)); - keys[listIndex - 1] = p; + keys[listIndex] = p; listIndex++; lastTime = currentTime; @@ -1155,15 +1155,15 @@ public struct Pair { xKeys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[1] * boneData.ScaleX, 0, 0)); yKeys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[2] * boneData.ScaleY, 0, 0)); - int listIndex = 1; - int frameIndex = 1; + int listIndex = 0; + int frameIndex = 0; int f = ScaleTimeline.ENTRIES; float[] frames = timeline.Frames; skeleton.SetToSetupPose(); float lastTime = 0; while (currentTime < endTime) { - int pIndex = listIndex - 1; - float curveType = timeline.GetCurveType(frameIndex - 1); + int pIndex = listIndex; + float curveType = timeline.GetCurveType(frameIndex); if (curveType == 0) { //linear Keyframe px = xKeys[pIndex]; @@ -1234,8 +1234,8 @@ public struct Pair { timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); - px = xKeys[listIndex - 1]; - py = yKeys[listIndex - 1]; + px = xKeys[listIndex]; + py = yKeys[listIndex]; float xOut = (bone.ScaleX - px.value) / (currentTime - px.time); float yOut = (bone.ScaleY - py.value) / (currentTime - py.time); @@ -1246,8 +1246,8 @@ public struct Pair { xKeys.Add(new Keyframe(currentTime, bone.ScaleX, xOut, 0)); yKeys.Add(new Keyframe(currentTime, bone.ScaleY, yOut, 0)); - xKeys[listIndex - 1] = px; - yKeys[listIndex - 1] = py; + xKeys[listIndex] = px; + yKeys[listIndex] = py; listIndex++; lastTime = currentTime; @@ -1286,15 +1286,15 @@ public struct Pair { List keys = new List(); keys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[1] * boneDataOffset, 0, 0)); - int listIndex = 1; - int frameIndex = 1; + int listIndex = 0; + int frameIndex = 0; int f = ScaleXTimeline.ENTRIES; float[] frames = timeline.Frames; skeleton.SetToSetupPose(); float lastTime = 0; while (currentTime < endTime) { - int pIndex = listIndex - 1; - float curveType = timeline.GetCurveType(frameIndex - 1); + int pIndex = listIndex; + float curveType = timeline.GetCurveType(frameIndex); if (curveType == 0) { //linear Keyframe p = keys[pIndex]; @@ -1340,14 +1340,14 @@ public struct Pair { timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); - p = keys[listIndex - 1]; + p = keys[listIndex]; float boneScale = isXTimeline ? bone.ScaleX : bone.ScaleY; float valueOut = (boneScale - p.value) / (currentTime - p.time); p.outTangent = valueOut; keys.Add(new Keyframe(currentTime, boneScale, valueOut, 0)); - keys[listIndex - 1] = p; + keys[listIndex] = p; listIndex++; lastTime = currentTime; @@ -1382,16 +1382,16 @@ public struct Pair { keys.Add(new Keyframe(timeline.Frames[0], rotation, 0, 0)); - int listIndex = 1; - int frameIndex = 1; + int listIndex = 0; + int frameIndex = 0; int f = 2; float[] frames = timeline.Frames; skeleton.SetToSetupPose(); float lastTime = 0; float angle = rotation; while (currentTime < endTime) { - int pIndex = listIndex - 1; - float curveType = timeline.GetCurveType(frameIndex - 1); + int pIndex = listIndex; + float curveType = timeline.GetCurveType(frameIndex); if (curveType == 0) { //linear @@ -1464,7 +1464,7 @@ public struct Pair { timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); skeleton.UpdateWorldTransform(); - pk = keys[listIndex - 1]; + pk = keys[listIndex]; rotation = bone.Rotation; angle += Mathf.DeltaAngle(angle, rotation); @@ -1476,7 +1476,7 @@ public struct Pair { keys.Add(new Keyframe(currentTime, r, rOut, 0)); - keys[listIndex - 1] = pk; + keys[listIndex] = pk; listIndex++; lastTime = currentTime; @@ -1582,10 +1582,7 @@ public struct Pair { } } - float currentTime = timeline.Frames[0]; - float endTime = frames[frames.Length - 1]; - int f = 0; - while (currentTime < endTime) { + for (int f = 0, frameCount = frames.Length; f < frameCount; ++f) { float time = frames[f]; int frameIndex = Search(frames, time); @@ -1602,9 +1599,6 @@ public struct Pair { } } } - - currentTime = time; - f += 1; } foreach (KeyValuePair pair in curveTable) {