Skip to content

Commit

Permalink
[all] Source clean up, formatting, and tabs for indentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSweet authored and HaraldCsaszar committed Aug 28, 2019
1 parent 7f81f6d commit 45362e6
Show file tree
Hide file tree
Showing 297 changed files with 5,288 additions and 5,707 deletions.
76 changes: 38 additions & 38 deletions spine-as3/spine-as3/src/spine/animation/AnimationState.as
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ package spine.animation {
internal var queue : EventQueue;
internal var propertyIDs : Dictionary = new Dictionary();
internal var mixingTo : Vector.<TrackEntry> = new Vector.<TrackEntry>();
internal var animationsChanged : Boolean;
internal var animationsChanged : Boolean;
public var timeScale : Number = 1;
internal var trackEntryPool : Pool;

Expand Down Expand Up @@ -131,7 +131,7 @@ package spine.animation {
if (from == null) return true;

var finished : Boolean = updateMixingFrom(from, delta);

from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;

Expand All @@ -142,11 +142,11 @@ package spine.animation {
to.mixingFrom = from.mixingFrom;
if (from.mixingFrom != null) from.mixingFrom.mixingTo = to;
to.interruptAlpha = from.interruptAlpha;
queue.end(from);
queue.end(from);
}
return finished;
}

from.trackTime += delta * from.timeScale;
to.mixTime += delta;
return false;
Expand Down Expand Up @@ -182,11 +182,11 @@ package spine.animation {
Timeline(timelines[ii]).apply(skeleton, animationLast, animationTime, events, mix, blend, MixDirection.In);
} else {
var timelineMode : Vector.<int> = current.timelineMode;

var firstFrame : Boolean = current.timelinesRotation.length == 0;
if (firstFrame) current.timelinesRotation.length = timelineCount << 1;
var timelinesRotation : Vector.<Number> = current.timelinesRotation;

for (ii = 0; ii < timelineCount; ii++) {
var timeline : Timeline = timelines[ii];
var timelineBlend : MixBlend = (timelineMode[ii] & (NOT_LAST - 1)) == SUBSEQUENT ? blend : MixBlend.setup;
Expand Down Expand Up @@ -234,11 +234,11 @@ package spine.animation {
} else {
var timelineMode : Vector.<int> = from.timelineMode;
var timelineHoldMix : Vector.<TrackEntry> = from.timelineHoldMix;

var firstFrame : Boolean = from.timelinesRotation.length == 0;
if (firstFrame) from.timelinesRotation.length = timelineCount << 1;
var timelinesRotation : Vector.<Number> = from.timelinesRotation;

from.totalAlpha = 0;
for (i = 0; i < timelineCount; i++) {
var timeline : Timeline = timelines[i];
Expand All @@ -264,15 +264,15 @@ package spine.animation {
alpha = alphaHold;
break;
default:
timelineBlend = MixBlend.setup;
timelineBlend = MixBlend.setup;
var holdMix : TrackEntry = timelineHoldMix[i];
alpha = alphaHold * Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration);
break;
}
from.totalAlpha += alpha;
if (timeline is RotateTimeline)
applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
else {
else {
if (timelineBlend == MixBlend.setup) {
if (timeline is AttachmentTimeline) {
if (attachments || ((timelineMode[i] & NOT_LAST) == NOT_LAST)) direction = MixDirection.In;
Expand All @@ -282,14 +282,14 @@ package spine.animation {
}
timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction);
}
}
}
}
}

if (to.mixDuration > 0) queueEvents(from, animationTime);
this.events.length = 0;
from.nextAnimationLast = animationTime;
from.nextTrackLast = from.trackTime;

return mix;
}

Expand All @@ -315,8 +315,8 @@ package spine.animation {
case MixBlend.first:
r1 = bone.rotation;
r2 = bone.data.rotation;
}
} else {
}
} else {
r1 = blend == MixBlend.setup ? bone.data.rotation : bone.rotation;
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) // Time is after last frame.
r2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION];
Expand All @@ -326,20 +326,20 @@ package spine.animation {
var prevRotation : Number = frames[frame + RotateTimeline.PREV_ROTATION];
var frameTime : Number = frames[frame];
var percent : Number = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));

r2 = frames[frame + RotateTimeline.ROTATION] - prevRotation;
r2 -= (16384 - int((16384.499999999996 - r2 / 360))) * 360;
r2 = prevRotation + r2 * percent + bone.data.rotation;
r2 -= (16384 - int((16384.499999999996 - r2 / 360))) * 360;
}
}

// Mix between rotations using the direction of the shortest route on the first frame while detecting crosses.
// Mix between rotations using the direction of the shortest route on the first frame while detecting crosses.
var total : Number, diff : Number = r2 - r1;
diff -= (16384 - int((16384.499999999996 - diff / 360))) * 360;
if (diff == 0) {
total = timelinesRotation[i];
} else {
} else {
var lastTotal : Number, lastDiff : Number;
if (firstFrame) {
lastTotal = 0;
Expand Down Expand Up @@ -378,8 +378,8 @@ package spine.animation {
if (event.time < trackLastWrapped) break;
if (event.time > animationEnd) continue; // Discard events outside animation start/end.
queue.event(entry, event);
}
}

// Queue complete if completed a loop iteration or the animation.
var complete:Boolean;
if (entry.loop)
Expand Down Expand Up @@ -433,20 +433,20 @@ package spine.animation {
private function setCurrent(index : int, current : TrackEntry, interrupt : Boolean) : void {
var from : TrackEntry = expandToIndex(index);
tracks[index] = current;

if (from != null) {
if (interrupt) queue.interrupt(from);
current.mixingFrom = from;
from.mixingTo = current;
current.mixTime = 0;

// Store the interrupted mix percentage.
if (from.mixingFrom != null && from.mixDuration > 0)
current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration);

from.timelinesRotation.length = 0; // Reset rotation for mixing out, in case entry was mixed in.
}

queue.start(current);
}

Expand Down Expand Up @@ -504,9 +504,9 @@ package spine.animation {
var duration : Number = last.animationEnd - last.animationStart;
if (duration != 0) {
if (last.loop)
delay += duration * (1 + (int)(last.trackTime / duration));
delay += duration * (1 + (int)(last.trackTime / duration));
else
delay += Math.max(duration, last.trackTime);
delay += Math.max(duration, last.trackTime);
} else
delay = last.trackTime;
}
Expand Down Expand Up @@ -590,7 +590,7 @@ package spine.animation {
private function _animationsChanged() : void {
animationsChanged = false;

propertyIDs = new Dictionary();
propertyIDs = new Dictionary();
var i : int = 0;
var n: int = 0;
var entry : TrackEntry = null;
Expand All @@ -601,7 +601,7 @@ package spine.animation {
entry = entry.mixingFrom;
do {
if (entry.mixingTo == null || entry.mixBlend != MixBlend.add) computeHold(entry);
entry = entry.mixingTo;
entry = entry.mixingTo;
} while (entry != null);
}

Expand All @@ -614,7 +614,7 @@ package spine.animation {
}
}
}

private function computeNotLast (entry: TrackEntry) : void {
var timelines : Vector.<Timeline> = entry.animation.timelines;
var timelinesCount : int = entry.animation.timelines.length;
Expand All @@ -636,19 +636,19 @@ package spine.animation {
}

private function computeHold (entry: TrackEntry) : void {
var to: TrackEntry = entry.mixingTo;
var to: TrackEntry = entry.mixingTo;
var timelines : Vector.<Timeline> = entry.animation.timelines;
var timelinesCount : int = entry.animation.timelines.length;
var timelineMode : Vector.<int> = entry.timelineMode;
timelineMode.length = timelinesCount;
timelineMode.length = timelinesCount;
var timelineHoldMix : Vector.<TrackEntry> = entry.timelineHoldMix;
timelineHoldMix.length = 0;
var propertyIDs: Dictionary = this.propertyIDs;

var i : int = 0;
if (to != null && to.holdPrevious) {
for (i = 0; i < timelinesCount; i++) {
propertyIDs[timelines[i].getPropertyId().toString()] = true;
propertyIDs[timelines[i].getPropertyId().toString()] = true;
timelineMode[i] = HOLD;
}
return;
Expand All @@ -658,27 +658,27 @@ package spine.animation {
for (i = 0; i < timelinesCount; i++) {
var timeline : Timeline = Timeline(timelines[i]);
var intId : int = timeline.getPropertyId();
var id : String = intId.toString();
var id : String = intId.toString();
var contained: Object = propertyIDs[id];
propertyIDs[id] = true;
if (contained != null) {
timelineMode[i] = AnimationState.SUBSEQUENT;
else if (to == null || timeline is AttachmentTimeline || timeline is DrawOrderTimeline
|| timeline is EventTimeline || !hasTimeline(to, intId)) {
timelineMode[i] = AnimationState.FIRST;
} else {
} else {
for (var next : TrackEntry = to.mixingTo; next != null; next = next.mixingTo) {
if (hasTimeline(next, intId)) continue;
if (entry.mixDuration > 0) {
timelineMode[i] = AnimationState.HOLD_MIX;
timelineMode[i] = AnimationState.HOLD_MIX;
timelineHoldMix[i] = entry;
continue outer;
}
break;
}
timelineMode[i] = AnimationState.HOLD;
}
}
}
}

private static function hasTimeline (entry: TrackEntry, id : int) : Boolean {
Expand Down
44 changes: 22 additions & 22 deletions spine-as3/spine-as3/src/spine/animation/DeformTimeline.as
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ package spine.animation {
import spine.Skeleton;
import spine.Slot;

public class DeformTimeline extends CurveTimeline {
public class DeformTimeline extends CurveTimeline {
public var slotIndex : int;
public var frames : Vector.<Number>;
public var frameVertices : Vector.<Vector.<Number>>;
Expand Down Expand Up @@ -63,16 +63,16 @@ package spine.animation {
if (!slot.bone.active) return;
var slotAttachment : Attachment = slot.attachment;
if (!(slotAttachment is VertexAttachment) || !(VertexAttachment(slotAttachment).deformAttachment == attachment)) return;

var deformArray : Vector.<Number> = slot.deform;
if (deformArray.length == 0) blend = MixBlend.setup;

var frameVertices : Vector.<Vector.<Number>> = this.frameVertices;
var vertexCount : int = frameVertices[0].length;
var deform : Vector.<Number>;

var frames : Vector.<Number> = this.frames;
var i : int;
var i : int;
if (time < frames[0]) {
vertexAttachment = VertexAttachment(slotAttachment);
switch (blend) {
Expand All @@ -99,27 +99,27 @@ package spine.animation {
}
}
return;
}
}

deformArray.length = vertexCount;
deform = deformArray;
var n : int;
var n : int;
var setup : Number, prev : Number;
if (time >= frames[frames.length - 1]) { // Time is after last frame.
var lastVertices : Vector.<Number> = frameVertices[frames.length - 1];
if (alpha == 1) {
if (blend == MixBlend.add) {
vertexAttachment = VertexAttachment(slotAttachment);
if (vertexAttachment.bones == null) {
if (vertexAttachment.bones == null) {
setupVertices = vertexAttachment.vertices;
for (i = 0; i < vertexCount; i++) {
for (i = 0; i < vertexCount; i++) {
deform[i] += lastVertices[i] - setupVertices[i];
}
} else {
} else {
for (i = 0; i < vertexCount; i++)
deform[i] += lastVertices[i];
}
} else {
} else {
for (i = 0, n = vertexCount; i < n; i++)
deform[i] = lastVertices[i];
}
Expand All @@ -146,16 +146,16 @@ package spine.animation {
deform[i] += (lastVertices[i] - deform[i]) * alpha;
case MixBlend.add:
vertexAttachment = VertexAttachment(slotAttachment);
if (vertexAttachment.bones == null) {
if (vertexAttachment.bones == null) {
setupVertices = vertexAttachment.vertices;
for (i = 0; i < vertexCount; i++) {
for (i = 0; i < vertexCount; i++) {
deform[i] += (lastVertices[i] - setupVertices[i]) * alpha;
}
} else {
for (i = 0; i < vertexCount; i++)
deform[i] += lastVertices[i] * alpha;
}
}
}
}
}
return;
}
Expand All @@ -170,20 +170,20 @@ package spine.animation {
if (alpha == 1) {
if (blend == MixBlend.add) {
vertexAttachment = VertexAttachment(slotAttachment);
if (vertexAttachment.bones == null) {
if (vertexAttachment.bones == null) {
setupVertices = vertexAttachment.vertices;
for (i = 0; i < vertexCount; i++) {
prev = prevVertices[i];
deform[i] += prev + (nextVertices[i] - prev) * percent - setupVertices[i];
}
} else {
} else {
for (i = 0; i < vertexCount; i++) {
prev = prevVertices[i];
prev = prevVertices[i];
deform[i] += prev + (nextVertices[i] - prev) * percent;
}
}
} else {
for (i = 0; i < vertexCount; i++) {
} else {
for (i = 0; i < vertexCount; i++) {
prev = prevVertices[i];
deform[i] = prev + (nextVertices[i] - prev) * percent;
}
Expand Down Expand Up @@ -216,19 +216,19 @@ package spine.animation {
break;
case MixBlend.add:
vertexAttachment = VertexAttachment(slotAttachment);
if (vertexAttachment.bones == null) {
if (vertexAttachment.bones == null) {
setupVertices = vertexAttachment.vertices;
for (i = 0; i < vertexCount; i++) {
prev = prevVertices[i], setup = setupVertices[i];
deform[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha;
}
} else {
} else {
for (i = 0; i < vertexCount; i++) {
prev = prevVertices[i];
deform[i] += (prev + (nextVertices[i] - prev) * percent) * alpha;
}
}
}
}
}
}
}
Expand Down
Loading

0 comments on commit 45362e6

Please sign in to comment.