From d9e39c286655657aad1c55c72fa216d127ad79f3 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Sat, 1 Dec 2018 20:57:55 +0100 Subject: [PATCH 1/5] [libgdx] SkeletonViewer, display track percentages with lowest at bottom. --- .../src/com/esotericsoftware/spine/SkeletonViewer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java index af3a57527..4e630a3de 100644 --- a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java +++ b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java @@ -340,7 +340,7 @@ public class SkeletonViewer extends ApplicationAdapter { if (state != null) { // AnimationState status. status.setLength(0); - for (int i = 0, n = state.getTracks().size; i < n; i++) { + for (int i = state.getTracks().size - 1; i >= 0; i--) { TrackEntry entry = state.getTracks().get(i); if (entry == null) continue; status.append(i); From b4c50035b89b989fee5ba70f2965e301f0319bdf Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Sat, 1 Dec 2018 20:59:08 +0100 Subject: [PATCH 2/5] [libgdx] AnimationState, fixed attachment and draw order threshold TrackEntry settings. closes #1204 --- .../com/esotericsoftware/spine/AnimationState.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java index 3d309ce4f..4db2abfa1 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -280,6 +280,7 @@ public class AnimationState { from.totalAlpha = 0; for (int i = 0; i < timelineCount; i++) { Timeline timeline = (Timeline)timelines[i]; + MixDirection direction = MixDirection.out; MixBlend timelineBlend; float alpha; switch (timelineMode[i]) { @@ -307,8 +308,16 @@ public class AnimationState { if (timeline instanceof RotateTimeline) { applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame); - } else - timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, MixDirection.out); + } else { + if (timelineBlend == MixBlend.setup) { + if (timeline instanceof AttachmentTimeline) { + if (attachments) direction = MixDirection.in; + } else if (timeline instanceof DrawOrderTimeline) { + if (drawOrder) direction = MixDirection.in; + } + } + timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction); + } } } From 37b99d6933dbfc8d84a56982cd544c1cb850bb3c Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 3 Dec 2018 17:49:34 +0800 Subject: [PATCH 3/5] [unity] spine-unity whitespace formatting. --- .../spine-unity/Components/SkeletonMecanim.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs index d035a9ee4..d8dd8d51c 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs @@ -151,7 +151,7 @@ namespace Spine.Unity { ClearClipInfosForLayers(); } - public void Apply(Skeleton skeleton) { + public void Apply (Skeleton skeleton) { if (layerMixModes.Length < animator.layerCount) System.Array.Resize(ref layerMixModes, animator.layerCount); @@ -306,7 +306,7 @@ namespace Spine.Unity { } } - static float AnimationTime(float normalizedTime, float clipLength, bool loop, bool reversed) { + static float AnimationTime (float normalizedTime, float clipLength, bool loop, bool reversed) { if (reversed) normalizedTime = (1 - normalizedTime + (int)normalizedTime) + (int)normalizedTime; float time = normalizedTime * clipLength; @@ -315,14 +315,14 @@ namespace Spine.Unity { return (clipLength - time < EndSnapEpsilon) ? clipLength : time; // return a time snapped to clipLength; } - static float AnimationTime(float normalizedTime, float clipLength, bool reversed) { + static float AnimationTime (float normalizedTime, float clipLength, bool reversed) { if (reversed) normalizedTime = (1 - normalizedTime + (int)normalizedTime) + (int)normalizedTime; return normalizedTime * clipLength; } - void InitClipInfosForLayers() { + void InitClipInfosForLayers () { if (layerClipInfos.Length < animator.layerCount) { System.Array.Resize(ref layerClipInfos, animator.layerCount); for (int layer = 0, n = animator.layerCount; layer < n; ++layer) { @@ -332,7 +332,7 @@ namespace Spine.Unity { } } - void ClearClipInfosForLayers() { + void ClearClipInfosForLayers () { for (int layer = 0, n = layerClipInfos.Length; layer < n; ++layer) { if (layerClipInfos[layer] == null) layerClipInfos[layer] = new ClipInfos(); @@ -346,7 +346,7 @@ namespace Spine.Unity { } } - void GetStateUpdatesFromAnimator(int layer) { + void GetStateUpdatesFromAnimator (int layer) { var layerInfos = layerClipInfos[layer]; int clipInfoCount = animator.GetCurrentAnimatorClipInfoCount(layer); @@ -378,8 +378,7 @@ namespace Spine.Unity { layerInfos.interruptingClipTimeAddition = newTime - oldTime; layerInfos.interruptingStateInfo = interruptingStateInfo; } - } - else { + } else { layerInfos.clipInfoCount = clipInfoCount; layerInfos.nextClipInfoCount = nextClipInfoCount; layerInfos.interruptingClipInfoCount = 0; @@ -420,7 +419,7 @@ namespace Spine.Unity { shallInterpolateWeightTo1 = layerInfos.isLastFrameOfInterruption; } - void GetAnimatorStateInfos( + void GetAnimatorStateInfos ( int layer, out bool isInterruptionActive, out AnimatorStateInfo stateInfo, From 536ccce9ea8655aa3280f3aaee08244a916f8f67 Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 3 Dec 2018 18:25:11 +0800 Subject: [PATCH 4/5] [csharp] Update DrawOrderTimeline setup pose code. --- spine-csharp/src/Animation.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index b2c21bbf3..308989b44 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -1205,9 +1205,7 @@ namespace Spine { int[] drawOrderToSetupIndex = drawOrders[frame]; if (drawOrderToSetupIndex == null) { - drawOrder.Clear(); - for (int i = 0, n = slots.Count; i < n; i++) - drawOrder.Add(slots.Items[i]); + Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count); } else { var drawOrderItems = drawOrder.Items; var slotsItems = slots.Items; From 2db2f22705b712b27e1b5106605c739f657cd52c Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 3 Dec 2018 18:26:51 +0800 Subject: [PATCH 5/5] [csharp] Fix attachment and draworder threshold TrackEntry settings. Port of: https://github.com/EsotericSoftware/spine-runtimes/commit/b4c50035b89b989fee5ba70f2965e301f0319bdf see: https://github.com/EsotericSoftware/spine-runtimes/issues/1204 --- spine-csharp/src/AnimationState.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index ea6b47a27..fa6a65ed8 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -254,6 +254,7 @@ namespace Spine { from.totalAlpha = 0; for (int i = 0; i < timelineCount; i++) { Timeline timeline = timelinesItems[i]; + MixDirection direction = MixDirection.Out; MixBlend timelineBlend; float alpha; switch (timelineMode[i]) { @@ -283,7 +284,17 @@ namespace Spine { if (rotateTimeline != null) { ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame); } else { - timeline.Apply(skeleton, animationLast, animationTime, eventBuffer, alpha, timelineBlend, MixDirection.Out); + if (timelineBlend == MixBlend.Setup) { + if (timeline is AttachmentTimeline) { + if (attachments) direction = MixDirection.In; + } else if (timeline is DrawOrderTimeline) { + if (drawOrder) { + direction = MixDirection.In; + } + } + } + + timeline.Apply(skeleton, animationLast, animationTime, eventBuffer, alpha, timelineBlend, direction); } } }