diff --git a/spine-as3/spine-as3/src/spine/PathConstraint.as b/spine-as3/spine-as3/src/spine/PathConstraint.as index 633b31d38..6aa80b0bc 100644 --- a/spine-as3/spine-as3/src/spine/PathConstraint.as +++ b/spine-as3/spine-as3/src/spine/PathConstraint.as @@ -79,8 +79,8 @@ package spine { var data : PathConstraintData = this._data; var tangents : Boolean = data.rotateMode == RotateMode.tangent, scale : Boolean = data.rotateMode == RotateMode.chainScale; - var boneCount : int = this._bones.length, spacesCount : int = tangents ? boneCount : boneCount + 1; var bones : Vector. = this._bones; + var boneCount : int = bones.length, spacesCount : int = tangents ? boneCount : boneCount + 1; this._spaces.length = spacesCount; var spaces : Vector. = this._spaces, lengths : Vector. = _lengths; if (scale) lengths.length = boneCount; diff --git a/spine-as3/spine-as3/src/spine/animation/AnimationState.as b/spine-as3/spine-as3/src/spine/animation/AnimationState.as index 8f1b776f9..dbefc1aaf 100644 --- a/spine-as3/spine-as3/src/spine/animation/AnimationState.as +++ b/spine-as3/spine-as3/src/spine/animation/AnimationState.as @@ -180,8 +180,8 @@ package spine.animation { applyTime = current.animation.duration - applyTime; applyEvents = null; } - var timelineCount : int = current.animation.timelines.length; var timelines : Vector. = current.animation.timelines; + var timelineCount : int = timelines.length; var ii : int = 0; var timeline : Timeline; if ((i == 0 && mix == 1) || blend == MixBlend.add) { @@ -202,7 +202,7 @@ package spine.animation { timeline = timelines[ii]; var timelineBlend : MixBlend = timelineMode[ii] == SUBSEQUENT ? blend : MixBlend.setup; if (timeline is RotateTimeline) - applyRotateTimeline(timeline, skeleton, applyTime, mix, timelineBlend, current.timelinesRotation, ii << 1, firstFrame); + applyRotateTimeline(RotateTimeline(timeline), skeleton, applyTime, mix, timelineBlend, current.timelinesRotation, ii << 1, firstFrame); else if (timeline is AttachmentTimeline) applyAttachmentTimeline(AttachmentTimeline(timeline), skeleton, applyTime, timelineBlend, true); else @@ -248,8 +248,8 @@ package spine.animation { } var attachments : Boolean = mix < from.attachmentThreshold, drawOrder : Boolean = mix < from.drawOrderThreshold; - var timelineCount : int = from.animation.timelines.length; var timelines : Vector. = from.animation.timelines; + var timelineCount : int = timelines.length; var alphaHold : Number = from.alpha * to.interruptAlpha, alphaMix : Number = alphaHold * (1 - mix); var animationLast : Number = from.animationLast, animationTime : Number = from.getAnimationTime(), applyTime : Number = animationTime; var events : Vector. = null; @@ -340,7 +340,7 @@ package spine.animation { if (attachments) slot.attachmentState = unkeyedState + CURRENT; } - private function applyRotateTimeline(timeline : Timeline, skeleton : Skeleton, time : Number, alpha : Number, blend : MixBlend, timelinesRotation : Vector., i : int, firstFrame : Boolean) : void { + private function applyRotateTimeline(timeline : RotateTimeline, skeleton : Skeleton, time : Number, alpha : Number, blend : MixBlend, timelinesRotation : Vector., i : int, firstFrame : Boolean) : void { if (firstFrame) timelinesRotation[i] = 0; if (alpha == 1) { @@ -348,10 +348,9 @@ package spine.animation { return; } - var rotateTimeline : RotateTimeline = RotateTimeline(timeline); - var bone : Bone = skeleton.bones[rotateTimeline.getBoneIndex()]; + var bone : Bone = skeleton.bones[timeline.getBoneIndex()]; if (!bone.active) return; - var frames : Vector. = rotateTimeline.frames; + var frames : Vector. = timeline.frames; var r1 : Number, r2 : Number; if (time < frames[0]) { switch (blend) { @@ -365,7 +364,7 @@ package spine.animation { } } else { r1 = blend == MixBlend.setup ? bone.data.rotation : bone.rotation; - r2 = bone.data.rotation + rotateTimeline.getCurveValue(time); + r2 = bone.data.rotation + timeline.getCurveValue(time); } // Mix between rotations using the direction of the shortest route on the first frame while detecting crosses. @@ -558,7 +557,7 @@ package spine.animation { var entry : TrackEntry = addAnimation(trackIndex, emptyAnimation, false, delay <= 0 ? 1 : delay); entry.mixDuration = mixDuration; entry.trackEnd = mixDuration; - if (delay <= 0 && entry.previous != null) entry.delay = entry.previous.getTrackComplete() - entry.mixDuration; + if (delay <= 0 && entry.previous != null) entry.delay = entry.previous.getTrackComplete() - entry.mixDuration + delay; return entry; } @@ -622,18 +621,16 @@ package spine.animation { animationsChanged = false; propertyIDs.clear(); - var i : int = 0; - var n: int = 0; - var entry : TrackEntry = null; - for (i = 0, n = tracks.length; i < n; i++) { - entry = tracks[i]; - if (entry == null) continue; - while (entry.mixingFrom != null) + var tracks = this.tracks; + for (var i : int = 0, n : int = tracks.length; i < n; i++) { + var entry : TrackEntry = tracks[i]; + if (!entry) continue; + while (entry.mixingFrom) entry = entry.mixingFrom; do { - if (entry.mixingTo == null || entry.mixBlend != MixBlend.add) computeHold(entry); + if (!entry.mixingTo || entry.mixBlend != MixBlend.add) computeHold(entry); entry = entry.mixingTo; - } while (entry != null); + } while (entry); } } diff --git a/spine-as3/spine-as3/src/spine/animation/TrackEntry.as b/spine-as3/spine-as3/src/spine/animation/TrackEntry.as index 4545847ea..45d85545e 100644 --- a/spine-as3/spine-as3/src/spine/animation/TrackEntry.as +++ b/spine-as3/spine-as3/src/spine/animation/TrackEntry.as @@ -67,7 +67,7 @@ package spine.animation { /** If this track entry is non-looping, the track time in seconds when {@link #getAnimationEnd()} is reached, or the current * {@link #getTrackTime()} if it has already been reached. If this track entry is looping, the track time when this * animation will reach its next {@link #getAnimationEnd()} (the next loop completion). */ - public function getTrackComplete () : Number { + public function getTrackComplete() : Number { var duration : Number = animationEnd - animationStart; if (duration != 0) { if (loop) return duration * (1 + int(trackTime / duration)); // Completion of next loop. diff --git a/spine-c/spine-c/src/spine/AnimationState.c b/spine-c/spine-c/src/spine/AnimationState.c index 0a29f4037..183314402 100644 --- a/spine-c/spine-c/src/spine/AnimationState.c +++ b/spine-c/spine-c/src/spine/AnimationState.c @@ -838,7 +838,7 @@ spTrackEntry* spAnimationState_addEmptyAnimation(spAnimationState* self, int tra entry = spAnimationState_addAnimation(self, trackIndex, SP_EMPTY_ANIMATION, 0, delay <= 0 ? 1 : delay); entry->mixDuration = mixDuration; entry->trackEnd = mixDuration; - if (delay <= 0 && entry->previous != NULL) entry->delay = spTrackEntry_getTrackComplete(entry->previous) - entry->mixDuration; + if (delay <= 0 && entry->previous != NULL) entry->delay = spTrackEntry_getTrackComplete(entry->previous) - entry->mixDuration + delay; return entry; } diff --git a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp index 932803415..acd1d42b9 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp @@ -596,8 +596,8 @@ TrackEntry *AnimationState::addEmptyAnimation(size_t trackIndex, float mixDurati TrackEntry *entry = addAnimation(trackIndex, AnimationState::getEmptyAnimation(), false, delay <= 0 ? 1 : delay); entry->_mixDuration = mixDuration; entry->_trackEnd = mixDuration; - if (delay <= 0 && entry->_previous != NULL) entry->_delay = entry->_previous->getTrackComplete() - entry->_mixDuration; - return entry; + if (delay <= 0 && entry->_previous != NULL) entry->_delay = entry->_previous->getTrackComplete() - entry->_mixDuration + delay; + return entry; } void AnimationState::setEmptyAnimations(float mixDuration) { @@ -699,7 +699,7 @@ void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleto } } else { r1 = blend == MixBlend_Setup ? bone->_data._rotation : bone->_rotation; - r2 = bone->_data._rotation + rotateTimeline->getCurveValue(time); + r2 = bone->_data._rotation + rotateTimeline->getCurveValue(time); } // Mix between rotations using the direction of the shortest route on the first frame while detecting crosses. @@ -732,7 +732,7 @@ void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleto timelinesRotation[i] = total; } timelinesRotation[i + 1] = diff; - bone->_rotation = r1 + total * alpha; + bone->_rotation = r1 + total * alpha; } bool AnimationState::updateMixingFrom(TrackEntry *to, float delta) { diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index 28dad6769..8144543cc 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -323,7 +323,6 @@ namespace Spine { } } - /// /// Stores the segments for the specified Bezier curve. For timelines that modify multiple values, there may be more than /// one curve per frame. diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 809fc6c22..57d0d3740 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -366,7 +366,6 @@ namespace Spine { if (mix < from.eventThreshold) events = this.events; } - if (blend == MixBlend.Add) { for (int i = 0; i < timelineCount; i++) timelines[i].Apply(skeleton, animationLast, applyTime, events, alphaMix, blend, MixDirection.Out); @@ -661,7 +660,6 @@ namespace Spine { queue.Start(current); // triggers AnimationsChanged } - /// Sets an animation by name. public TrackEntry SetAnimation (int trackIndex, string animationName, bool loop) { Animation animation = data.skeletonData.FindAnimation(animationName); @@ -780,7 +778,7 @@ namespace Spine { TrackEntry entry = AddAnimation(trackIndex, AnimationState.EmptyAnimation, false, delay <= 0 ? 1 : delay); entry.mixDuration = mixDuration; entry.trackEnd = mixDuration; - if (delay <= 0 && entry.previous != null) entry.delay = entry.previous.TrackComplete - entry.mixDuration; + if (delay <= 0 && entry.previous != null) entry.delay = entry.previous.TrackComplete - entry.mixDuration + delay; return entry; } @@ -859,7 +857,6 @@ namespace Spine { if (entry == null) continue; while (entry.mixingFrom != null) // Move to last entry, then iterate in reverse. entry = entry.mixingFrom; - do { if (entry.mixingTo == null || entry.mixBlend != MixBlend.Add) ComputeHold(entry); entry = entry.mixingTo; @@ -867,8 +864,6 @@ namespace Spine { } } - - private void ComputeHold (TrackEntry entry) { TrackEntry to = entry.mixingTo; Timeline[] timelines = entry.animation.timelines.Items; diff --git a/spine-csharp/src/ExposedList.cs b/spine-csharp/src/ExposedList.cs index 55e00eabd..977523cad 100644 --- a/spine-csharp/src/ExposedList.cs +++ b/spine-csharp/src/ExposedList.cs @@ -219,8 +219,6 @@ namespace Spine { Array.Copy(Items, index, array, arrayIndex, count); } - - public bool Exists (Predicate match) { CheckMatch(match); return GetIndex(0, Count, match) != -1; diff --git a/spine-csharp/src/SkeletonBinary.cs b/spine-csharp/src/SkeletonBinary.cs index 68fb34356..e551fbc63 100644 --- a/spine-csharp/src/SkeletonBinary.cs +++ b/spine-csharp/src/SkeletonBinary.cs @@ -325,7 +325,6 @@ namespace Spine { return skeletonData; } - /// May be null. private Skin ReadSkin (SkeletonInput input, SkeletonData skeletonData, bool defaultSkin, bool nonessential) { diff --git a/spine-csharp/src/SkeletonBounds.cs b/spine-csharp/src/SkeletonBounds.cs index 191548147..b2ebdf435 100644 --- a/spine-csharp/src/SkeletonBounds.cs +++ b/spine-csharp/src/SkeletonBounds.cs @@ -125,7 +125,6 @@ namespace Spine { this.maxY = maxY; } - /// Returns true if the axis aligned bounding box contains the point. public bool AabbContainsPoint (float x, float y) { return x >= minX && x <= maxX && y >= minY && y <= maxY; 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 457536d76..59ebe927f 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -381,12 +381,11 @@ public class AnimationState { Slot slot = skeleton.slots.get(timeline.slotIndex); if (!slot.bone.active) return; - float[] frames = timeline.frames; - if (time < frames[0]) { // Time is before first frame. + if (time < timeline.frames[0]) { // Time is before first frame. if (blend == MixBlend.setup || blend == MixBlend.first) setAttachment(skeleton, slot, slot.data.attachmentName, attachments); } else - setAttachment(skeleton, slot, timeline.attachmentNames[Timeline.search(frames, time)], attachments); + setAttachment(skeleton, slot, timeline.attachmentNames[Timeline.search(timeline.frames, time)], attachments); // If an attachment wasn't set (ie before the first frame or attachments is false), set the setup attachment later. if (slot.attachmentState <= unkeyedState) slot.attachmentState = unkeyedState + SETUP; @@ -675,7 +674,7 @@ public class AnimationState { TrackEntry entry = addAnimation(trackIndex, emptyAnimation, false, delay <= 0 ? 1 : delay); entry.mixDuration = mixDuration; entry.trackEnd = mixDuration; - if (delay <= 0 && entry.previous != null) entry.delay = entry.previous.getTrackComplete() - entry.mixDuration; + if (delay <= 0 && entry.previous != null) entry.delay = entry.previous.getTrackComplete() - entry.mixDuration + delay; return entry; } diff --git a/spine-ts/core/src/AnimationState.ts b/spine-ts/core/src/AnimationState.ts index f7f640741..c8d43b09c 100644 --- a/spine-ts/core/src/AnimationState.ts +++ b/spine-ts/core/src/AnimationState.ts @@ -180,8 +180,8 @@ module spine { applyTime = current.animation.duration - applyTime; applyEvents = null; } - let timelineCount = current.animation.timelines.length; let timelines = current.animation.timelines; + let timelineCount = timelines.length; if ((i == 0 && mix == 1) || blend == MixBlend.add) { for (let ii = 0; ii < timelineCount; ii++) { // Fixes issue #302 on IOS9 where mix, blend sometimes became undefined and caused assets @@ -253,8 +253,8 @@ module spine { } let attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; - let timelineCount = from.animation.timelines.length; let timelines = from.animation.timelines; + let timelineCount = timelines.length; let alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix); let animationLast = from.animationLast, animationTime = from.getAnimationTime(), applyTime = animationTime; let events = null; @@ -331,12 +331,11 @@ module spine { var slot = skeleton.slots[timeline.slotIndex]; if (!slot.bone.active) return; - var frames = timeline.frames; - if (time < frames[0]) { // Time is before first frame. + if (time < timeline.frames[0]) { // Time is before first frame. if (blend == MixBlend.setup || blend == MixBlend.first) this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments); } else - this.setAttachment(skeleton, slot, timeline.attachmentNames[Timeline.search1(frames, time)], attachments); + this.setAttachment(skeleton, slot, timeline.attachmentNames[Timeline.search1(timeline.frames, time)], attachments); // If an attachment wasn't set (ie before the first frame or attachments is false), set the setup attachment later. if (slot.attachmentState <= this.unkeyedState) slot.attachmentState = this.unkeyedState + SETUP; @@ -347,7 +346,7 @@ module spine { if (attachments) slot.attachmentState = this.unkeyedState + CURRENT; } - applyRotateTimeline (timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, + applyRotateTimeline (timeline: RotateTimeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array, i: number, firstFrame: boolean) { if (firstFrame) timelinesRotation[i] = 0; @@ -357,10 +356,9 @@ module spine { return; } - let rotateTimeline = timeline as RotateTimeline; - let bone = skeleton.bones[rotateTimeline.boneIndex]; + let bone = skeleton.bones[timeline.boneIndex]; if (!bone.active) return; - let frames = rotateTimeline.frames; + let frames = timeline.frames; let r1 = 0, r2 = 0; if (time < frames[0]) { switch (blend) { @@ -374,7 +372,7 @@ module spine { } } else { r1 = blend == MixBlend.setup ? bone.data.rotation : bone.rotation; - r2 = bone.data.rotation + rotateTimeline.getCurveValue(time); + r2 = bone.data.rotation + timeline.getCurveValue(time); } // Mix between rotations using the direction of the shortest route on the first frame while detecting crosses. @@ -619,7 +617,7 @@ module spine { let entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation(), false, delay <= 0 ? 1 : delay); entry.mixDuration = mixDuration; entry.trackEnd = mixDuration; - if (delay <= 0 && entry.previous) entry.delay = entry.previous.getTrackComplete() - entry.mixDuration; + if (delay <= 0 && entry.previous) entry.delay = entry.previous.getTrackComplete() - entry.mixDuration + delay; return entry; } @@ -688,17 +686,16 @@ module spine { this.animationsChanged = false; this.propertyIDs.clear(); - - for (let i = 0, n = this.tracks.length; i < n; i++) { - let entry = this.tracks[i]; + let tracks = this.tracks; + for (let i = 0, n = tracks.length; i < n; i++) { + let entry = tracks[i]; if (!entry) continue; while (entry.mixingFrom) entry = entry.mixingFrom; - do { - if (!entry.mixingFrom || entry.mixBlend != MixBlend.add) this.computeHold(entry); + if (!entry.mixingTo || entry.mixBlend != MixBlend.add) this.computeHold(entry); entry = entry.mixingTo; - } while (entry) + } while (entry); } } diff --git a/spine-ts/core/src/IkConstraint.ts b/spine-ts/core/src/IkConstraint.ts index b931d3fa5..d4d2e0b74 100644 --- a/spine-ts/core/src/IkConstraint.ts +++ b/spine-ts/core/src/IkConstraint.ts @@ -123,7 +123,8 @@ module spine { if (bone.ascaleX < 0) rotationIK += 180; if (rotationIK > 180) rotationIK -= 360; - else if (rotationIK < -180) rotationIK += 360; + else if (rotationIK < -180) + rotationIK += 360; let sx = bone.ascaleX, sy = bone.ascaleY; if (compress || stretch) { switch (bone.data.transformMode) { @@ -272,13 +273,15 @@ module spine { a1 = (a1 - os) * MathUtils.radDeg + os1 - rotation; if (a1 > 180) a1 -= 360; - else if (a1 < -180) a1 += 360; + else if (a1 < -180) // + a1 += 360; parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0); rotation = child.arotation; a2 = ((a2 + os) * MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation; if (a2 > 180) a2 -= 360; - else if (a2 < -180) a2 += 360; + else if (a2 < -180) // + a2 += 360; child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY); } } diff --git a/spine-ts/core/src/PathConstraint.ts b/spine-ts/core/src/PathConstraint.ts index 0d9cec2dd..ae83f1dcf 100644 --- a/spine-ts/core/src/PathConstraint.ts +++ b/spine-ts/core/src/PathConstraint.ts @@ -93,8 +93,8 @@ module spine { let data = this.data; let tangents = data.rotateMode == RotateMode.Tangent, scale = data.rotateMode == RotateMode.ChainScale; - let boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1; let bones = this.bones; + let boneCount = bones.length, spacesCount = tangents ? boneCount : boneCount + 1; let spaces = Utils.setArraySize(this.spaces, spacesCount), lengths: Array = scale ? this.lengths = Utils.setArraySize(this.lengths, boneCount) : null; let spacing = this.spacing; @@ -342,7 +342,7 @@ module spine { if (this.data.positionMode == PositionMode.Percent) position *= pathLength; - let multiplier = 0; + let multiplier; switch (this.data.spacingMode) { case SpacingMode.Percent: multiplier = pathLength; diff --git a/spine-ts/core/src/TextureAtlas.ts b/spine-ts/core/src/TextureAtlas.ts index 1d09f4674..21712775b 100644 --- a/spine-ts/core/src/TextureAtlas.ts +++ b/spine-ts/core/src/TextureAtlas.ts @@ -255,7 +255,6 @@ module spine { x: number; y: number; index: number; - rotate: boolean; degrees: number; texture: Texture; names: string[];