Просмотр исходного кода

[as3] Ported VertexAttachment id and Timeline/Animation#apply changes

badlogic 8 лет назад
Родитель
Сommit
ba409c8f3b
25 измененных файлов с 178 добавлено и 95 удалено
  1. 1 0
      CHANGELOG.md
  2. BIN
      spine-as3/spine-as3-example/lib/spine-as3.swc
  3. 2 0
      spine-as3/spine-as3/.settings/org.eclipse.core.resources.prefs
  4. 2 2
      spine-as3/spine-as3/src/spine/animation/Animation.as
  5. 22 22
      spine-as3/spine-as3/src/spine/animation/AnimationState.as
  6. 3 3
      spine-as3/spine-as3/src/spine/animation/AttachmentTimeline.as
  7. 10 3
      spine-as3/spine-as3/src/spine/animation/ColorTimeline.as
  8. 1 1
      spine-as3/spine-as3/src/spine/animation/CurveTimeline.as
  9. 22 14
      spine-as3/spine-as3/src/spine/animation/DeformTimeline.as
  10. 3 3
      spine-as3/spine-as3/src/spine/animation/DrawOrderTimeline.as
  11. 2 2
      spine-as3/spine-as3/src/spine/animation/EventTimeline.as
  12. 13 8
      spine-as3/spine-as3/src/spine/animation/IkConstraintTimeline.as
  13. 8 3
      spine-as3/spine-as3/src/spine/animation/PathConstraintMixTimeline.as
  14. 9 3
      spine-as3/spine-as3/src/spine/animation/PathConstraintPositionTimeline.as
  15. 9 3
      spine-as3/spine-as3/src/spine/animation/PathConstraintSpacingTimeline.as
  16. 12 4
      spine-as3/spine-as3/src/spine/animation/RotateTimeline.as
  17. 9 4
      spine-as3/spine-as3/src/spine/animation/ScaleTimeline.as
  18. 8 3
      spine-as3/spine-as3/src/spine/animation/ShearTimeline.as
  19. 1 1
      spine-as3/spine-as3/src/spine/animation/Timeline.as
  20. 15 8
      spine-as3/spine-as3/src/spine/animation/TransformConstraintTimeline.as
  21. 8 3
      spine-as3/spine-as3/src/spine/animation/TranslateTimeline.as
  22. 15 5
      spine-as3/spine-as3/src/spine/animation/TwoColorTimeline.as
  23. 3 0
      spine-as3/spine-as3/src/spine/attachments/VertexAttachment.as
  24. BIN
      spine-starling/spine-starling-example/lib/spine-as3.swc
  25. BIN
      spine-starling/spine-starling/lib/spine-as3.swc

+ 1 - 0
CHANGELOG.md

@@ -16,6 +16,7 @@
   * Added `PointAttachment`, additional method `newPointAttachment` in `AttachmentLoader` interface.
   * Added `ClippingAttachment`, additional method `newClippingAttachment` in `AttachmentLoader` interface.
   * `AnimationState#apply` returns boolean indicating if any timeline was applied or not.
+  * `Animation#apply` and `Timeline#apply`` now take enums `MixPose` and `MixDirection` instead of booleans
 
 ### Starling
  * Fixed renderer to work with 3.6 changes.

BIN
spine-as3/spine-as3-example/lib/spine-as3.swc


+ 2 - 0
spine-as3/spine-as3/.settings/org.eclipse.core.resources.prefs

@@ -2,6 +2,8 @@ eclipse.preferences.version=1
 encoding//src/spine/SkeletonClipping.as=UTF-8
 encoding//src/spine/SkeletonJson.as=UTF-8
 encoding//src/spine/Triangulator.as=UTF-8
+encoding//src/spine/animation/MixDirection.as=UTF-8
+encoding//src/spine/animation/MixPose.as=UTF-8
 encoding//src/spine/animation/TwoColorTimeline.as=UTF-8
 encoding//src/spine/attachments/ClippingAttachment.as=UTF-8
 encoding//src/spine/attachments/PointAttachment.as=UTF-8

+ 2 - 2
spine-as3/spine-as3/src/spine/animation/Animation.as

@@ -50,7 +50,7 @@ package spine.animation {
 		}
 
 		/** Poses the skeleton at the specified time for this animation. */
-		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, loop : Boolean, events : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, loop : Boolean, events : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			if (skeleton == null) throw new ArgumentError("skeleton cannot be null.");
 
 			if (loop && duration != 0) {
@@ -59,7 +59,7 @@ package spine.animation {
 			}
 
 			for (var i : int = 0, n : int = timelines.length; i < n; i++)
-				timelines[i].apply(skeleton, lastTime, time, events, alpha, setupPose, mixingOut);
+				timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction);
 		}
 
 		public function get name() : String {

+ 22 - 22
spine-as3/spine-as3/src/spine/animation/AnimationState.as

@@ -158,11 +158,12 @@ package spine.animation {
 				var current : TrackEntry = tracks[i];
 				if (current == null || current.delay > 0) continue;
 				applied = true;
+				var currentPose : MixPose = i == 0 ? MixPose.current : MixPose.currentLayered;
 
 				// Apply mixing from entries first.
 				var mix : Number = current.alpha;
 				if (current.mixingFrom != null)
-					mix *= applyMixingFrom(current, skeleton);
+					mix *= applyMixingFrom(current, skeleton, currentPose);
 				else if (current.trackTime >= current.trackEnd && current.next == null)
 					mix = 0;
 
@@ -173,7 +174,7 @@ package spine.animation {
 				var ii : int = 0;
 				if (mix == 1) {
 					for (ii = 0; ii < timelineCount; ii++)
-						Timeline(timelines[ii]).apply(skeleton, animationLast, animationTime, events, 1, true, false);
+						Timeline(timelines[ii]).apply(skeleton, animationLast, animationTime, events, 1, MixPose.setup, MixDirection.In);
 				} else {
 					var timelineData : Vector.<int> = current.timelineData;
 					
@@ -183,10 +184,11 @@ package spine.animation {
 					
 					for (ii = 0; ii < timelineCount; ii++) {
 						var timeline : Timeline = timelines[ii];
+						var pose : MixPose = timelineData[ii] >= AnimationState.FIRST ? MixPose.setup : currentPose;
 						if (timeline is RotateTimeline) {
-							applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= FIRST, timelinesRotation, ii << 1, firstFrame);
+							applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);
 						} else
-							timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= FIRST, false);
+							timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, MixDirection.In);
 					}
 				}
 				queueEvents(current, animationTime);
@@ -199,9 +201,9 @@ package spine.animation {
 			return applied;
 		}
 
-		private function applyMixingFrom(to : TrackEntry, skeleton : Skeleton) : Number {
+		private function applyMixingFrom(to : TrackEntry, skeleton : Skeleton, currentPose : MixPose) : Number {
 			var from : TrackEntry = to.mixingFrom;
-			if (from.mixingFrom != null) applyMixingFrom(from, skeleton);
+			if (from.mixingFrom != null) applyMixingFrom(from, skeleton, currentPose);
 
 			var mix : Number = 0;
 			if (to.mixDuration == 0) // Single frame mix to undo mixingFrom changes.
@@ -223,7 +225,7 @@ package spine.animation {
 			if (firstFrame) from.timelinesRotation.length = timelineCount << 1;
 			var timelinesRotation : Vector.<Number> = from.timelinesRotation;
 
-			var first : Boolean = false;
+			var pose : MixPose;
 			var alphaDip : Number = from.alpha * to.interruptAlpha;
 			var alphaMix : Number = alphaDip * (1 - mix);
 			var alpha : Number = 0;
@@ -232,19 +234,21 @@ package spine.animation {
 				var timeline : Timeline = timelines[i];
 				switch (timelineData[i]) {
 				case SUBSEQUENT:
-					first = false;
+					if (!attachments && timeline is AttachmentTimeline) continue;
+					if (!drawOrder && timeline is DrawOrderTimeline) continue;
+					pose = currentPose;
 					alpha = alphaMix;
 					break;
 				case FIRST:
-					first = true;
+					pose = MixPose.setup;
 					alpha = alphaMix;
 					break;
 				case DIP:
-					first = true;
+					pose = MixPose.setup;
 					alpha = alphaDip;
 					break;
 				default:
-					first = true;
+					pose = MixPose.setup;
 					alpha = alphaDip;
 					var dipMix : TrackEntry = timelineDipMix[i];
 					alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
@@ -252,13 +256,9 @@ package spine.animation {
 				}
 				from.totalAlpha += alpha;
 				if (timeline is RotateTimeline)
-					applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
-				else {
-					if (!first) {
-						if (!attachments && timeline is AttachmentTimeline) continue;
-						if (!drawOrder && timeline is DrawOrderTimeline) continue;
-					}
-					timeline.apply(skeleton, animationLast, animationTime, events, alpha, first, true);
+					applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
+				else {					
+					timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, MixDirection.Out);
 				}
 			}
 	
@@ -270,11 +270,11 @@ package spine.animation {
 			return mix;
 		}
 
-		private function applyRotateTimeline(timeline : Timeline, skeleton : Skeleton, time : Number, alpha : Number, setupPose : Boolean, timelinesRotation : Vector.<Number>, i : int, firstFrame : Boolean) : void {
+		private function applyRotateTimeline(timeline : Timeline, skeleton : Skeleton, time : Number, alpha : Number, pose : MixPose, timelinesRotation : Vector.<Number>, i : int, firstFrame : Boolean) : void {
 			if (firstFrame) timelinesRotation[i] = 0;
 
 			if (alpha == 1) {
-				timeline.apply(skeleton, 0, time, null, 1, setupPose, false);
+				timeline.apply(skeleton, 0, time, null, 1, pose, MixDirection.In);
 				return;
 			}
 
@@ -282,7 +282,7 @@ package spine.animation {
 			var frames : Vector.<Number> = rotateTimeline.frames;
 			var bone : Bone = skeleton.bones[rotateTimeline.boneIndex];
 			if (time < frames[0]) {
-				if (setupPose) bone.rotation = bone.data.rotation;
+				if (pose == MixPose.setup) bone.rotation = bone.data.rotation;
 				return;
 			}
 
@@ -303,7 +303,7 @@ package spine.animation {
 			}
 
 			// Mix between rotations using the direction of the shortest route on the first frame while detecting crosses.
-			var r1 : Number = setupPose ? bone.data.rotation : bone.rotation;
+			var r1 : Number = pose == MixPose.setup ? bone.data.rotation : bone.rotation;
 			var total : Number, diff : Number = r2 - r1;
 			if (diff == 0) {
 				total = timelinesRotation[i];

+ 3 - 3
spine-as3/spine-as3/src/spine/animation/AttachmentTimeline.as

@@ -57,17 +57,17 @@ package spine.animation {
 			attachmentNames[frameIndex] = attachmentName;
 		}
 
-		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var attachmentName : String;
 			var slot : Slot = skeleton.slots[slotIndex];
-			if (mixingOut && setupPose) {
+			if (direction == MixDirection.Out && pose == MixPose.setup) {
 				attachmentName = slot.data.attachmentName;
 				slot.attachment = attachmentName == null ? null : skeleton.getAttachmentForSlotIndex(slotIndex, attachmentName);
 				return;
 			}
 			var frames : Vector.<Number> = this.frames;
 			if (time < frames[0]) {
-				if (setupPose) {
+				if (pose == MixPose.setup) {
 					attachmentName = slot.data.attachmentName;
 					slot.attachment = attachmentName == null ? null : skeleton.getAttachmentForSlotIndex(slotIndex, attachmentName);
 				}

+ 10 - 3
spine-as3/spine-as3/src/spine/animation/ColorTimeline.as

@@ -29,6 +29,7 @@
  *****************************************************************************/
 
 package spine.animation {
+	import spine.Color;
 	import spine.Event;
 	import spine.Skeleton;
 	import spine.Slot;
@@ -59,13 +60,19 @@ package spine.animation {
 			frames[int(frameIndex + A)] = a;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var frames : Vector.<Number> = this.frames;
 			var slot : Slot = skeleton.slots[slotIndex];
 
 			if (time < frames[0]) {
-				if (setupPose) {
+				switch (pose) {
+				case MixPose.setup:
 					slot.color.setFromColor(slot.data.color);
+					return;
+				case MixPose.current:
+					var color : Color = slot.color, setup : Color = slot.data.color;
+					color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha,
+						(setup.a - color.a) * alpha);
 				}
 				return;
 			}
@@ -95,7 +102,7 @@ package spine.animation {
 			if (alpha == 1) {
 				slot.color.setFrom(r, g, b, a);
 			} else {
-				if (setupPose) {
+				if (pose == MixPose.setup) {
 					slot.color.setFromColor(slot.data.color);
 				}
 				slot.color.r += (r - slot.color.r) * alpha;

+ 1 - 1
spine-as3/spine-as3/src/spine/animation/CurveTimeline.as

@@ -45,7 +45,7 @@ package spine.animation {
 			curves = new Vector.<Number>((frameCount - 1) * BEZIER_SIZE, true);
 		}
 
-		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 		}
 
 		public function getPropertyId() : int {

+ 22 - 14
spine-as3/spine-as3/src/spine/animation/DeformTimeline.as

@@ -48,7 +48,7 @@ package spine.animation {
 		}
 
 		override public function getPropertyId() : int {
-			return (TimelineType.deform.ordinal << 24) + slotIndex;
+			return (TimelineType.deform.ordinal << 27) + attachment.id + slotIndex;
 		}
 
 		/** Sets the time and value of the specified keyframe. */
@@ -57,26 +57,34 @@ package spine.animation {
 			frameVertices[frameIndex] = vertices;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var slot : Slot = skeleton.slots[slotIndex];
 			var slotAttachment : Attachment = slot.attachment;
 			if (!(slotAttachment is VertexAttachment) || !(VertexAttachment(slotAttachment)).applyDeform(attachment)) return;
-
-			var frames : Vector.<Number> = this.frames;
+			
 			var verticesArray : Vector.<Number> = slot.attachmentVertices;
-			if (time < frames[0]) {
-				if (setupPose) verticesArray.length = 0;
-				return;
-			}
-
 			var frameVertices : Vector.<Vector.<Number>> = this.frameVertices;
 			var vertexCount : int = frameVertices[0].length;
-
-			if (verticesArray.length != vertexCount && !setupPose) alpha = 1; // Don't mix from uninitialized slot vertices.
+			if (verticesArray.length != vertexCount && pose != MixPose.setup) alpha = 1; // Don't mix from uninitialized slot vertices.
 			verticesArray.length = vertexCount;
 			var vertices : Vector.<Number> = verticesArray;
 
-			var i : int, n : int;
+			var frames : Vector.<Number> = this.frames;
+			var i : int;			
+			if (time < frames[0]) {
+				switch (pose) {
+				case MixPose.setup:
+					verticesArray.length = 0;
+					return;
+				case MixPose.current:
+					alpha = 1 - alpha;
+					for (i = 0; i < vertexCount; i++)
+						vertices[i] *= alpha;
+				}
+				return;
+			}						
+
+			var n : int;
 			var vertexAttachment : VertexAttachment;
 			var setupVertices : Vector.<Number>;
 			var setup : Number, prev : Number;
@@ -86,7 +94,7 @@ package spine.animation {
 					// Vertex positions or deform offsets, no alpha.
 					for (i = 0, n = vertexCount; i < n; i++)
 						vertices[i] = lastVertices[i];
-				} else if (setupPose) {
+				} else if (pose == MixPose.setup) {
 					vertexAttachment = VertexAttachment(slotAttachment);
 					if (vertexAttachment.bones == null) {
 						// Unweighted vertex positions, with alpha.
@@ -121,7 +129,7 @@ package spine.animation {
 					prev = prevVertices[i];
 					vertices[i] = prev + (nextVertices[i] - prev) * percent;
 				}
-			} else if (setupPose) {
+			} else if (pose == MixPose.setup) {
 				vertexAttachment = VertexAttachment(slotAttachment);
 				if (vertexAttachment.bones == null) {
 					// Unweighted vertex positions, with alpha.

+ 3 - 3
spine-as3/spine-as3/src/spine/animation/DrawOrderTimeline.as

@@ -56,8 +56,8 @@ package spine.animation {
 			drawOrders[frameIndex] = drawOrder;
 		}
 
-		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
-			if (mixingOut && setupPose) {
+		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
+			if (direction == MixDirection.Out && pose == MixPose.setup) {
 				for (var ii : int = 0, n : int = skeleton.slots.length; ii < n; ii++)
 					skeleton.drawOrder[ii] = skeleton.slots[ii];
 				return;
@@ -68,7 +68,7 @@ package spine.animation {
 			var slot : Slot;
 			var i : int = 0;
 			if (time < frames[0]) {
-				if (setupPose) {
+				if (pose == MixPose.setup) {
 					for each (slot in slots)
 						drawOrder[i++] = slot;
 				}

+ 2 - 2
spine-as3/spine-as3/src/spine/animation/EventTimeline.as

@@ -56,11 +56,11 @@ package spine.animation {
 		}
 
 		/** Fires events for frames > lastTime and <= time. */
-		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			if (!firedEvents) return;
 
 			if (lastTime > time) { // Fire events after last time for looped animations.
-				apply(skeleton, lastTime, int.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
+				apply(skeleton, lastTime, int.MAX_VALUE, firedEvents, alpha, pose, direction);
 				lastTime = -1;
 			} else if (lastTime >= frames[int(frameCount - 1)]) // Last time is after last frame.
 				return;

+ 13 - 8
spine-as3/spine-as3/src/spine/animation/IkConstraintTimeline.as

@@ -57,23 +57,28 @@ package spine.animation {
 			frames[int(frameIndex + BEND_DIRECTION)] = bendDirection;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var constraint : IkConstraint = skeleton.ikConstraints[ikConstraintIndex];
 			if (time < frames[0]) {
-				if (setupPose) {
+				switch (pose) {
+				case MixPose.setup:
 					constraint.mix = constraint.data.mix;
 					constraint.bendDirection = constraint.data.bendDirection;
+					return;
+				case MixPose.current:
+					constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
+					constraint.bendDirection = constraint.data.bendDirection;
 				}
 				return;
 			}
 
 			if (time >= frames[int(frames.length - ENTRIES)]) { // Time is after last frame.
-				if (setupPose) {
+				if (pose == MixPose.setup) {
 					constraint.mix = constraint.data.mix + (frames[frames.length + PREV_MIX] - constraint.data.mix) * alpha;
-					constraint.bendDirection = mixingOut ? constraint.data.bendDirection : int(frames[frames.length + PREV_BEND_DIRECTION]);
+					constraint.bendDirection = direction == MixDirection.Out ? constraint.data.bendDirection : int(frames[frames.length + PREV_BEND_DIRECTION]);
 				} else {
 					constraint.mix += (frames[frames.length + PREV_MIX] - constraint.mix) * alpha;
-					if (!mixingOut) constraint.bendDirection = int(frames[frames.length + PREV_BEND_DIRECTION]);
+					if (direction == MixDirection.In) constraint.bendDirection = int(frames[frames.length + PREV_BEND_DIRECTION]);
 				}
 				return;
 			}
@@ -84,12 +89,12 @@ package spine.animation {
 			var frameTime : Number = frames[frame];
 			var percent : Number = getCurvePercent(frame / ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PREV_TIME] - frameTime));
 
-			if (setupPose) {
+			if (pose == MixPose.setup) {
 				constraint.mix = constraint.data.mix + (mix + (frames[frame + MIX] - mix) * percent - constraint.data.mix) * alpha;
-				constraint.bendDirection = mixingOut ? constraint.data.bendDirection : int(frames[frame + PREV_BEND_DIRECTION]);
+				constraint.bendDirection = direction == MixDirection.Out ? constraint.data.bendDirection : int(frames[frame + PREV_BEND_DIRECTION]);
 			} else {
 				constraint.mix += (mix + (frames[frame + MIX] - mix) * percent - constraint.mix) * alpha;
-				if (!mixingOut) constraint.bendDirection = int(frames[frame + PREV_BEND_DIRECTION]);
+				if (direction == MixDirection.In) constraint.bendDirection = int(frames[frame + PREV_BEND_DIRECTION]);
 			}
 		}
 	}

+ 8 - 3
spine-as3/spine-as3/src/spine/animation/PathConstraintMixTimeline.as

@@ -57,12 +57,17 @@ package spine.animation {
 			frames[frameIndex + TRANSLATE] = translateMix;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var constraint : PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
 			if (time < frames[0]) {
-				if (setupPose) {
+				switch (pose) {
+				case MixPose.setup:
 					constraint.rotateMix = constraint.data.rotateMix;
 					constraint.translateMix = constraint.data.translateMix;
+					return;
+				case MixPose.current:
+					constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
+					constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
 				}
 				return;
 			}
@@ -83,7 +88,7 @@ package spine.animation {
 				translate += (frames[frame + TRANSLATE] - translate) * percent;
 			}
 
-			if (setupPose) {
+			if (pose == MixPose.setup) {
 				constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
 				constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
 			} else {

+ 9 - 3
spine-as3/spine-as3/src/spine/animation/PathConstraintPositionTimeline.as

@@ -56,10 +56,16 @@ package spine.animation {
 			frames[frameIndex + VALUE] = value;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var constraint : PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
 			if (time < frames[0]) {
-				if (setupPose) constraint.position = constraint.data.position;
+				switch (pose) {
+				case MixPose.setup:
+					constraint.position = constraint.data.position;
+					return;
+				case MixPose.current:
+					constraint.position += (constraint.data.position - constraint.position) * alpha;
+				}
 				return;
 			}
 
@@ -75,7 +81,7 @@ package spine.animation {
 
 				position += (frames[frame + VALUE] - position) * percent;
 			}
-			if (setupPose)
+			if (pose == MixPose.setup)
 				constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
 			else
 				constraint.position += (position - constraint.position) * alpha;

+ 9 - 3
spine-as3/spine-as3/src/spine/animation/PathConstraintSpacingTimeline.as

@@ -42,10 +42,16 @@ package spine.animation {
 			return (TimelineType.pathConstraintSpacing.ordinal << 24) + pathConstraintIndex;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var constraint : PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
 			if (time < frames[0]) {
-				if (setupPose) constraint.spacing = constraint.data.spacing;
+				switch (pose) {
+				case MixPose.setup:
+					constraint.spacing = constraint.data.spacing;
+					return;
+				case MixPose.current:
+					constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
+				}
 				return;
 			}
 
@@ -62,7 +68,7 @@ package spine.animation {
 				spacing += (frames[frame + VALUE] - spacing) * percent;
 			}
 
-			if (setupPose)
+			if (pose == MixPose.setup)
 				constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
 			else
 				constraint.spacing += (spacing - constraint.spacing) * alpha;

+ 12 - 4
spine-as3/spine-as3/src/spine/animation/RotateTimeline.as

@@ -56,18 +56,26 @@ package spine.animation {
 			frames[int(frameIndex + ROTATION)] = degrees;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var frames : Vector.<Number> = this.frames;
 
 			var bone : Bone = skeleton.bones[boneIndex];
 			var r : Number;
 			if (time < frames[0]) {
-				if (setupPose) bone.rotation = bone.data.rotation;
+				switch (pose) {
+				case MixPose.setup:
+					bone.rotation = bone.data.rotation;
+					return;
+				case MixPose.current:
+					r = bone.data.rotation - bone.rotation;
+					r -= (16384 - int((16384.499999999996 - r / 360))) * 360;
+					bone.rotation += r * alpha;
+				}
 				return;
 			}
 
 			if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
-				if (setupPose)
+				if (pose == MixPose.setup)
 					bone.rotation = bone.data.rotation + frames[frames.length + PREV_ROTATION] * alpha;
 				else {
 					r = bone.data.rotation + frames[frames.length + PREV_ROTATION] - bone.rotation;
@@ -86,7 +94,7 @@ package spine.animation {
 			r = frames[frame + ROTATION] - prevRotation;
 			r -= (16384 - int((16384.499999999996 - r / 360))) * 360;
 			r = prevRotation + r * percent;
-			if (setupPose) {
+			if (pose == MixPose.setup) {
 				r -= (16384 - int((16384.499999999996 - r / 360))) * 360;
 				bone.rotation = bone.data.rotation + r * alpha;
 			} else {

+ 9 - 4
spine-as3/spine-as3/src/spine/animation/ScaleTimeline.as

@@ -43,14 +43,19 @@ package spine.animation {
 			return (TimelineType.scale.ordinal << 24) + boneIndex;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var frames : Vector.<Number> = this.frames;
 			var bone : Bone = skeleton.bones[boneIndex];
 
 			if (time < frames[0]) {
-				if (setupPose) {
+				switch (pose) {
+				case MixPose.setup:
 					bone.scaleX = bone.data.scaleX;
 					bone.scaleY = bone.data.scaleY;
+					return;
+				case MixPose.current:
+					bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
+					bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
 				}
 				return;
 			}
@@ -75,7 +80,7 @@ package spine.animation {
 				bone.scaleY = y;
 			} else {
 				var bx : Number, by : Number;
-				if (setupPose) {
+				if (pose == MixPose.setup) {
 					bx = bone.data.scaleX;
 					by = bone.data.scaleY;
 				} else {
@@ -83,7 +88,7 @@ package spine.animation {
 					by = bone.scaleY;
 				}
 				// Mixing out uses sign of setup or current pose, else use sign of key.
-				if (mixingOut) {
+				if (direction == MixDirection.Out) {
 					x = Math.abs(x) * MathUtils.signum(bx);
 					y = Math.abs(y) * MathUtils.signum(by);
 				} else {

+ 8 - 3
spine-as3/spine-as3/src/spine/animation/ShearTimeline.as

@@ -42,14 +42,19 @@ package spine.animation {
 			return (TimelineType.shear.ordinal << 24) + boneIndex;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var frames : Vector.<Number> = this.frames;
 			var bone : Bone = skeleton.bones[boneIndex];
 
 			if (time < frames[0]) {
-				if (setupPose) {
+				switch (pose) {
+				case MixPose.setup:
 					bone.shearX = bone.data.shearX;
 					bone.shearY = bone.data.shearY;
+					return;
+				case MixPose.current:
+					bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
+					bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
 				}
 				return;
 			}
@@ -69,7 +74,7 @@ package spine.animation {
 				x = x + (frames[frame + X] - x) * percent;
 				y = y + (frames[frame + Y] - y) * percent;
 			}
-			if (setupPose) {
+			if (pose == MixPose.setup) {
 				bone.shearX = bone.data.shearX + x * alpha;
 				bone.shearY = bone.data.shearY + y * alpha;
 			} else {

+ 1 - 1
spine-as3/spine-as3/src/spine/animation/Timeline.as

@@ -34,7 +34,7 @@ package spine.animation {
 
 	public interface Timeline {
 		/** Sets the value(s) for the specified time. */
-		function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void;
+		function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void;
 
 		function getPropertyId() : int;
 	}

+ 15 - 8
spine-as3/spine-as3/src/spine/animation/TransformConstraintTimeline.as

@@ -60,18 +60,25 @@ package spine.animation {
 			frames[frameIndex + SHEAR] = shearMix;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var frames : Vector.<Number> = this.frames;
 
 			var constraint : TransformConstraint = skeleton.transformConstraints[transformConstraintIndex];
 			var data : TransformConstraintData;
 			if (time < frames[0]) {
-				if (setupPose) {
-					data = constraint.data;
-					constraint.rotateMix = constraint.data.rotateMix;
-					constraint.translateMix = constraint.data.translateMix;
-					constraint.scaleMix = constraint.data.scaleMix;
-					constraint.shearMix = constraint.data.shearMix;
+				data = constraint.data;
+				switch (pose) {
+				case MixPose.setup:
+					constraint.rotateMix = data.rotateMix;
+					constraint.translateMix = data.translateMix;
+					constraint.scaleMix = data.scaleMix;
+					constraint.shearMix = data.shearMix;
+					return;
+				case MixPose.current:
+					constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
+					constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
+					constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
+					constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
 				}
 				return;
 			}
@@ -98,7 +105,7 @@ package spine.animation {
 				scale += (frames[frame + SCALE] - scale) * percent;
 				shear += (frames[frame + SHEAR] - shear) * percent;
 			}
-			if (setupPose) {
+			if (pose == MixPose.setup) {
 				data = constraint.data;
 				constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
 				constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;

+ 8 - 3
spine-as3/spine-as3/src/spine/animation/TranslateTimeline.as

@@ -57,14 +57,19 @@ package spine.animation {
 			frames[int(frameIndex + Y)] = y;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var frames : Vector.<Number> = this.frames;
 
 			var bone : Bone = skeleton.bones[boneIndex];
 			if (time < frames[0]) {
-				if (setupPose) {
+				switch (pose) {
+				case MixPose.setup:
 					bone.x = bone.data.x;
 					bone.y = bone.data.y;
+					return;
+				case MixPose.current:
+					bone.x += (bone.data.x - bone.x) * alpha;
+					bone.y += (bone.data.y - bone.y) * alpha;
 				}
 				return;
 			}
@@ -84,7 +89,7 @@ package spine.animation {
 				x += (frames[frame + X] - x) * percent;
 				y += (frames[frame + Y] - y) * percent;
 			}
-			if (setupPose) {
+			if (pose == MixPose.setup) {
 				bone.x = bone.data.x + x * alpha;
 				bone.y = bone.data.y + y * alpha;
 			} else {

+ 15 - 5
spine-as3/spine-as3/src/spine/animation/TwoColorTimeline.as

@@ -64,14 +64,24 @@ package spine.animation {
 			this.frames[frameIndex + TwoColorTimeline.B2] = b2;
 		}
 
-		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, setupPose : Boolean, mixingOut : Boolean) : void {
+		override public function apply(skeleton : Skeleton, lastTime : Number, time : Number, firedEvents : Vector.<Event>, alpha : Number, pose : MixPose, direction : MixDirection) : void {
 			var frames : Vector.<Number> = this.frames;
 			var slot : Slot = skeleton.slots[slotIndex];
+			var light : Color, dark : Color;
 
 			if (time < frames[0]) {
-				if (setupPose) {
+				switch (pose) {
+				case MixPose.setup:
 					slot.color.setFromColor(slot.data.color);
 					slot.darkColor.setFromColor(slot.data.darkColor);
+					return;
+				case MixPose.current:
+					light = slot.color;
+					dark = slot.darkColor;
+					var setupLight : Color = slot.data.color, setupDark : Color = slot.data.darkColor;
+					light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha,
+						(setupLight.a - light.a) * alpha);
+					dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
 				}
 				return;
 			}
@@ -111,9 +121,9 @@ package spine.animation {
 				slot.color.setFrom(r, g, b, a);
 				slot.darkColor.setFrom(r2, g2, b2, 1);
 			} else {
-				var light : Color = slot.color;
-				var dark : Color = slot.darkColor;
-				if (setupPose) {
+				light = slot.color;
+				dark = slot.darkColor;
+				if (pose == MixPose.setup) {
 					light.setFromColor(slot.data.color);
 					dark.setFromColor(slot.data.darkColor);
 				}

+ 3 - 0
spine-as3/spine-as3/src/spine/attachments/VertexAttachment.as

@@ -34,9 +34,12 @@ package spine.attachments {
 	import spine.Slot;
 
 	public dynamic class VertexAttachment extends Attachment {
+		private static var nextID : int = 0;
+		
 		public var bones : Vector.<int>;
 		public var vertices : Vector.<Number>;
 		public var worldVerticesLength : int;
+		public var id : int = (nextID++ & 65535) << 11;
 
 		public function VertexAttachment(name : String) {
 			super(name);

BIN
spine-starling/spine-starling-example/lib/spine-as3.swc


BIN
spine-starling/spine-starling/lib/spine-as3.swc