[runtimes] Back ported fix for #1119 to 3.6.

This commit is contained in:
badlogic 2018-06-08 13:40:38 +02:00
parent cab8127626
commit 681584056b
20 changed files with 57 additions and 52 deletions

View File

@ -129,6 +129,9 @@ package spine.animation {
if (from == null) return true; if (from == null) return true;
var finished : Boolean = updateMixingFrom(from, delta); var finished : Boolean = updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
// 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 (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
@ -140,9 +143,7 @@ package spine.animation {
} }
return finished; return finished;
} }
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale; from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale; to.mixTime += delta * to.timeScale;
return false; return false;

View File

@ -325,6 +325,9 @@ int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTr
finished = _spAnimationState_updateMixingFrom(self, from, delta); finished = _spAnimationState_updateMixingFrom(self, from, delta);
from->animationLast = from->nextAnimationLast;
from->trackLast = from->nextTrackLast;
/* 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 (to->mixTime > 0 && (to->mixTime >= to->mixDuration || to->timeScale == 0)) { if (to->mixTime > 0 && (to->mixTime >= to->mixDuration || to->timeScale == 0)) {
/* Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). */ /* Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). */
@ -336,8 +339,6 @@ int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTr
return finished; return finished;
} }
from->animationLast = from->nextAnimationLast;
from->trackLast = from->nextTrackLast;
from->trackTime += delta * from->timeScale; from->trackTime += delta * from->timeScale;
to->mixTime += delta * to->timeScale; to->mixTime += delta * to->timeScale;
return 0; return 0;

View File

@ -166,6 +166,9 @@ public class AnimationState {
boolean finished = updateMixingFrom(from, delta); boolean finished = updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
// 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 (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
@ -177,8 +180,6 @@ public class AnimationState {
return finished; return finished;
} }
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale; from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale; to.mixTime += delta * to.timeScale;
return false; return false;
@ -535,7 +536,7 @@ public class AnimationState {
delay += duration * (1 + (int)(last.trackTime / duration)); delay += duration * (1 + (int)(last.trackTime / duration));
else else
delay += duration; delay += duration;
delay -= data.getMix(last.animation, animation); delay -= data.getMix(last.animation, animation);
} else } else
delay = 0; delay = 0;
} }

View File

@ -209,9 +209,9 @@ function TrackEntry:setTimelineData(to, mixingToArray, propertyIDs)
local entry = mixingTo[ii] local entry = mixingTo[ii]
local skip = false local skip = false
if not entry:hasTimeline(id) then if not entry:hasTimeline(id) then
if entry.mixDuration > 0 then if entry.mixDuration > 0 then
timelineData[i] = DIP_MIX timelineData[i] = DIP_MIX
timelineDipMix[i] = entry timelineDipMix[i] = entry
skip = true skip = true
break break
end end
@ -291,7 +291,7 @@ function AnimationState:update (delta)
current.delay = 0 current.delay = 0
end end
end end
if not skip then if not skip then
local _next = current.next local _next = current.next
if _next then if _next then
@ -328,7 +328,7 @@ function AnimationState:update (delta)
from = from.mixingFrom from = from.mixingFrom
end end
end end
current.trackTime = current.trackTime + currentDelta current.trackTime = current.trackTime + currentDelta
end end
end end
@ -342,8 +342,11 @@ function AnimationState:updateMixingFrom (to, delta)
local from = to.mixingFrom local from = to.mixingFrom
if from == nil then return true end if from == nil then return true end
local finished = self:updateMixingFrom(from, delta) local finished = self:updateMixingFrom(from, delta)
from.animationLast = from.nextAnimationLast
from.trackLast = from.nextTrackLast
-- 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 (to.mixTime > 0 and (to.mixTime >= to.mixDuration or to.timeScale == 0)) then if (to.mixTime > 0 and (to.mixTime >= to.mixDuration or to.timeScale == 0)) then
-- Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). -- Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
@ -355,8 +358,6 @@ function AnimationState:updateMixingFrom (to, delta)
return finished return finished
end end
from.animationLast = from.nextAnimationLast
from.trackLast = from.nextTrackLast
from.trackTime = from.trackTime + delta * from.timeScale from.trackTime = from.trackTime + delta * from.timeScale
to.mixTime = to.mixTime + delta * to.timeScale to.mixTime = to.mixTime + delta * to.timeScale
return false; return false;
@ -376,10 +377,10 @@ function AnimationState:apply (skeleton)
applied = true applied = true
local currrentPose = MixPose.currentLayered local currrentPose = MixPose.currentLayered
if i == 0 then currentPose = MixPose.current end if i == 0 then currentPose = MixPose.current end
-- Apply mixing from entries first. -- Apply mixing from entries first.
local mix = current.alpha local mix = current.alpha
if current.mixingFrom then if current.mixingFrom then
mix = mix * self:applyMixingFrom(current, skeleton, currentPose) mix = mix * self:applyMixingFrom(current, skeleton, currentPose)
elseif current.trackTime >= current.trackEnd and current.next == nil then elseif current.trackTime >= current.trackEnd and current.next == nil then
mix = 0 mix = 0
@ -401,7 +402,7 @@ function AnimationState:apply (skeleton)
for i,timeline in ipairs(timelines) do for i,timeline in ipairs(timelines) do
local pose = MixPose.currentPose local pose = MixPose.currentPose
if timelineData[i] >= FIRST then pose = MixPose.setup end if timelineData[i] >= FIRST then pose = MixPose.setup end
if timeline.type == Animation.TimelineType.rotate then if timeline.type == Animation.TimelineType.rotate then
self:applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, i * 2, self:applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, i * 2,
firstFrame) -- FIXME passing ii * 2, indexing correct? firstFrame) -- FIXME passing ii * 2, indexing correct?
@ -472,7 +473,7 @@ function AnimationState:applyMixingFrom (to, skeleton, currentPose)
local dipMix = timelineDipMix[i] local dipMix = timelineDipMix[i]
alpha = alpha * math_max(0, 1 - dipMix.mixtime / dipMix.mixDuration) alpha = alpha * math_max(0, 1 - dipMix.mixtime / dipMix.mixDuration)
end end
if not skipSubsequent then if not skipSubsequent then
from.totalAlpha = from.totalAlpha + alpha from.totalAlpha = from.totalAlpha + alpha
if timeline.type == Animation.TimelineType.rotate then if timeline.type == Animation.TimelineType.rotate then
@ -492,11 +493,11 @@ function AnimationState:applyMixingFrom (to, skeleton, currentPose)
end end
function AnimationState:applyRotateTimeline (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) function AnimationState:applyRotateTimeline (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame)
if firstFrame then if firstFrame then
timelinesRotation[i] = 0 timelinesRotation[i] = 0
timelinesRotation[i+1] = 0 timelinesRotation[i+1] = 0
end end
if alpha == 1 then if alpha == 1 then
timeline:apply(skeleton, 0, time, nil, 1, pose, MixDirection._in) timeline:apply(skeleton, 0, time, nil, 1, pose, MixDirection._in)
return return
@ -584,7 +585,7 @@ function AnimationState:queueEvents (entry, animationTime)
-- Queue complete if completed a loop iteration or the animation. -- Queue complete if completed a loop iteration or the animation.
local queueComplete = false local queueComplete = false
if entry.loop then if entry.loop then
queueComplete = duration == 0 or (trackLastWrapped > entry.trackTime % duration) queueComplete = duration == 0 or (trackLastWrapped > entry.trackTime % duration)
else else
queueComplete = (animationTime >= animationEnd and entry.animationLast < animationEnd) queueComplete = (animationTime >= animationEnd and entry.animationLast < animationEnd)
@ -650,11 +651,11 @@ function AnimationState:setCurrent (index, current, interrupt)
if interrupt then queue:interrupt(from) end if interrupt then queue:interrupt(from) end
current.mixingFrom = from current.mixingFrom = from
current.mixTime = 0 current.mixTime = 0
if from.mixingFrom and from.mixDuration > 0 then if from.mixingFrom and from.mixDuration > 0 then
current.interruptAlpha = current.interruptAlpha * math_min(1, from.mixTime / from.mixDuration) current.interruptAlpha = current.interruptAlpha * math_min(1, from.mixTime / from.mixDuration)
end end
from.timelinesRotation = {}; from.timelinesRotation = {};
end end
@ -711,7 +712,7 @@ function AnimationState:addAnimation (trackIndex, animation, loop, delay)
local entry = self:trackEntry(trackIndex, animation, loop, last) local entry = self:trackEntry(trackIndex, animation, loop, last)
local queue = self.queue local queue = self.queue
local data = self.data local data = self.data
if not last then if not last then
self:setCurrent(trackIndex, entry, true) self:setCurrent(trackIndex, entry, true)
queue:drain() queue:drain()
@ -786,7 +787,7 @@ function AnimationState:trackEntry (trackIndex, animation, loop, last)
entry.trackTime = 0 entry.trackTime = 0
entry.trackLast = -1 entry.trackLast = -1
entry.nextTrackLast = -1 entry.nextTrackLast = -1
entry.trackEnd = 999999999 entry.trackEnd = 999999999
entry.timeScale = 1 entry.timeScale = 1
entry.alpha = 1 entry.alpha = 1
@ -807,7 +808,7 @@ function AnimationState:disposeNext (entry)
queue:dispose(_next) queue:dispose(_next)
_next = _next.next _next = _next.next
end end
entry.next = nil entry.next = nil
end end
function AnimationState:_animationsChanged () function AnimationState:_animationsChanged ()
@ -816,10 +817,10 @@ function AnimationState:_animationsChanged ()
self.propertyIDs = {} self.propertyIDs = {}
local propertyIDs = self.propertyIDs local propertyIDs = self.propertyIDs
local mixingTo = self.mixingTo local mixingTo = self.mixingTo
for i, entry in pairs(self.tracks) do for i, entry in pairs(self.tracks) do
if entry then if entry then
entry:setTimelineData(nil, mixingTo, propertyIDs) entry:setTimelineData(nil, mixingTo, propertyIDs)
end end
end end
end end

View File

@ -1211,6 +1211,8 @@ var spine;
if (from == null) if (from == null)
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
@ -1219,8 +1221,6 @@ var spine;
} }
return finished; return finished;
} }
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale; from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale; to.mixTime += delta * to.timeScale;
return false; return false;
@ -9907,7 +9907,7 @@ var spine;
else { else {
for (var i = 0; i < config.atlasPages.length; i++) { for (var i = 0; i < config.atlasPages.length; i++) {
if (config.atlasPagesContent && config.atlasPagesContent[i]) { if (config.atlasPagesContent && config.atlasPagesContent[i]) {
assets.loadTextureData(config.atlasPages[i], config.atlasPagesContent[0]); assets.loadTextureData(config.atlasPages[i], config.atlasPagesContent[i]);
} }
else { else {
assets.loadTexture(config.atlasPages[i]); assets.loadTexture(config.atlasPages[i]);

File diff suppressed because one or more lines are too long

View File

@ -1211,6 +1211,8 @@ var spine;
if (from == null) if (from == null)
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
@ -1219,8 +1221,6 @@ var spine;
} }
return finished; return finished;
} }
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale; from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale; to.mixTime += delta * to.timeScale;
return false; return false;

File diff suppressed because one or more lines are too long

View File

@ -1211,6 +1211,8 @@ var spine;
if (from == null) if (from == null)
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
@ -1219,8 +1221,6 @@ var spine;
} }
return finished; return finished;
} }
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale; from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale; to.mixTime += delta * to.timeScale;
return false; return false;

File diff suppressed because one or more lines are too long

View File

@ -1211,6 +1211,8 @@ var spine;
if (from == null) if (from == null)
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
@ -1219,8 +1221,6 @@ var spine;
} }
return finished; return finished;
} }
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale; from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale; to.mixTime += delta * to.timeScale;
return false; return false;

File diff suppressed because one or more lines are too long

View File

@ -1211,6 +1211,8 @@ var spine;
if (from == null) if (from == null)
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
@ -1219,8 +1221,6 @@ var spine;
} }
return finished; return finished;
} }
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale; from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale; to.mixTime += delta * to.timeScale;
return false; return false;

File diff suppressed because one or more lines are too long

View File

@ -1211,6 +1211,8 @@ var spine;
if (from == null) if (from == null)
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0 || to.mixDuration == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
@ -1219,8 +1221,6 @@ var spine;
} }
return finished; return finished;
} }
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale; from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale; to.mixTime += delta * to.timeScale;
return false; return false;
@ -9244,7 +9244,7 @@ var spine;
else { else {
for (var i = 0; i < config.atlasPages.length; i++) { for (var i = 0; i < config.atlasPages.length; i++) {
if (config.atlasPagesContent && config.atlasPagesContent[i]) { if (config.atlasPagesContent && config.atlasPagesContent[i]) {
assets.loadTextureData(config.atlasPages[i], config.atlasPagesContent[0]); assets.loadTextureData(config.atlasPages[i], config.atlasPagesContent[i]);
} }
else { else {
assets.loadTexture(config.atlasPages[i]); assets.loadTexture(config.atlasPages[i]);

File diff suppressed because one or more lines are too long

View File

@ -114,6 +114,9 @@ module spine {
let finished = this.updateMixingFrom(from, delta); let finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
// 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 (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
@ -125,8 +128,6 @@ module spine {
return finished; return finished;
} }
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
from.trackTime += delta * from.timeScale; from.trackTime += delta * from.timeScale;
to.mixTime += delta * to.timeScale; to.mixTime += delta * to.timeScale;
return false; return false;