浏览代码

Merge branch '4.1' of https://github.com/esotericsoftware/spine-runtimes into 4.1

Mario Zechner 2 年之前
父节点
当前提交
6ec6c4c21c
共有 1 个文件被更改,包括 37 次插入43 次删除
  1. 37 43
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs

+ 37 - 43
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Windows/SkeletonBaker.cs

@@ -848,7 +848,7 @@ namespace Spine.Unity.Editor {
 
 			keys.Add(new Keyframe(0, rotation, 0, 0));
 
-			int listIndex = 1;
+			int listIndex = 0;
 
 			float r = rotation;
 
@@ -865,7 +865,7 @@ namespace Spine.Unity.Editor {
 				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 @@ namespace Spine.Unity.Editor {
 			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 @@ namespace Spine.Unity.Editor {
 
 						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 @@ namespace Spine.Unity.Editor {
 						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 @@ namespace Spine.Unity.Editor {
 			List<Keyframe> keys = new List<Keyframe>();
 			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 @@ namespace Spine.Unity.Editor {
 
 						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 @@ namespace Spine.Unity.Editor {
 			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 @@ namespace Spine.Unity.Editor {
 
 						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 @@ namespace Spine.Unity.Editor {
 						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 @@ namespace Spine.Unity.Editor {
 			List<Keyframe> keys = new List<Keyframe>();
 			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 @@ namespace Spine.Unity.Editor {
 
 						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 @@ namespace Spine.Unity.Editor {
 
 			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 @@ namespace Spine.Unity.Editor {
 
 						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 @@ namespace Spine.Unity.Editor {
 
 						keys.Add(new Keyframe(currentTime, r, rOut, 0));
 
-						keys[listIndex - 1] = pk;
+						keys[listIndex] = pk;
 
 						listIndex++;
 						lastTime = currentTime;
@@ -1582,10 +1582,7 @@ namespace Spine.Unity.Editor {
 				}
 			}
 
-			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 @@ namespace Spine.Unity.Editor {
 						}
 					}
 				}
-
-				currentTime = time;
-				f += 1;
 			}
 
 			foreach (KeyValuePair<string, AnimationCurve> pair in curveTable) {