Various clean up.

This commit is contained in:
Nathan Sweet 2021-06-04 22:15:58 -04:00
parent 3b650f8db1
commit 700d2897a8
34 changed files with 179 additions and 212 deletions

View File

@ -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;
}

View File

@ -40,15 +40,19 @@ package spine.animation {
public function Animation(name : String, timelines : Vector.<Timeline>, 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.<Timeline>) : 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.<String> = 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.<String>) : Boolean {

View File

@ -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;

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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.<Number> = vertices[frame], prev : Number;
var nextVertices : Vector.<Number> = vertices[frame + 1];

View File

@ -75,7 +75,7 @@ package spine.animation {
return;
}
var drawOrderToSetupIndex : Vector.<int> = drawOrders[search(frames, time)];
var drawOrderToSetupIndex : Vector.<int> = drawOrders[search1(frames, time)];
if (drawOrderToSetupIndex == null) {
for (i = 0; i < n; i++)
drawOrder[i] = slots[i];

View File

@ -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;

View File

@ -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:

View File

@ -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:

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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:

View File

@ -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:

View File

@ -75,10 +75,10 @@ package spine.animation {
var frames : Vector.<Number> = 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:

View File

@ -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:

View File

@ -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;
}

View File

@ -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:

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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:

View File

@ -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;
}

View File

@ -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;
}

View File

@ -57,17 +57,17 @@ package spine.animation {
public function apply (skeleton: Skeleton, lastTime: Number, time: Number, events: Vector.<Event>, alpha: Number, blend: MixBlend, direction: MixDirection) : void {
}
static internal function search (frames : Vector.<Number>, time : Number) : int {
static internal function search1 (frames : Vector.<Number>, 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.<Number>, time : Number, step: int) : int {
var n : int = values.length;
static internal function search (frames : Vector.<Number>, 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;
}
}

View File

@ -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:

View File

@ -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:

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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. */

View File

@ -395,8 +395,8 @@ namespace Spine {
/// <param name="bezierCount">The maximum number of Bezier curves. See <see cref="Shrink(int)"/>.</param>
/// <param name="propertyIds">Unique identifiers for the properties the timeline modifies.</param>
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 {
/// <param name="bezierCount">The maximum number of Bezier curves. See <see cref="Shrink(int)"/>.</param>
/// <param name="propertyIds">Unique identifiers for the properties the timeline modifies.</param>
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();
}
}

View File

@ -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;

View File

@ -41,16 +41,20 @@ module spine {
constructor (name: string, timelines: Array<Timeline>, 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<Timeline>) {
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<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
static search (frames: ArrayLike<number>, time: number) {
static search1 (frames: ArrayLike<number>, 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<number>, time: number, step: number) {
let n = values.length;
static search (frames: ArrayLike<number>, 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*/:

View File

@ -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;