[ts] Ported dipping problem fix, see #867

This commit is contained in:
badlogic 2017-03-31 12:12:22 +02:00
parent c03ae7064a
commit 030da37e6b
20 changed files with 380 additions and 45 deletions

View File

@ -328,6 +328,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -385,6 +386,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1461,6 +1461,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1588,7 +1589,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1596,6 +1599,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1736,9 +1740,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1884,6 +1903,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1941,6 +1984,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1949,6 +1993,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -328,6 +328,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -385,6 +386,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1461,6 +1461,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1588,7 +1589,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1596,6 +1599,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1736,9 +1740,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1884,6 +1903,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1941,6 +1984,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1949,6 +1993,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -235,6 +235,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -292,6 +293,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1043,6 +1043,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1170,7 +1171,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1178,6 +1181,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1318,9 +1322,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1466,6 +1485,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1523,6 +1566,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1531,6 +1575,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -235,6 +235,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -292,6 +293,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1043,6 +1043,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1170,7 +1171,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1178,6 +1181,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1318,9 +1322,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1466,6 +1485,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1523,6 +1566,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1531,6 +1575,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -235,6 +235,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -292,6 +293,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1043,6 +1043,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1170,7 +1171,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1178,6 +1181,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1318,9 +1322,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1466,6 +1485,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1523,6 +1566,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1531,6 +1575,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -235,6 +235,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -292,6 +293,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1043,6 +1043,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1170,7 +1171,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1178,6 +1181,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1318,9 +1322,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1466,6 +1485,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1523,6 +1566,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1531,6 +1575,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -39,6 +39,7 @@ module spine {
queue = new EventQueue(this);
propertyIDs = new IntSet();
animationsChanged = false;
multipleMixing = false;
timeScale = 1;
trackEntryPool = new Pool<TrackEntry>(() => new TrackEntry());
@ -183,7 +184,9 @@ module spine {
let timelineCount = from.animation.timelines.length;
let timelines = from.animation.timelines;
let timelinesFirst = from.timelinesFirst;
let alpha = from.alpha * entry.mixAlpha * (1 - mix);
let timelinesLast = this.multipleMixing ? null : from.timelinesLast;
let alphaBase = from.alpha * entry.mixAlpha;
let alphaMix = alphaBase * (1 - mix);
let firstFrame = from.timelinesRotation.length == 0;
if (firstFrame) Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -192,6 +195,7 @@ module spine {
for (let i = 0; i < timelineCount; i++) {
let timeline = timelines[i];
let setupPose = timelinesFirst[i];
let alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -348,10 +352,30 @@ module spine {
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
let mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
// A mix was interrupted, mix from the closest animation.
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
// If not completely mixed in, set mixAlpha so mixing out happens from current mix to zero.
if (from.mixingFrom != null && from.mixDuration > 0) current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
// The interrupted mix will mix out from its current percentage to zero.
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
// End the other animation after it is applied one last time.
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
@ -510,6 +534,33 @@ module spine {
let entry = this.tracks[i];
if (entry != null) this.checkTimelinesFirst(entry);
}
if (this.multipleMixing) return;
// Set timelinesLast for mixingFrom entries, from highest track to lowest that has mixingFrom.
propertyIDs.clear();
let lowestMixingFrom = n;
for (i = 0; i < n; i++) { // Find lowest track with a mixingFrom entry.
let entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null) continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) { // Find first non-null entry.
let entry = this.tracks[i];
if (entry == null) continue;
// Store properties for non-mixingFrom entry but don't set timelinesLast, which is only used for mixingFrom entries.
let timelines = entry.animation.timelines;
for (let ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
}
setTimelinesFirst (entry: TrackEntry) {
@ -578,6 +629,7 @@ module spine {
delay: number; trackTime: number; trackLast: number; nextTrackLast: number; trackEnd: number; timeScale: number;
alpha: number; mixTime: number; mixDuration: number; mixAlpha: number;
timelinesFirst = new Array<boolean>();
timelinesLast = new Array<boolean>();
timelinesRotation = new Array<number>();
reset () {
@ -586,6 +638,7 @@ module spine {
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
}

View File

@ -47,7 +47,7 @@ var transitionsDemo = function(loadingComplete, bgColor) {
state.apply(skeleton);
skeleton.updateWorldTransform();
bounds = { offset: new spine.Vector2(), size: new spine.Vector2() };
skeleton.getBounds(bounds.offset, bounds.size);
skeleton.getBounds(bounds.offset, bounds.size, []);
setupInput();
$("#transitions-overlay").removeClass("overlay-hide");
$("#transitions-overlay").addClass("overlay");