mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-24 18:51:25 +08:00
[as3] Ported Animation State changes, see #908
This commit is contained in:
parent
7593da8cb8
commit
679a1997c0
Binary file not shown.
@ -39,6 +39,7 @@ package spine.animation {
|
|||||||
public static var SUBSEQUENT : int = 0;
|
public static var SUBSEQUENT : int = 0;
|
||||||
public static var FIRST : int = 1;
|
public static var FIRST : int = 1;
|
||||||
public static var DIP : int = 2;
|
public static var DIP : int = 2;
|
||||||
|
public static var DIP_MIX : int = 3;
|
||||||
internal static var emptyAnimation : Animation = new Animation("<empty>", new Vector.<Timeline>(), 0);
|
internal static var emptyAnimation : Animation = new Animation("<empty>", new Vector.<Timeline>(), 0);
|
||||||
public var data : AnimationStateData;
|
public var data : AnimationStateData;
|
||||||
public var tracks : Vector.<TrackEntry> = new Vector.<TrackEntry>();
|
public var tracks : Vector.<TrackEntry> = new Vector.<TrackEntry>();
|
||||||
@ -107,7 +108,7 @@ package spine.animation {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (current.mixingFrom != null && updateMixingFrom(current, delta, 2)) {
|
if (current.mixingFrom != null && updateMixingFrom(current, delta)) {
|
||||||
// End mixing from entries once all have completed.
|
// End mixing from entries once all have completed.
|
||||||
var from : TrackEntry = current.mixingFrom;
|
var from : TrackEntry = current.mixingFrom;
|
||||||
current.mixingFrom = null;
|
current.mixingFrom = null;
|
||||||
@ -123,21 +124,18 @@ package spine.animation {
|
|||||||
queue.drain();
|
queue.drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateMixingFrom(entry : TrackEntry, delta : Number, animationCount : int) : Boolean {
|
private function updateMixingFrom(to : TrackEntry, delta : Number) : Boolean {
|
||||||
var from : TrackEntry = entry.mixingFrom;
|
var from : TrackEntry = to.mixingFrom;
|
||||||
if (from == null) return true;
|
if (from == null) return true;
|
||||||
|
|
||||||
var finished : Boolean = updateMixingFrom(from, delta, animationCount + 1);
|
var finished : Boolean = updateMixingFrom(from, delta);
|
||||||
|
|
||||||
// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
|
// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
|
||||||
if (entry.mixTime > 0 && (entry.mixTime >= entry.mixDuration || entry.timeScale == 0)) {
|
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
|
||||||
if (animationCount > 5 && from.mixingFrom == null) {
|
if (from.totalAlpha == 0) {
|
||||||
// Limit linked list by speeding up and removing old entries.
|
to.mixingFrom = from.mixingFrom;
|
||||||
entry.interruptAlpha = Math.max(0, entry.interruptAlpha - delta * 0.66);
|
to.interruptAlpha = from.interruptAlpha;
|
||||||
if (entry.interruptAlpha <= 0) {
|
queue.end(from);
|
||||||
entry.mixingFrom = null;
|
|
||||||
queue.end(from);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
@ -145,7 +143,7 @@ package spine.animation {
|
|||||||
from.animationLast = from.nextAnimationLast;
|
from.animationLast = from.nextAnimationLast;
|
||||||
from.trackLast = from.nextTrackLast;
|
from.trackLast = from.nextTrackLast;
|
||||||
from.trackTime += delta * from.timeScale;
|
from.trackTime += delta * from.timeScale;
|
||||||
entry.mixTime += delta * entry.timeScale;
|
to.mixTime += delta * to.timeScale;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,9 +182,9 @@ package spine.animation {
|
|||||||
for (ii = 0; ii < timelineCount; ii++) {
|
for (ii = 0; ii < timelineCount; ii++) {
|
||||||
var timeline : Timeline = timelines[ii];
|
var timeline : Timeline = timelines[ii];
|
||||||
if (timeline is RotateTimeline) {
|
if (timeline is RotateTimeline) {
|
||||||
applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] > 0, timelinesRotation, ii << 1, firstFrame);
|
applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= FIRST, timelinesRotation, ii << 1, firstFrame);
|
||||||
} else
|
} else
|
||||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] > 0, false);
|
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= FIRST, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queueEvents(current, animationTime);
|
queueEvents(current, animationTime);
|
||||||
@ -226,6 +224,7 @@ package spine.animation {
|
|||||||
var alphaDip : Number = from.alpha * to.interruptAlpha;
|
var alphaDip : Number = from.alpha * to.interruptAlpha;
|
||||||
var alphaMix : Number = alphaDip * (1 - mix);
|
var alphaMix : Number = alphaDip * (1 - mix);
|
||||||
var alpha : Number = 0;
|
var alpha : Number = 0;
|
||||||
|
from.totalAlpha = 0;
|
||||||
for (var i : int = 0; i < timelineCount; i++) {
|
for (var i : int = 0; i < timelineCount; i++) {
|
||||||
var timeline : Timeline = timelines[i];
|
var timeline : Timeline = timelines[i];
|
||||||
switch (timelineData[i]) {
|
switch (timelineData[i]) {
|
||||||
@ -237,13 +236,18 @@ package spine.animation {
|
|||||||
first = true;
|
first = true;
|
||||||
alpha = alphaMix;
|
alpha = alphaMix;
|
||||||
break;
|
break;
|
||||||
|
case DIP:
|
||||||
|
first = true;
|
||||||
|
alpha = alphaDip;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
first = true;
|
first = true;
|
||||||
alpha = alphaDip;
|
alpha = alphaDip;
|
||||||
var dipMix : TrackEntry = timelineDipMix[i];
|
var dipMix : TrackEntry = timelineDipMix[i];
|
||||||
if (dipMix != null) alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
from.totalAlpha += alpha;
|
||||||
if (timeline is RotateTimeline)
|
if (timeline is RotateTimeline)
|
||||||
applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -46,7 +46,7 @@ package spine.animation {
|
|||||||
public var eventThreshold : Number, attachmentThreshold : Number, drawOrderThreshold : Number;
|
public var eventThreshold : Number, attachmentThreshold : Number, drawOrderThreshold : Number;
|
||||||
public var animationStart : Number, animationEnd : Number, animationLast : Number, nextAnimationLast : Number;
|
public var animationStart : Number, animationEnd : Number, animationLast : Number, nextAnimationLast : Number;
|
||||||
public var delay : Number, trackTime : Number, trackLast : Number, nextTrackLast : Number, trackEnd : Number, timeScale : Number;
|
public var delay : Number, trackTime : Number, trackLast : Number, nextTrackLast : Number, trackEnd : Number, timeScale : Number;
|
||||||
public var alpha : Number, mixTime : Number, mixDuration : Number, interruptAlpha : Number;
|
public var alpha : Number, mixTime : Number, mixDuration : Number, interruptAlpha : Number, totalAlpha : Number;
|
||||||
public var timelineData : Vector.<int> = new Vector.<int>();
|
public var timelineData : Vector.<int> = new Vector.<int>();
|
||||||
public var timelineDipMix : Vector.<TrackEntry> = new Vector.<TrackEntry>();
|
public var timelineDipMix : Vector.<TrackEntry> = new Vector.<TrackEntry>();
|
||||||
public var timelinesRotation : Vector.<Number> = new Vector.<Number>();
|
public var timelinesRotation : Vector.<Number> = new Vector.<Number>();
|
||||||
@ -89,6 +89,7 @@ package spine.animation {
|
|||||||
var timelinesCount : int = animation.timelines.length;
|
var timelinesCount : int = animation.timelines.length;
|
||||||
var timelineData : Vector.<int> = this.timelineData;
|
var timelineData : Vector.<int> = this.timelineData;
|
||||||
timelineData.length = timelinesCount;
|
timelineData.length = timelinesCount;
|
||||||
|
this.timelineDipMix.length = 0;
|
||||||
var timelineDipMix : Vector.<TrackEntry> = this.timelineDipMix;
|
var timelineDipMix : Vector.<TrackEntry> = this.timelineDipMix;
|
||||||
timelineDipMix.length = timelinesCount;
|
timelineDipMix.length = timelinesCount;
|
||||||
|
|
||||||
@ -101,16 +102,19 @@ package spine.animation {
|
|||||||
timelineData[i] = AnimationState.SUBSEQUENT;
|
timelineData[i] = AnimationState.SUBSEQUENT;
|
||||||
} else if (to == null || !to.hasTimeline(intId))
|
} else if (to == null || !to.hasTimeline(intId))
|
||||||
timelineData[i] = AnimationState.FIRST;
|
timelineData[i] = AnimationState.FIRST;
|
||||||
else {
|
else {
|
||||||
timelineData[i] = AnimationState.DIP;
|
|
||||||
for (var ii : int = mixingToLast; ii >= 0; ii--) {
|
for (var ii : int = mixingToLast; ii >= 0; ii--) {
|
||||||
var entry : TrackEntry = mixingTo[ii];
|
var entry : TrackEntry = mixingTo[ii];
|
||||||
if (!entry.hasTimeline(intId)) {
|
if (!entry.hasTimeline(intId)) {
|
||||||
if (entry.mixDuration > 0) timelineDipMix[i] = entry;
|
if (entry.mixDuration > 0) {
|
||||||
continue outer;
|
timelineData[i] = AnimationState.DIP_MIX;
|
||||||
}
|
timelineDipMix[i] = entry;
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
timelineDipMix[i] = null;
|
timelineData[i] = AnimationState.DIP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lastEntry;
|
return lastEntry;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user