From 700d2897a8ac6ffb7bf80eae83797318bdbfa32f Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Fri, 4 Jun 2021 22:15:58 -0400 Subject: [PATCH] Various clean up. --- .../src/spine/animation/AlphaTimeline.as | 4 +- .../src/spine/animation/Animation.as | 8 +- .../src/spine/animation/AnimationState.as | 2 +- .../src/spine/animation/AttachmentTimeline.as | 2 +- .../src/spine/animation/CurveTimeline1.as | 4 +- .../src/spine/animation/CurveTimeline2.as | 4 +- .../src/spine/animation/DeformTimeline.as | 2 +- .../src/spine/animation/DrawOrderTimeline.as | 2 +- .../src/spine/animation/EventTimeline.as | 2 +- .../spine/animation/IkConstraintTimeline.as | 2 +- .../animation/PathConstraintMixTimeline.as | 2 +- .../PathConstraintPositionTimeline.as | 4 +- .../PathConstraintSpacingTimeline.as | 4 +- .../src/spine/animation/RGB2Timeline.as | 2 +- .../src/spine/animation/RGBA2Timeline.as | 2 +- .../src/spine/animation/RGBATimeline.as | 6 +- .../src/spine/animation/RGBTimeline.as | 2 +- .../src/spine/animation/RotateTimeline.as | 4 +- .../src/spine/animation/ScaleTimeline.as | 6 +- .../src/spine/animation/ScaleXTimeline.as | 4 +- .../src/spine/animation/ScaleYTimeline.as | 4 +- .../src/spine/animation/ShearTimeline.as | 6 +- .../src/spine/animation/ShearXTimeline.as | 4 +- .../src/spine/animation/ShearYTimeline.as | 4 +- .../spine-as3/src/spine/animation/Timeline.as | 8 +- .../animation/TransformConstraintTimeline.as | 2 +- .../src/spine/animation/TranslateTimeline.as | 6 +- .../src/spine/animation/TranslateXTimeline.as | 4 +- .../src/spine/animation/TranslateYTimeline.as | 4 +- spine-c/spine-c/src/spine/Animation.c | 11 +- spine-csharp/src/Animation.cs | 137 +++++++++--------- .../com/esotericsoftware/spine/Animation.java | 18 ++- spine-ts/core/src/Animation.ts | 113 +++++++-------- spine-ts/core/src/AnimationState.ts | 2 +- 34 files changed, 179 insertions(+), 212 deletions(-) diff --git a/spine-as3/spine-as3/src/spine/animation/AlphaTimeline.as b/spine-as3/spine-as3/src/spine/animation/AlphaTimeline.as index 539aab8bd..1c671449a 100644 --- a/spine-as3/spine-as3/src/spine/animation/AlphaTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/AlphaTimeline.as @@ -42,9 +42,7 @@ package spine.animation { private var slotIndex : int; public function AlphaTimeline (frameCount : Number, bezierCount : Number, slotIndex : Number) { - super(frameCount, bezierCount, [ - Property.alpha + "|" + slotIndex - ]); + super(frameCount, bezierCount, Property.alpha + "|" + slotIndex); this.slotIndex = slotIndex; } diff --git a/spine-as3/spine-as3/src/spine/animation/Animation.as b/spine-as3/spine-as3/src/spine/animation/Animation.as index 03b1b0e17..ce367160d 100644 --- a/spine-as3/spine-as3/src/spine/animation/Animation.as +++ b/spine-as3/spine-as3/src/spine/animation/Animation.as @@ -40,15 +40,19 @@ package spine.animation { public function Animation(name : String, timelines : Vector., duration : Number) { if (name == null) throw new ArgumentError("name cannot be null."); - if (timelines == null) throw new ArgumentError("timelines cannot be null."); _name = name; + setTimelines(timelines); + this.duration = duration; + } + + public function setTimelines(timelines : Vector.) : void { + if (timelines == null) throw new ArgumentError("timelines cannot be null."); _timelines = timelines; for (var i : int = 0, n : int = timelines.length; i < n; i++) { var ids : Vector. = timelines[i].propertyIds; for (var ii : int = 0, nn : int = ids.length; ii < nn; ii++) _timelineIds[ids[ii]] = true; } - this.duration = duration; } public function hasTimeline(ids : Vector.) : Boolean { diff --git a/spine-as3/spine-as3/src/spine/animation/AnimationState.as b/spine-as3/spine-as3/src/spine/animation/AnimationState.as index 3be009a56..8f1b776f9 100644 --- a/spine-as3/spine-as3/src/spine/animation/AnimationState.as +++ b/spine-as3/spine-as3/src/spine/animation/AnimationState.as @@ -329,7 +329,7 @@ package spine.animation { 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.search1(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; diff --git a/spine-as3/spine-as3/src/spine/animation/AttachmentTimeline.as b/spine-as3/spine-as3/src/spine/animation/AttachmentTimeline.as index 10ae6b4c9..5bf9de8d7 100644 --- a/spine-as3/spine-as3/src/spine/animation/AttachmentTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/AttachmentTimeline.as @@ -74,7 +74,7 @@ package spine.animation { return; } - setAttachment(skeleton, slot, attachmentNames[search(frames, time)]); + setAttachment(skeleton, slot, attachmentNames[search1(frames, time)]); } private function setAttachment(skeleton : Skeleton, slot : Slot, attachmentName : String) : void { diff --git a/spine-as3/spine-as3/src/spine/animation/CurveTimeline1.as b/spine-as3/spine-as3/src/spine/animation/CurveTimeline1.as index 3638715ba..083258687 100644 --- a/spine-as3/spine-as3/src/spine/animation/CurveTimeline1.as +++ b/spine-as3/spine-as3/src/spine/animation/CurveTimeline1.as @@ -35,8 +35,8 @@ package spine.animation { /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}. * @param propertyIds Unique identifiers for the properties the timeline modifies. */ - public function CurveTimeline1 (frameCount : int, bezierCount : int, propertyIds : Array) { - super(frameCount, bezierCount, propertyIds); + public function CurveTimeline1 (frameCount : int, bezierCount : int, propertyId : string) { + super(frameCount, bezierCount, [ propertyId ]); } public override function getFrameEntries() : int { diff --git a/spine-as3/spine-as3/src/spine/animation/CurveTimeline2.as b/spine-as3/spine-as3/src/spine/animation/CurveTimeline2.as index 7a4c086ad..e729c17e7 100644 --- a/spine-as3/spine-as3/src/spine/animation/CurveTimeline2.as +++ b/spine-as3/spine-as3/src/spine/animation/CurveTimeline2.as @@ -36,8 +36,8 @@ package spine.animation { /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}. * @param propertyIds Unique identifiers for the properties the timeline modifies. */ - public function CurveTimeline2 (frameCount : int, bezierCount : int, propertyIds : Array) { - super(frameCount, bezierCount, propertyIds); + public function CurveTimeline2 (frameCount : int, bezierCount : int, propertyId1 : String, propertyId2 : String) { + super(frameCount, bezierCount, [ propertyId1, propertyId2 ]); } public override function getFrameEntries() : int { diff --git a/spine-as3/spine-as3/src/spine/animation/DeformTimeline.as b/spine-as3/spine-as3/src/spine/animation/DeformTimeline.as index 42456ff10..29371c37e 100644 --- a/spine-as3/spine-as3/src/spine/animation/DeformTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/DeformTimeline.as @@ -222,7 +222,7 @@ package spine.animation { } // Interpolate between the previous frame and the current frame. - var frame : int = search(frames, time); + var frame : int = search1(frames, time); var percent : Number = getCurvePercent(time, frame); var prevVertices : Vector. = vertices[frame], prev : Number; var nextVertices : Vector. = vertices[frame + 1]; diff --git a/spine-as3/spine-as3/src/spine/animation/DrawOrderTimeline.as b/spine-as3/spine-as3/src/spine/animation/DrawOrderTimeline.as index 707a9b9a5..49139eb77 100644 --- a/spine-as3/spine-as3/src/spine/animation/DrawOrderTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/DrawOrderTimeline.as @@ -75,7 +75,7 @@ package spine.animation { return; } - var drawOrderToSetupIndex : Vector. = drawOrders[search(frames, time)]; + var drawOrderToSetupIndex : Vector. = drawOrders[search1(frames, time)]; if (drawOrderToSetupIndex == null) { for (i = 0; i < n; i++) drawOrder[i] = slots[i]; diff --git a/spine-as3/spine-as3/src/spine/animation/EventTimeline.as b/spine-as3/spine-as3/src/spine/animation/EventTimeline.as index d2a9633f7..78947e5e7 100644 --- a/spine-as3/spine-as3/src/spine/animation/EventTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/EventTimeline.as @@ -69,7 +69,7 @@ package spine.animation { if (lastTime < frames[0]) i = 0; else { - i = search(frames, lastTime) + 1; + i = search1(frames, lastTime) + 1; var frameTime : Number = frames[i]; while (i > 0) { // Fire multiple events with the same frame. if (frames[i - 1] != frameTime) break; diff --git a/spine-as3/spine-as3/src/spine/animation/IkConstraintTimeline.as b/spine-as3/spine-as3/src/spine/animation/IkConstraintTimeline.as index 4635459c9..2008a4ccf 100644 --- a/spine-as3/spine-as3/src/spine/animation/IkConstraintTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/IkConstraintTimeline.as @@ -86,7 +86,7 @@ package spine.animation { } var mix : Number = 0, softness : Number = 0; - var i : int = search2(frames, time, ENTRIES) + var i : int = search(frames, time, ENTRIES) var curveType : Number = curves[i / ENTRIES]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/PathConstraintMixTimeline.as b/spine-as3/spine-as3/src/spine/animation/PathConstraintMixTimeline.as index 0fa85d470..b4dee1595 100644 --- a/spine-as3/spine-as3/src/spine/animation/PathConstraintMixTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/PathConstraintMixTimeline.as @@ -83,7 +83,7 @@ package spine.animation { } var rotate : Number, x : Number, y : Number; - var i : int = search2(frames, time, ENTRIES); + var i : int = search(frames, time, ENTRIES); var curveType : Number = curves[i >> 2]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/PathConstraintPositionTimeline.as b/spine-as3/spine-as3/src/spine/animation/PathConstraintPositionTimeline.as index dc54a2a79..411460424 100644 --- a/spine-as3/spine-as3/src/spine/animation/PathConstraintPositionTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/PathConstraintPositionTimeline.as @@ -37,9 +37,7 @@ package spine.animation { public var pathConstraintIndex : int; public function PathConstraintPositionTimeline (frameCount : int, bezierCount : int, pathConstraintIndex : int) { - super(frameCount, bezierCount, [ - Property.pathConstraintPosition + "|" + pathConstraintIndex - ]); + super(frameCount, bezierCount, Property.pathConstraintPosition + "|" + pathConstraintIndex); this.pathConstraintIndex = pathConstraintIndex; } diff --git a/spine-as3/spine-as3/src/spine/animation/PathConstraintSpacingTimeline.as b/spine-as3/spine-as3/src/spine/animation/PathConstraintSpacingTimeline.as index c96120563..cbf011dcb 100644 --- a/spine-as3/spine-as3/src/spine/animation/PathConstraintSpacingTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/PathConstraintSpacingTimeline.as @@ -37,9 +37,7 @@ package spine.animation { public var pathConstraintIndex : int; public function PathConstraintSpacingTimeline (frameCount : int, bezierCount : int, pathConstraintIndex : int) { - super(frameCount, bezierCount, [ - Property.pathConstraintSpacing + "|" + pathConstraintIndex - ]); + super(frameCount, bezierCount, Property.pathConstraintSpacing + "|" + pathConstraintIndex); this.pathConstraintIndex = pathConstraintIndex; } diff --git a/spine-as3/spine-as3/src/spine/animation/RGB2Timeline.as b/spine-as3/spine-as3/src/spine/animation/RGB2Timeline.as index 753ade0a5..ccb65878f 100644 --- a/spine-as3/spine-as3/src/spine/animation/RGB2Timeline.as +++ b/spine-as3/spine-as3/src/spine/animation/RGB2Timeline.as @@ -103,7 +103,7 @@ package spine.animation { } var r : Number = 0, g : Number = 0, b : Number = 0, a : Number = 0, r2 : Number = 0, g2 : Number = 0, b2 : Number = 0; - var i : int = search2(frames, time, ENTRIES); + var i : int = search(frames, time, ENTRIES); var curveType : Number = curves[i / ENTRIES]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/RGBA2Timeline.as b/spine-as3/spine-as3/src/spine/animation/RGBA2Timeline.as index 5261d4fc6..b1b2ce14b 100644 --- a/spine-as3/spine-as3/src/spine/animation/RGBA2Timeline.as +++ b/spine-as3/spine-as3/src/spine/animation/RGBA2Timeline.as @@ -101,7 +101,7 @@ package spine.animation { } var r : Number = 0, g : Number = 0, b : Number = 0, a : Number = 0, r2 : Number = 0, g2 : Number = 0, b2 : Number = 0; - var i : int = search2(frames, time, ENTRIES); + var i : int = search(frames, time, ENTRIES); var curveType : Number = curves[i >> 3]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/RGBATimeline.as b/spine-as3/spine-as3/src/spine/animation/RGBATimeline.as index f82088c8e..646a2e08a 100644 --- a/spine-as3/spine-as3/src/spine/animation/RGBATimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/RGBATimeline.as @@ -75,10 +75,10 @@ package spine.animation { var frames : Vector. = this.frames; var color : Color = slot.color; if (time < frames[0]) { - var setup : Color = slot.data.color; + var setup : Color = slot.data.color; switch (blend) { case MixBlend.setup: - color.setFromColor(slot.data.color); + color.setFromColor(setup); return; case MixBlend.first: color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, @@ -88,7 +88,7 @@ package spine.animation { } var r : Number = 0, g : Number = 0, b : Number = 0, a : Number = 0; - var i : int = search2(frames, time, ENTRIES); + var i : int = search(frames, time, ENTRIES); var curveType : Number = curves[i / ENTRIES]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/RGBTimeline.as b/spine-as3/spine-as3/src/spine/animation/RGBTimeline.as index db900756d..ef945545b 100644 --- a/spine-as3/spine-as3/src/spine/animation/RGBTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/RGBTimeline.as @@ -88,7 +88,7 @@ package spine.animation { } var r : Number = 0, g : Number = 0, b : Number = 0; - var i : int = search2(frames, time, ENTRIES); + var i : int = search(frames, time, ENTRIES); var curveType : Number = curves[i / ENTRIES]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/RotateTimeline.as b/spine-as3/spine-as3/src/spine/animation/RotateTimeline.as index efa63aa8e..b49cc00fc 100644 --- a/spine-as3/spine-as3/src/spine/animation/RotateTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/RotateTimeline.as @@ -36,9 +36,7 @@ package spine.animation { private var boneIndex : int; public function RotateTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ - Property.rotate + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.rotate + "|" + boneIndex); this.boneIndex = boneIndex; } diff --git a/spine-as3/spine-as3/src/spine/animation/ScaleTimeline.as b/spine-as3/spine-as3/src/spine/animation/ScaleTimeline.as index da054f8cb..904d9dc0b 100644 --- a/spine-as3/spine-as3/src/spine/animation/ScaleTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/ScaleTimeline.as @@ -37,10 +37,10 @@ package spine.animation { private var boneIndex : int; public function ScaleTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ + super(frameCount, bezierCount, Property.scaleX + "|" + boneIndex, Property.scaleY + "|" + boneIndex - ]); + ); this.boneIndex = boneIndex; } @@ -67,7 +67,7 @@ package spine.animation { } var x : Number = 0, y : Number = 0; - var i : int = search2(frames, time, ENTRIES); + var i : int = search(frames, time, ENTRIES); var curveType : Number = curves[i / ENTRIES]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/ScaleXTimeline.as b/spine-as3/spine-as3/src/spine/animation/ScaleXTimeline.as index 6661406fc..8a4f7fdf5 100644 --- a/spine-as3/spine-as3/src/spine/animation/ScaleXTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/ScaleXTimeline.as @@ -37,9 +37,7 @@ package spine.animation { private var boneIndex : int; public function ScaleXTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ - Property.scaleX + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.scaleX + "|" + boneIndex); this.boneIndex = boneIndex; } diff --git a/spine-as3/spine-as3/src/spine/animation/ScaleYTimeline.as b/spine-as3/spine-as3/src/spine/animation/ScaleYTimeline.as index d4ddb4758..eacec4061 100644 --- a/spine-as3/spine-as3/src/spine/animation/ScaleYTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/ScaleYTimeline.as @@ -37,9 +37,7 @@ package spine.animation { private var boneIndex : int; public function ScaleYTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ - Property.scaleY + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.scaleY + "|" + boneIndex); this.boneIndex = boneIndex; } diff --git a/spine-as3/spine-as3/src/spine/animation/ShearTimeline.as b/spine-as3/spine-as3/src/spine/animation/ShearTimeline.as index 2ef20b21f..dfa6dd4da 100644 --- a/spine-as3/spine-as3/src/spine/animation/ShearTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/ShearTimeline.as @@ -36,10 +36,10 @@ package spine.animation { private var boneIndex : int; public function ShearTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ + super(frameCount, bezierCount, Property.shearX + "|" + boneIndex, Property.shearY + "|" + boneIndex - ]); + ); this.boneIndex = boneIndex; } @@ -66,7 +66,7 @@ package spine.animation { } var x : Number = 0, y : Number = 0; - var i : int = search2(frames, time, ENTRIES); + var i : int = search(frames, time, ENTRIES); var curveType : Number = curves[i / ENTRIES]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/ShearXTimeline.as b/spine-as3/spine-as3/src/spine/animation/ShearXTimeline.as index 5c0b2c865..621b9f31f 100644 --- a/spine-as3/spine-as3/src/spine/animation/ShearXTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/ShearXTimeline.as @@ -36,9 +36,7 @@ package spine.animation { private var boneIndex : int; public function ShearXTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ - Property.shearX + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.shearX + "|" + boneIndex); this.boneIndex = boneIndex; } diff --git a/spine-as3/spine-as3/src/spine/animation/ShearYTimeline.as b/spine-as3/spine-as3/src/spine/animation/ShearYTimeline.as index 7437e83ce..79eaa5fdc 100644 --- a/spine-as3/spine-as3/src/spine/animation/ShearYTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/ShearYTimeline.as @@ -36,9 +36,7 @@ package spine.animation { private var boneIndex : int; public function ShearYTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ - Property.shearY + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.shearY + "|" + boneIndex); this.boneIndex = boneIndex; } diff --git a/spine-as3/spine-as3/src/spine/animation/Timeline.as b/spine-as3/spine-as3/src/spine/animation/Timeline.as index f5ee23d78..e530c8b21 100644 --- a/spine-as3/spine-as3/src/spine/animation/Timeline.as +++ b/spine-as3/spine-as3/src/spine/animation/Timeline.as @@ -57,17 +57,17 @@ package spine.animation { public function apply (skeleton: Skeleton, lastTime: Number, time: Number, events: Vector., alpha: Number, blend: MixBlend, direction: MixDirection) : void { } - static internal function search (frames : Vector., time : Number) : int { + static internal function search1 (frames : Vector., time : Number) : int { var n : int = frames.length; for (var i : int = 1; i < n; i++) if (frames[i] > time) return i - 1; return n - 1; } - static internal function search2 (values : Vector., time : Number, step: int) : int { - var n : int = values.length; + static internal function search (frames : Vector., time : Number, step: int) : int { + var n : int = frames.length; for (var i : int = step; i < n; i += step) - if (values[i] > time) return i - step; + if (frames[i] > time) return i - step; return n - step; } } diff --git a/spine-as3/spine-as3/src/spine/animation/TransformConstraintTimeline.as b/spine-as3/spine-as3/src/spine/animation/TransformConstraintTimeline.as index 67a796fc0..34632a51b 100644 --- a/spine-as3/spine-as3/src/spine/animation/TransformConstraintTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/TransformConstraintTimeline.as @@ -93,7 +93,7 @@ package spine.animation { } var rotate : Number, x : Number, y : Number, scaleX : Number, scaleY : Number, shearY : Number; - var i : int = search2(frames, time, ENTRIES); + var i : int = search(frames, time, ENTRIES); var curveType : Number = curves[i / ENTRIES]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/TranslateTimeline.as b/spine-as3/spine-as3/src/spine/animation/TranslateTimeline.as index 3b2ef61be..a1773849c 100644 --- a/spine-as3/spine-as3/src/spine/animation/TranslateTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/TranslateTimeline.as @@ -36,10 +36,10 @@ package spine.animation { private var boneIndex : int; public function TranslateTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ + super(frameCount, bezierCount, Property.x + "|" + boneIndex, Property.y + "|" + boneIndex - ]); + ); this.boneIndex = boneIndex; } @@ -66,7 +66,7 @@ package spine.animation { } var x : Number = 0, y : Number = 0; - var i : int = search2(frames, time, ENTRIES); + var i : int = search(frames, time, ENTRIES); var curveType : Number = curves[i / ENTRIES]; switch (curveType) { case LINEAR: diff --git a/spine-as3/spine-as3/src/spine/animation/TranslateXTimeline.as b/spine-as3/spine-as3/src/spine/animation/TranslateXTimeline.as index 6fdcc7457..01e426f71 100644 --- a/spine-as3/spine-as3/src/spine/animation/TranslateXTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/TranslateXTimeline.as @@ -36,9 +36,7 @@ package spine.animation { private var boneIndex : int; public function TranslateXTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ - Property.x + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.x + "|" + boneIndex); this.boneIndex = boneIndex; } diff --git a/spine-as3/spine-as3/src/spine/animation/TranslateYTimeline.as b/spine-as3/spine-as3/src/spine/animation/TranslateYTimeline.as index f2d44e957..d960f3c56 100644 --- a/spine-as3/spine-as3/src/spine/animation/TranslateYTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/TranslateYTimeline.as @@ -36,9 +36,7 @@ package spine.animation { private var boneIndex : int; public function TranslateYTimeline(frameCount : int, bezierCount : int, boneIndex : int) { - super(frameCount, bezierCount, [ - Property.y + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.y + "|" + boneIndex); this.boneIndex = boneIndex; } diff --git a/spine-c/spine-c/src/spine/Animation.c b/spine-c/spine-c/src/spine/Animation.c index a333bc80e..8812925fd 100644 --- a/spine-c/spine-c/src/spine/Animation.c +++ b/spine-c/spine-c/src/spine/Animation.c @@ -60,9 +60,9 @@ void spAnimation_dispose (spAnimation* self) { } int /*bool*/ spAnimation_hasTimeline(spAnimation* self, spPropertyId* ids, int idsCount) { - int i, n, ii, nn; + int i, n, ii; for (i = 0, n = self->timelineIds->size; i < n; i++) { - for (ii = 0, nn = idsCount; ii < nn; ii++) { + for (ii = 0; ii < idsCount; ii++) { if (self->timelineIds->items[i] == ids[ii]) return 1; } } @@ -111,13 +111,13 @@ void _spTimeline_init (spTimeline* self, void (*setBezier) (spTimeline* self, int bezier, int frame, float value, float time1, float value1, float cx1, float cy1, float cx2, float cy2, float time2, float value2) ) { - int i, n; + int i; self->frames = spFloatArray_create(frameCount * frameEntries); self->frames->size = frameCount * frameEntries; self->frameCount = frameCount; self->frameEntries = frameEntries; - for (i = 0, n = propertyIdsCount; i < n; i++) + for (i = 0; i < propertyIdsCount; i++) self->propertyIds[i] = propertyIds[i]; self->propertyIdsCount = propertyIdsCount; @@ -1434,7 +1434,6 @@ void spRGBA2Timeline_setFrame (spRGBA2Timeline* self, int frame, float time, flo static const int RGB2_ENTRIES = 7, COLOR2_R2 = 5, COLOR2_G2 = 6, COLOR2_B2 = 7; - void _spRGB2Timeline_apply (spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction ) { @@ -1521,6 +1520,7 @@ void _spRGB2Timeline_apply (spTimeline* timeline, spSkeleton* skeleton, float la } else { if (blend == SP_MIX_BLEND_SETUP) { spColor_setFromColor3(light, &slot->data->color); + spColor_setFromColor3(dark, slot->data->darkColor); } spColor_addFloats3(light, (r - light->r) * alpha, (g - light->g) * alpha, (b - light->b) * alpha); @@ -1930,7 +1930,6 @@ void spDeformTimeline_setFrame (spDeformTimeline* self, int frame, float time, f } } - /**/ /** Fires events for frames > lastTime and <= time. */ diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index 1636a47a0..28dad6769 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -395,8 +395,8 @@ namespace Spine { /// The maximum number of Bezier curves. See . /// Unique identifiers for the properties the timeline modifies. - public CurveTimeline1 (int frameCount, int bezierCount, params string[] propertyIds) - : base(frameCount, bezierCount, propertyIds) { + public CurveTimeline1 (int frameCount, int bezierCount, string propertyId) + : base(frameCount, bezierCount, propertyId) { } public override int FrameEntries { @@ -442,8 +442,8 @@ namespace Spine { /// The maximum number of Bezier curves. See . /// Unique identifiers for the properties the timeline modifies. - public CurveTimeline2 (int frameCount, int bezierCount, params string[] propertyIds) - :base (frameCount, bezierCount, propertyIds) { + public CurveTimeline2 (int frameCount, int bezierCount, string propertyId1, string propertyId2) + :base (frameCount, bezierCount, propertyId1, propertyId2) { } public override int FrameEntries { @@ -1230,7 +1230,6 @@ namespace Spine { slot.g = g; slot.b = b; slot.a = a; - slot.ClampColor(); } else { float br, bg, bb, ba; if (blend == MixBlend.Setup) { @@ -1244,12 +1243,12 @@ namespace Spine { bb = slot.b; ba = slot.a; } - slot.r = br + ((r - br) * alpha); - slot.g = bg + ((g - bg) * alpha); - slot.b = bb + ((b - bb) * alpha); - slot.a = ba + ((a - ba) * alpha); - slot.ClampColor(); + slot.r = br + (r - br) * alpha; + slot.g = bg + (g - bg) * alpha; + slot.b = bb + (b - bb) * alpha; + slot.a = ba + (a - ba) * alpha; } + slot.ClampColor(); } } @@ -1340,7 +1339,6 @@ namespace Spine { slot.r = r; slot.g = g; slot.b = b; - slot.ClampColor(); } else { float br, bg, bb; if (blend == MixBlend.Setup) { @@ -1353,11 +1351,11 @@ namespace Spine { bg = slot.g; bb = slot.b; } - slot.r = br + ((r - br) * alpha); - slot.g = bg + ((g - bg) * alpha); - slot.b = bb + ((b - bb) * alpha); - slot.ClampColor(); + slot.r = br + (r - br) * alpha; + slot.g = bg + (g - bg) * alpha; + slot.b = bb + (b - bb) * alpha; } + slot.ClampColor(); } } @@ -1459,28 +1457,28 @@ namespace Spine { float[] frames = this.frames; if (time < frames[0]) { // Time is before first frame. - var slotData = slot.data; + SlotData setup = slot.data; switch (blend) { case MixBlend.Setup: - slot.r = slotData.r; - slot.g = slotData.g; - slot.b = slotData.b; - slot.a = slotData.a; + slot.r = setup.r; + slot.g = setup.g; + slot.b = setup.b; + slot.a = setup.a; slot.ClampColor(); - slot.r2 = slotData.r2; - slot.g2 = slotData.g2; - slot.b2 = slotData.b2; + slot.r2 = setup.r2; + slot.g2 = setup.g2; + slot.b2 = setup.b2; slot.ClampSecondColor(); return; case MixBlend.First: - slot.r += (slot.r - slotData.r) * alpha; - slot.g += (slot.g - slotData.g) * alpha; - slot.b += (slot.b - slotData.b) * alpha; - slot.a += (slot.a - slotData.a) * alpha; + slot.r += (slot.r - setup.r) * alpha; + slot.g += (slot.g - setup.g) * alpha; + slot.b += (slot.b - setup.b) * alpha; + slot.a += (slot.a - setup.a) * alpha; slot.ClampColor(); - slot.r2 += (slot.r2 - slotData.r2) * alpha; - slot.g2 += (slot.g2 - slotData.g2) * alpha; - slot.b2 += (slot.b2 - slotData.b2) * alpha; + slot.r2 += (slot.r2 - setup.r2) * alpha; + slot.g2 += (slot.g2 - setup.g2) * alpha; + slot.b2 += (slot.b2 - setup.b2) * alpha; slot.ClampSecondColor(); return; } @@ -1533,11 +1531,9 @@ namespace Spine { slot.g = g; slot.b = b; slot.a = a; - slot.ClampColor(); slot.r2 = r2; slot.g2 = g2; slot.b2 = b2; - slot.ClampSecondColor(); } else { float br, bg, bb, ba, br2, bg2, bb2; if (blend == MixBlend.Setup) { @@ -1557,16 +1553,16 @@ namespace Spine { bg2 = slot.g2; bb2 = slot.b2; } - slot.r = br + ((r - br) * alpha); - slot.g = bg + ((g - bg) * alpha); - slot.b = bb + ((b - bb) * alpha); - slot.a = ba + ((a - ba) * alpha); - slot.ClampColor(); - slot.r2 = br2 + ((r2 - br2) * alpha); - slot.g2 = bg2 + ((g2 - bg2) * alpha); - slot.b2 = bb2 + ((b2 - bb2) * alpha); - slot.ClampSecondColor(); + slot.r = br + (r - br) * alpha; + slot.g = bg + (g - bg) * alpha; + slot.b = bb + (b - bb) * alpha; + slot.a = ba + (a - ba) * alpha; + slot.r2 = br2 + (r2 - br2) * alpha; + slot.g2 = bg2 + (g2 - bg2) * alpha; + slot.b2 = bb2 + (b2 - bb2) * alpha; } + slot.ClampColor(); + slot.ClampSecondColor(); } } @@ -1620,28 +1616,26 @@ namespace Spine { float[] frames = this.frames; if (time < frames[0]) { // Time is before first frame. - var slotData = slot.data; + SlotData setup = slot.data; switch (blend) { case MixBlend.Setup: - // slot.color.set(slot.data.color); - // slot.darkColor.set(slot.data.darkColor); - slot.r = slotData.r; - slot.g = slotData.g; - slot.b = slotData.b; + slot.r = setup.r; + slot.g = setup.g; + slot.b = setup.b; slot.ClampColor(); - slot.r2 = slotData.r2; - slot.g2 = slotData.g2; - slot.b2 = slotData.b2; + slot.r2 = setup.r2; + slot.g2 = setup.g2; + slot.b2 = setup.b2; slot.ClampSecondColor(); return; case MixBlend.First: - slot.r += (slot.r - slotData.r) * alpha; - slot.g += (slot.g - slotData.g) * alpha; - slot.b += (slot.b - slotData.b) * alpha; + slot.r += (slot.r - setup.r) * alpha; + slot.g += (slot.g - setup.g) * alpha; + slot.b += (slot.b - setup.b) * alpha; slot.ClampColor(); - slot.r2 += (slot.r2 - slotData.r2) * alpha; - slot.g2 += (slot.g2 - slotData.g2) * alpha; - slot.b2 += (slot.b2 - slotData.b2) * alpha; + slot.r2 += (slot.r2 - setup.r2) * alpha; + slot.g2 += (slot.g2 - setup.g2) * alpha; + slot.b2 += (slot.b2 - setup.b2) * alpha; slot.ClampSecondColor(); return; } @@ -1689,20 +1683,19 @@ namespace Spine { slot.r = r; slot.g = g; slot.b = b; - slot.ClampColor(); slot.r2 = r2; slot.g2 = g2; slot.b2 = b2; - slot.ClampSecondColor(); } else { float br, bg, bb, br2, bg2, bb2; if (blend == MixBlend.Setup) { - br = slot.data.r; - bg = slot.data.g; - bb = slot.data.b; - br2 = slot.data.r2; - bg2 = slot.data.g2; - bb2 = slot.data.b2; + SlotData setup = slot.data; + br = setup.r; + bg = setup.g; + bb = setup.b; + br2 = setup.r2; + bg2 = setup.g2; + bb2 = setup.b2; } else { br = slot.r; bg = slot.g; @@ -1711,15 +1704,15 @@ namespace Spine { bg2 = slot.g2; bb2 = slot.b2; } - slot.r = br + ((r - br) * alpha); - slot.g = bg + ((g - bg) * alpha); - slot.b = bb + ((b - bb) * alpha); - slot.ClampColor(); - slot.r2 = br2 + ((r2 - br2) * alpha); - slot.g2 = bg2 + ((g2 - bg2) * alpha); - slot.b2 = bb2 + ((b2 - bb2) * alpha); - slot.ClampSecondColor(); + slot.r = br + (r - br) * alpha; + slot.g = bg + (g - bg) * alpha; + slot.b = bb + (b - bb) * alpha; + slot.r2 = br2 + (r2 - br2) * alpha; + slot.g2 = bg2 + (g2 - bg2) * alpha; + slot.b2 = bb2 + (b2 - bb2) * alpha; } + slot.ClampColor(); + slot.ClampSecondColor(); } } diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java index abeddb68b..28c7287f6 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java @@ -376,9 +376,9 @@ public class Animation { static final int VALUE = 1; /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}. - * @param propertyIds Unique identifiers for the properties the timeline modifies. */ - public CurveTimeline1 (int frameCount, int bezierCount, String... propertyIds) { - super(frameCount, bezierCount, propertyIds); + * @param propertyId Unique identifier for the property the timeline modifies. */ + public CurveTimeline1 (int frameCount, int bezierCount, String propertyId) { + super(frameCount, bezierCount, propertyId); } public int getFrameEntries () { @@ -423,9 +423,10 @@ public class Animation { static final int VALUE1 = 1, VALUE2 = 2; /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}. - * @param propertyIds Unique identifiers for the properties the timeline modifies. */ - public CurveTimeline2 (int frameCount, int bezierCount, String... propertyIds) { - super(frameCount, bezierCount, propertyIds); + * @param propertyId1 Unique identifier for the first property the timeline modifies. + * @param propertyId2 Unique identifier for the second property the timeline modifies. */ + public CurveTimeline2 (int frameCount, int bezierCount, String propertyId1, String propertyId2) { + super(frameCount, bezierCount, propertyId1, propertyId2); } public int getFrameEntries () { @@ -1428,7 +1429,10 @@ public class Animation { } else { if (blend == setup) { light.set(slot.data.color); - dark.set(slot.data.darkColor); + Color setupDark = slot.data.darkColor; + dark.r = setupDark.r; + dark.g = setupDark.g; + dark.b = setupDark.b; } light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha); dark.r += (r2 - dark.r) * alpha; diff --git a/spine-ts/core/src/Animation.ts b/spine-ts/core/src/Animation.ts index 24cfe296f..ebc1b13f1 100644 --- a/spine-ts/core/src/Animation.ts +++ b/spine-ts/core/src/Animation.ts @@ -41,16 +41,20 @@ module spine { constructor (name: string, timelines: Array, duration: number) { if (!name) throw new Error("name cannot be null."); - if (!timelines) throw new Error("timelines cannot be null."); this.name = name; + this.setTimelines(timelines); + this.duration = duration; + } + + setTimelines(timelines: Array) { + if (!timelines) throw new Error("timelines cannot be null."); this.timelines = timelines; this.timelineIds = new StringSet(); for (var i = 0; i < timelines.length; i++) this.timelineIds.addAll(timelines[i].getPropertyIds()); - this.duration = duration; } - hasTimeline(ids: string[]) { + hasTimeline(ids: string[]) : boolean { for (let i = 0; i < ids.length; i++) if (this.timelineIds.contains(ids[i])) return true; return false; @@ -166,17 +170,17 @@ module spine { abstract apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; - static search (frames: ArrayLike, time: number) { + static search1 (frames: ArrayLike, time: number) { let n = frames.length; for (let i = 1; i < n; i++) if (frames[i] > time) return i - 1; return n - 1; } - static search2 (values: ArrayLike, time: number, step: number) { - let n = values.length; + static search (frames: ArrayLike, time: number, step: number) { + let n = frames.length; for (let i = step; i < n; i += step) - if (values[i] > time) return i - step; + if (frames[i] > time) return i - step; return n - step; } } @@ -282,8 +286,8 @@ module spine { } export abstract class CurveTimeline1 extends CurveTimeline { - constructor(frameCount: number, bezierCount: number, propertyIds: string[]) { - super(frameCount, bezierCount, propertyIds); + constructor(frameCount: number, bezierCount: number, propertyId: string) { + super(frameCount, bezierCount, [ propertyId ]); } getFrameEntries () { @@ -326,8 +330,8 @@ module spine { export abstract class CurveTimeline2 extends CurveTimeline { /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}. * @param propertyIds Unique identifiers for the properties the timeline modifies. */ - constructor (frameCount: number, bezierCount: number, propertyIds: string[]) { - super(frameCount, bezierCount, propertyIds); + constructor (frameCount: number, bezierCount: number, propertyId1: string, propertyId2: string) { + super(frameCount, bezierCount, [ propertyId1, propertyId2 ]); } getFrameEntries () { @@ -350,9 +354,7 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ - Property.rotate + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.rotate + "|" + boneIndex); this.boneIndex = boneIndex; } @@ -391,10 +393,10 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ + super(frameCount, bezierCount, Property.x + "|" + boneIndex, Property.y + "|" + boneIndex, - ]); + ); this.boneIndex = boneIndex; } @@ -417,7 +419,7 @@ module spine { } let x = 0, y = 0; - let i = Timeline.search2(frames, time, 3/*ENTRIES*/); + let i = Timeline.search(frames, time, 3/*ENTRIES*/); let curveType = this.curves[i / 3/*ENTRIES*/]; switch (curveType) { case 0/*LINEAR*/: @@ -459,9 +461,7 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ - Property.x + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.x + "|" + boneIndex); this.boneIndex = boneIndex; } @@ -501,9 +501,7 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ - Property.y + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.y + "|" + boneIndex); this.boneIndex = boneIndex; } @@ -543,10 +541,10 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ + super(frameCount, bezierCount, Property.scaleX + "|" + boneIndex, Property.scaleY + "|" + boneIndex - ]); + ); this.boneIndex = boneIndex; } @@ -569,7 +567,7 @@ module spine { } let x = 0, y = 0; - let i = Timeline.search2(frames, time, 3/*ENTRIES*/); + let i = Timeline.search(frames, time, 3/*ENTRIES*/); let curveType = this.curves[i / 3/*ENTRIES*/]; switch (curveType) { case 0/*LINEAR*/: @@ -653,9 +651,7 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ - Property.scaleX + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.scaleX + "|" + boneIndex); this.boneIndex = boneIndex; } @@ -724,9 +720,7 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ - Property.scaleY + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.scaleY + "|" + boneIndex); this.boneIndex = boneIndex; } @@ -795,10 +789,10 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ + super(frameCount, bezierCount, Property.shearX + "|" + boneIndex, Property.shearY + "|" + boneIndex - ]); + ); this.boneIndex = boneIndex; } @@ -821,7 +815,7 @@ module spine { } let x = 0, y = 0; - let i = Timeline.search2(frames, time, 3/*ENTRIES*/); + let i = Timeline.search(frames, time, 3/*ENTRIES*/); let curveType = this.curves[i / 3/*ENTRIES*/]; switch (curveType) { case 0/*LINEAR*/: @@ -863,9 +857,7 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ - Property.shearX + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.shearX + "|" + boneIndex); this.boneIndex = boneIndex; } @@ -905,9 +897,7 @@ module spine { boneIndex = 0; constructor (frameCount: number, bezierCount: number, boneIndex: number) { - super(frameCount, bezierCount, [ - Property.shearY + "|" + boneIndex - ]); + super(frameCount, bezierCount, Property.shearY + "|" + boneIndex); this.boneIndex = boneIndex; } @@ -978,7 +968,7 @@ module spine { let setup = slot.data.color; switch (blend) { case MixBlend.setup: - color.setFromColor(slot.data.color); + color.setFromColor(setup); return; case MixBlend.first: color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, @@ -988,7 +978,7 @@ module spine { } let r = 0, g = 0, b = 0, a = 0; - let i = Timeline.search2(frames, time, 5/*ENTRIES*/); + let i = Timeline.search(frames, time, 5/*ENTRIES*/); let curveType = this.curves[i / 5/*ENTRIES*/]; switch (curveType) { case 0/*LINEAR*/: @@ -1071,7 +1061,7 @@ module spine { } let r = 0, g = 0, b = 0; - let i = Timeline.search2(frames, time, 4/*ENTRIES*/); + let i = Timeline.search(frames, time, 4/*ENTRIES*/); let curveType = this.curves[i >> 2]; switch (curveType) { case 0/*LINEAR*/: @@ -1117,9 +1107,7 @@ module spine { slotIndex = 0; constructor (frameCount: number, bezierCount: number, slotIndex: number) { - super(frameCount, bezierCount, [ - Property.alpha + "|" + slotIndex - ]); + super(frameCount, bezierCount, Property.alpha + "|" + slotIndex); this.slotIndex = slotIndex; } @@ -1206,7 +1194,7 @@ module spine { } let r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0; - let i = Timeline.search2(frames, time, 8/*ENTRIES*/); + let i = Timeline.search(frames, time, 8/*ENTRIES*/); let curveType = this.curves[i >> 3]; switch (curveType) { case 0/*LINEAR*/: @@ -1254,7 +1242,10 @@ module spine { } else { if (blend == MixBlend.setup) { light.setFromColor(slot.data.color); - dark.setFromColor(slot.data.darkColor); + let setupDark = slot.data.darkColor; + dark.r = setupDark.r; + dark.g = setupDark.g; + dark.b = setupDark.b; } light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha); dark.r += (r2 - dark.r) * alpha; @@ -1321,7 +1312,7 @@ module spine { } let r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0; - let i = Timeline.search2(frames, time, 7/*ENTRIES*/); + let i = Timeline.search(frames, time, 7/*ENTRIES*/); let curveType = this.curves[i / 7/*ENTRIES*/]; switch (curveType) { case 0/*LINEAR*/: @@ -1423,7 +1414,7 @@ module spine { return; } - this.setAttachment(skeleton, slot, this.attachmentNames[Timeline.search(this.frames, time)]); + this.setAttachment(skeleton, slot, this.attachmentNames[Timeline.search1(this.frames, time)]); } setAttachment(skeleton: Skeleton, slot: Slot, attachmentName: string) { @@ -1610,7 +1601,7 @@ module spine { } // Interpolate between the previous frame and the current frame. - let frame = Timeline.search(frames, time); + let frame = Timeline.search1(frames, time); let percent = this.getCurvePercent(time, frame); let prevVertices = vertices[frame]; let nextVertices = vertices[frame + 1]; @@ -1727,7 +1718,7 @@ module spine { if (lastTime < frames[0]) i = 0; else { - i = Timeline.search(frames, lastTime) + 1; + i = Timeline.search1(frames, lastTime) + 1; let frameTime = frames[i]; while (i > 0) { // Fire multiple events with the same frame. if (frames[i - 1] != frameTime) break; @@ -1774,7 +1765,7 @@ module spine { return; } - let drawOrderToSetupIndex = this.drawOrders[Timeline.search(this.frames, time)]; + let drawOrderToSetupIndex = this.drawOrders[Timeline.search1(this.frames, time)]; if (!drawOrderToSetupIndex) Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); else { @@ -1839,7 +1830,7 @@ module spine { } let mix = 0, softness = 0; - let i = Timeline.search2(frames, time, 6/*ENTRIES*/) + let i = Timeline.search(frames, time, 6/*ENTRIES*/) let curveType = this.curves[i / 6/*ENTRIES*/]; switch (curveType) { case 0/*LINEAR*/: @@ -1943,7 +1934,7 @@ module spine { } let rotate, x, y, scaleX, scaleY, shearY; - let i = Timeline.search2(frames, time, 7/*ENTRIES*/); + let i = Timeline.search(frames, time, 7/*ENTRIES*/); let curveType = this.curves[i / 7/*ENTRIES*/]; switch (curveType) { case 0/*LINEAR*/: @@ -2004,9 +1995,7 @@ module spine { pathConstraintIndex: number; constructor (frameCount: number, bezierCount: number, pathConstraintIndex: number) { - super(frameCount, bezierCount, [ - Property.pathConstraintPosition + "|" + pathConstraintIndex - ]); + super(frameCount, bezierCount, Property.pathConstraintPosition + "|" + pathConstraintIndex); this.pathConstraintIndex = pathConstraintIndex; } @@ -2041,9 +2030,7 @@ module spine { pathConstraintIndex = 0; constructor (frameCount: number, bezierCount: number, pathConstraintIndex: number) { - super(frameCount, bezierCount, [ - Property.pathConstraintSpacing + "|" + pathConstraintIndex - ]); + super(frameCount, bezierCount, Property.pathConstraintSpacing + "|" + pathConstraintIndex); this.pathConstraintIndex = pathConstraintIndex; } @@ -2119,7 +2106,7 @@ module spine { } let rotate, x, y; - let i = Timeline.search2(frames, time, 4/*ENTRIES*/); + let i = Timeline.search(frames, time, 4/*ENTRIES*/); let curveType = this.curves[i >> 2]; switch (curveType) { case 0/*LINEAR*/: diff --git a/spine-ts/core/src/AnimationState.ts b/spine-ts/core/src/AnimationState.ts index 52f679932..f7f640741 100644 --- a/spine-ts/core/src/AnimationState.ts +++ b/spine-ts/core/src/AnimationState.ts @@ -336,7 +336,7 @@ module spine { if (blend == MixBlend.setup || blend == MixBlend.first) this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments); } else - this.setAttachment(skeleton, slot, timeline.attachmentNames[Timeline.search(frames, time)], attachments); + this.setAttachment(skeleton, slot, timeline.attachmentNames[Timeline.search1(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;