浏览代码

[ts] Fixed AnimationState not respecting MixBlend.first for rotate timelines. See #1274.

badlogic 6 年之前
父节点
当前提交
19e5edc94b

+ 23 - 15
spine-ts/build/spine-all.js

@@ -1532,25 +1532,33 @@ var spine;
 			var rotateTimeline = timeline;
 			var frames = rotateTimeline.frames;
 			var bone = skeleton.bones[rotateTimeline.boneIndex];
+			var r1 = 0, r2 = 0;
 			if (time < frames[0]) {
-				if (blend == spine.MixBlend.setup)
-					bone.rotation = bone.data.rotation;
-				return;
+				switch (blend) {
+					case spine.MixBlend.setup:
+						bone.rotation = bone.data.rotation;
+					default:
+						return;
+					case spine.MixBlend.first:
+						r1 = bone.rotation;
+						r2 = bone.data.rotation;
+				}
 			}
-			var r2 = 0;
-			if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
-				r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
 			else {
-				var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
-				var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
-				var frameTime = frames[frame];
-				var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
-				r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
-				r2 = prevRotation + r2 * percent + bone.data.rotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
+				if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
+					r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
+				else {
+					var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
+					var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
+					var frameTime = frames[frame];
+					var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
+					r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+					r2 = prevRotation + r2 * percent + bone.data.rotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				}
 			}
-			var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
 			var total = 0, diff = r2 - r1;
 			diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
 			if (diff == 0) {

文件差异内容过多而无法显示
+ 0 - 0
spine-ts/build/spine-all.js.map


+ 23 - 15
spine-ts/build/spine-canvas.js

@@ -1532,25 +1532,33 @@ var spine;
 			var rotateTimeline = timeline;
 			var frames = rotateTimeline.frames;
 			var bone = skeleton.bones[rotateTimeline.boneIndex];
+			var r1 = 0, r2 = 0;
 			if (time < frames[0]) {
-				if (blend == spine.MixBlend.setup)
-					bone.rotation = bone.data.rotation;
-				return;
+				switch (blend) {
+					case spine.MixBlend.setup:
+						bone.rotation = bone.data.rotation;
+					default:
+						return;
+					case spine.MixBlend.first:
+						r1 = bone.rotation;
+						r2 = bone.data.rotation;
+				}
 			}
-			var r2 = 0;
-			if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
-				r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
 			else {
-				var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
-				var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
-				var frameTime = frames[frame];
-				var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
-				r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
-				r2 = prevRotation + r2 * percent + bone.data.rotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
+				if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
+					r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
+				else {
+					var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
+					var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
+					var frameTime = frames[frame];
+					var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
+					r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+					r2 = prevRotation + r2 * percent + bone.data.rotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				}
 			}
-			var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
 			var total = 0, diff = r2 - r1;
 			diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
 			if (diff == 0) {

文件差异内容过多而无法显示
+ 0 - 0
spine-ts/build/spine-canvas.js.map


+ 23 - 15
spine-ts/build/spine-core.js

@@ -1532,25 +1532,33 @@ var spine;
 			var rotateTimeline = timeline;
 			var frames = rotateTimeline.frames;
 			var bone = skeleton.bones[rotateTimeline.boneIndex];
+			var r1 = 0, r2 = 0;
 			if (time < frames[0]) {
-				if (blend == spine.MixBlend.setup)
-					bone.rotation = bone.data.rotation;
-				return;
+				switch (blend) {
+					case spine.MixBlend.setup:
+						bone.rotation = bone.data.rotation;
+					default:
+						return;
+					case spine.MixBlend.first:
+						r1 = bone.rotation;
+						r2 = bone.data.rotation;
+				}
 			}
-			var r2 = 0;
-			if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
-				r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
 			else {
-				var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
-				var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
-				var frameTime = frames[frame];
-				var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
-				r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
-				r2 = prevRotation + r2 * percent + bone.data.rotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
+				if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
+					r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
+				else {
+					var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
+					var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
+					var frameTime = frames[frame];
+					var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
+					r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+					r2 = prevRotation + r2 * percent + bone.data.rotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				}
 			}
-			var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
 			var total = 0, diff = r2 - r1;
 			diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
 			if (diff == 0) {

文件差异内容过多而无法显示
+ 0 - 0
spine-ts/build/spine-core.js.map


+ 23 - 15
spine-ts/build/spine-player.js

@@ -1532,25 +1532,33 @@ var spine;
 			var rotateTimeline = timeline;
 			var frames = rotateTimeline.frames;
 			var bone = skeleton.bones[rotateTimeline.boneIndex];
+			var r1 = 0, r2 = 0;
 			if (time < frames[0]) {
-				if (blend == spine.MixBlend.setup)
-					bone.rotation = bone.data.rotation;
-				return;
+				switch (blend) {
+					case spine.MixBlend.setup:
+						bone.rotation = bone.data.rotation;
+					default:
+						return;
+					case spine.MixBlend.first:
+						r1 = bone.rotation;
+						r2 = bone.data.rotation;
+				}
 			}
-			var r2 = 0;
-			if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
-				r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
 			else {
-				var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
-				var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
-				var frameTime = frames[frame];
-				var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
-				r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
-				r2 = prevRotation + r2 * percent + bone.data.rotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
+				if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
+					r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
+				else {
+					var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
+					var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
+					var frameTime = frames[frame];
+					var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
+					r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+					r2 = prevRotation + r2 * percent + bone.data.rotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				}
 			}
-			var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
 			var total = 0, diff = r2 - r1;
 			diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
 			if (diff == 0) {

文件差异内容过多而无法显示
+ 0 - 0
spine-ts/build/spine-player.js.map


+ 23 - 15
spine-ts/build/spine-threejs.js

@@ -1532,25 +1532,33 @@ var spine;
 			var rotateTimeline = timeline;
 			var frames = rotateTimeline.frames;
 			var bone = skeleton.bones[rotateTimeline.boneIndex];
+			var r1 = 0, r2 = 0;
 			if (time < frames[0]) {
-				if (blend == spine.MixBlend.setup)
-					bone.rotation = bone.data.rotation;
-				return;
+				switch (blend) {
+					case spine.MixBlend.setup:
+						bone.rotation = bone.data.rotation;
+					default:
+						return;
+					case spine.MixBlend.first:
+						r1 = bone.rotation;
+						r2 = bone.data.rotation;
+				}
 			}
-			var r2 = 0;
-			if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
-				r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
 			else {
-				var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
-				var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
-				var frameTime = frames[frame];
-				var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
-				r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
-				r2 = prevRotation + r2 * percent + bone.data.rotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
+				if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
+					r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
+				else {
+					var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
+					var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
+					var frameTime = frames[frame];
+					var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
+					r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+					r2 = prevRotation + r2 * percent + bone.data.rotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				}
 			}
-			var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
 			var total = 0, diff = r2 - r1;
 			diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
 			if (diff == 0) {

文件差异内容过多而无法显示
+ 0 - 0
spine-ts/build/spine-threejs.js.map


+ 23 - 15
spine-ts/build/spine-webgl.js

@@ -1532,25 +1532,33 @@ var spine;
 			var rotateTimeline = timeline;
 			var frames = rotateTimeline.frames;
 			var bone = skeleton.bones[rotateTimeline.boneIndex];
+			var r1 = 0, r2 = 0;
 			if (time < frames[0]) {
-				if (blend == spine.MixBlend.setup)
-					bone.rotation = bone.data.rotation;
-				return;
+				switch (blend) {
+					case spine.MixBlend.setup:
+						bone.rotation = bone.data.rotation;
+					default:
+						return;
+					case spine.MixBlend.first:
+						r1 = bone.rotation;
+						r2 = bone.data.rotation;
+				}
 			}
-			var r2 = 0;
-			if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
-				r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
 			else {
-				var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
-				var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
-				var frameTime = frames[frame];
-				var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
-				r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
-				r2 = prevRotation + r2 * percent + bone.data.rotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
+				if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
+					r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
+				else {
+					var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
+					var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
+					var frameTime = frames[frame];
+					var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
+					r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+					r2 = prevRotation + r2 * percent + bone.data.rotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				}
 			}
-			var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
 			var total = 0, diff = r2 - r1;
 			diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
 			if (diff == 0) {

文件差异内容过多而无法显示
+ 0 - 0
spine-ts/build/spine-webgl.js.map


+ 27 - 20
spine-ts/core/src/AnimationState.ts

@@ -288,30 +288,37 @@ module spine {
 			let rotateTimeline = timeline as RotateTimeline;
 			let frames = rotateTimeline.frames;
 			let bone = skeleton.bones[rotateTimeline.boneIndex];
+			let r1 = 0, r2 = 0;
 			if (time < frames[0]) {
-				if (blend == MixBlend.setup) bone.rotation = bone.data.rotation;
-				return;
-			}
-
-			let r2 = 0;
-			if (time >= frames[frames.length - RotateTimeline.ENTRIES]) // Time is after last frame.
-				r2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION];
-			else {
-				// Interpolate between the previous frame and the current frame.
-				let frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES);
-				let prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
-				let frameTime = frames[frame];
-				let percent = rotateTimeline.getCurvePercent((frame >> 1) - 1,
-					1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
-
-				r2 = frames[frame + RotateTimeline.ROTATION] - prevRotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
-				r2 = prevRotation + r2 * percent + bone.data.rotation;
-				r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				switch (blend) {
+					case MixBlend.setup:
+						bone.rotation = bone.data.rotation;
+					default:
+						return;
+					case MixBlend.first:
+						r1 = bone.rotation;
+						r2 = bone.data.rotation;
+				}
+			} else {
+				r1 = blend == MixBlend.setup ? bone.data.rotation : bone.rotation;
+				if (time >= frames[frames.length - RotateTimeline.ENTRIES]) // Time is after last frame.
+					r2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION];
+				else {
+					// Interpolate between the previous frame and the current frame.
+					let frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES);
+					let prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
+					let frameTime = frames[frame];
+					let percent = rotateTimeline.getCurvePercent((frame >> 1) - 1,
+						1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
+
+					r2 = frames[frame + RotateTimeline.ROTATION] - prevRotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+					r2 = prevRotation + r2 * percent + bone.data.rotation;
+					r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
+				}
 			}
 
 			// Mix between rotations using the direction of the shortest route on the first frame while detecting crosses.
-			let r1 = blend == MixBlend.setup ? bone.data.rotation : bone.rotation;
 			let total = 0, diff = r2 - r1;
 			diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
 			if (diff == 0) {

部分文件因为文件数量过多而无法显示