From abdbb10480e4906d659bb11c18d1dc65e0af1e88 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Mon, 15 Oct 2018 16:24:48 +0200 Subject: [PATCH 1/4] [libgdx] Fixed 0 timeScale not returning to the setup pose. closes #1194 --- .../src/com/esotericsoftware/spine/AnimationState.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 233a2c0aa..7c826ac40 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -171,7 +171,7 @@ public class AnimationState { from.trackLast = from.nextTrackLast; // Require mixTime > 0 to ensure the mixing from entry was applied at least once. - if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { + if (to.mixTime > 0 && to.mixTime >= to.mixDuration) { // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). if (from.totalAlpha == 0 || to.mixDuration == 0) { to.mixingFrom = from.mixingFrom; @@ -182,6 +182,13 @@ public class AnimationState { return finished; } + // If to has 0 timeScale and is not the first entry, remove the mix and apply it one more time to return to the setup pose. + if (to.timeScale == 0 && to.mixingTo != null) { + to.timeScale = 1; + to.mixTime = 0; + to.mixDuration = 0; + } + from.trackTime += delta * from.timeScale; to.mixTime += delta * to.timeScale; return false; From eea4d106c1590b227979956ec3319b27497f61de Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Mon, 15 Oct 2018 16:25:09 +0200 Subject: [PATCH 2/4] [libgdx] Added AnimationState#getMixingFrom. --- .../src/com/esotericsoftware/spine/AnimationState.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 7c826ac40..1f6d1ce82 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -1073,6 +1073,12 @@ public class AnimationState { return mixingFrom; } + /** The track entry for the next animation when mixing from this animation to the next animation, or null if no mixing is + * currently occuring. When mixing to multiple animations, mixingTo makes up a linked list. */ + public TrackEntry getMixingTo () { + return mixingTo; + } + public void setHoldPrevious (boolean holdPrevious) { this.holdPrevious = holdPrevious; } From 48371236db8237843c1731dd407871e7a0200d57 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Mon, 15 Oct 2018 16:25:38 +0200 Subject: [PATCH 3/4] [libgdx] AnimationState javadocs. --- .../src/com/esotericsoftware/spine/AnimationState.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 1f6d1ce82..2d4a1ec6d 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -495,7 +495,8 @@ public class AnimationState { return setAnimation(trackIndex, animation, loop); } - /** Sets the current animation for a track, discarding any queued animations. + /** Sets the current animation for a track, discarding any queued animations. If the formerly current track entry was never + * applied to a skeleton, it is replaced (not mixed from). * @param loop If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its * duration. In either case {@link TrackEntry#getTrackEnd()} determines when the track is cleared. * @return A track entry to allow further customization of animation playback. References to the track entry must not be kept @@ -816,6 +817,7 @@ public class AnimationState { float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale; float alpha, mixTime, mixDuration, interruptAlpha, totalAlpha; MixBlend mixBlend = MixBlend.replace; + final IntArray timelineMode = new IntArray(); final Array timelineHoldMix = new Array(); final FloatArray timelinesRotation = new FloatArray(); From f057a8fd41171f4c3b68b8a9a5886b3ae4607d89 Mon Sep 17 00:00:00 2001 From: badlogic Date: Mon, 15 Oct 2018 16:34:22 +0200 Subject: [PATCH 4/4] [cpp] Setting vertex attachment did not clear slot.attachmentVertices. Closes #1188. --- spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp | 7 +++---- spine-cpp/spine-cpp/src/spine/DeformTimeline.cpp | 2 +- spine-cpp/spine-cpp/src/spine/Skeleton.cpp | 2 +- spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp b/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp index ad68c17a8..3d132dbc6 100644 --- a/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp @@ -70,7 +70,7 @@ void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, V Slot &slot = *slotP; if (direction == MixDirection_Out && blend == MixBlend_Setup) { attachmentName = &slot._data._attachmentName; - slot._attachment = attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName); + slot.setAttachment(attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName)); return; } @@ -78,8 +78,7 @@ void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, V // Time is before first frame. if (blend == MixBlend_Setup || blend == MixBlend_First) { attachmentName = &slot._data._attachmentName; - slot._attachment = - attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName); + slot.setAttachment(attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName)); } return; } @@ -93,7 +92,7 @@ void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, V } attachmentName = &_attachmentNames[frameIndex]; - slot._attachment = attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName); + slot.setAttachment(attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName)); } int AttachmentTimeline::getPropertyId() { diff --git a/spine-cpp/spine-cpp/src/spine/DeformTimeline.cpp b/spine-cpp/spine-cpp/src/spine/DeformTimeline.cpp index e13180ad7..37ca544f8 100644 --- a/spine-cpp/spine-cpp/src/spine/DeformTimeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/DeformTimeline.cpp @@ -69,7 +69,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto Slot *slotP = skeleton._slots[_slotIndex]; Slot &slot = *slotP; - Attachment *slotAttachment = slot._attachment; + Attachment *slotAttachment = slot.getAttachment(); if (slotAttachment == NULL || !slotAttachment->getRTTI().instanceOf(VertexAttachment::rtti)) { return; } diff --git a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp index 9040e3ce1..33550e702 100644 --- a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp @@ -564,7 +564,7 @@ void Skeleton::sortPathConstraint(PathConstraint *constraint) { for (size_t ii = 0, nn = _data->_skins.size(); ii < nn; ii++) sortPathConstraintAttachment(_data->_skins[ii], slotIndex, slotBone); - Attachment *attachment = slot->_attachment; + Attachment *attachment = slot->getAttachment(); if (attachment != NULL && attachment->getRTTI().instanceOf(PathAttachment::rtti)) sortPathConstraintAttachment(attachment, slotBone); diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp index 5ba3ce130..5e9ed1585 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp @@ -57,7 +57,7 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) { for (size_t i = 0; i < slotCount; i++) { Slot *slot = slots[i]; - Attachment *attachment = slot->_attachment; + Attachment *attachment = slot->getAttachment(); if (attachment == NULL || !attachment->getRTTI().instanceOf(BoundingBoxAttachment::rtti)) { continue; }