mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
More clean up.
This commit is contained in:
parent
137c3f69ed
commit
a5be08a62a
@ -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.<Bone> = this._bones;
|
||||
var boneCount : int = bones.length, spacesCount : int = tangents ? boneCount : boneCount + 1;
|
||||
this._spaces.length = spacesCount;
|
||||
var spaces : Vector.<Number> = this._spaces, lengths : Vector.<Number> = _lengths;
|
||||
if (scale) lengths.length = boneCount;
|
||||
|
||||
@ -180,8 +180,8 @@ package spine.animation {
|
||||
applyTime = current.animation.duration - applyTime;
|
||||
applyEvents = null;
|
||||
}
|
||||
var timelineCount : int = current.animation.timelines.length;
|
||||
var timelines : Vector.<Timeline> = 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.<Timeline> = 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.<Event> = 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.<Number>, i : int, firstFrame : Boolean) : void {
|
||||
private function applyRotateTimeline(timeline : RotateTimeline, skeleton : Skeleton, time : Number, alpha : Number, blend : MixBlend, timelinesRotation : Vector.<Number>, 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.<Number> = rotateTimeline.frames;
|
||||
var frames : Vector.<Number> = 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -323,7 +323,6 @@ namespace Spine {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Stores the segments for the specified Bezier curve. For timelines that modify multiple values, there may be more than
|
||||
/// one curve per frame.</summary>
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Sets an animation by name. <seealso cref="SetAnimation(int, Animation, bool)" /></summary>
|
||||
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;
|
||||
|
||||
@ -219,8 +219,6 @@ namespace Spine {
|
||||
Array.Copy(Items, index, array, arrayIndex, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool Exists (Predicate<T> match) {
|
||||
CheckMatch(match);
|
||||
return GetIndex(0, Count, match) != -1;
|
||||
|
||||
@ -325,7 +325,6 @@ namespace Spine {
|
||||
return skeletonData;
|
||||
}
|
||||
|
||||
|
||||
/// <returns>May be null.</returns>
|
||||
private Skin ReadSkin (SkeletonInput input, SkeletonData skeletonData, bool defaultSkin, bool nonessential) {
|
||||
|
||||
|
||||
@ -125,7 +125,6 @@ namespace Spine {
|
||||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Returns true if the axis aligned bounding box contains the point.</summary>
|
||||
public bool AabbContainsPoint (float x, float y) {
|
||||
return x >= minX && x <= maxX && y >= minY && y <= maxY;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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<number>, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<number> = 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;
|
||||
|
||||
@ -255,7 +255,6 @@ module spine {
|
||||
x: number;
|
||||
y: number;
|
||||
index: number;
|
||||
rotate: boolean;
|
||||
degrees: number;
|
||||
texture: Texture;
|
||||
names: string[];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user