mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-05 06:44:56 +08:00
Always mix, even when mix duration is 0, to give the old animation a chance to reset its changes.
This commit is contained in:
parent
42e3b95e33
commit
ef2a440655
@ -511,13 +511,28 @@ public class AnimationStateTest {
|
||||
|
||||
expect(1, "event 0", 0, 0), //
|
||||
expect(1, "event 14", 0.5f, 0.5f), //
|
||||
expect(1, "event 30", 1, 1), //
|
||||
expect(1, "complete", 1, 1), //
|
||||
expect(1, "end", 1, 1.1f) //
|
||||
|
||||
expect(0, "start", 0.1f, 0.8f), //
|
||||
|
||||
expect(1, "interrupt", 0.8f, 0.8f), //
|
||||
expect(1, "end", 0.8f, 0.8f), //
|
||||
|
||||
expect(0, "event 0", 0.1f, 0.8f), //
|
||||
expect(0, "event 14", 0.5f, 1.2f), //
|
||||
expect(0, "event 30", 1, 1.7f), //
|
||||
expect(0, "complete", 1, 1.7f), //
|
||||
expect(0, "end", 1, 1.8f) //
|
||||
);
|
||||
state.setAnimation(0, "events1", false); // First should be ignored.
|
||||
state.setAnimation(0, "events2", false);
|
||||
run(0.1f, 1000, null);
|
||||
run(0.1f, 1000, new TestListener() {
|
||||
public void frame (float time) {
|
||||
if (MathUtils.isEqual(time, 0.8f)) {
|
||||
state.setAnimation(0, "events2", false); // First should be ignored.
|
||||
state.setAnimation(0, "events1", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setup("addAnimation with delay on empty track", // 22
|
||||
expect(0, "start", 0, 0), //
|
||||
|
||||
@ -121,8 +121,12 @@ public class AnimationState {
|
||||
|
||||
float mix = current.alpha;
|
||||
if (current.mixingFrom != null) {
|
||||
mix *= current.mixTime / current.mixDuration;
|
||||
if (mix > 1) mix = 1;
|
||||
if (current.mixDuration == 0)
|
||||
mix = 1;
|
||||
else {
|
||||
mix *= current.mixTime / current.mixDuration;
|
||||
if (mix > 1) mix = 1;
|
||||
}
|
||||
applyMixingFrom(current.mixingFrom, skeleton, mix);
|
||||
if (mix == 1) {
|
||||
queue.end(current.mixingFrom);
|
||||
@ -254,15 +258,12 @@ public class AnimationState {
|
||||
|
||||
queue.interrupt(current);
|
||||
|
||||
if (entry.mixDuration > 0) {
|
||||
// If a mix is in progress, mix from the closest animation.
|
||||
if (mixingFrom != null && current.mixTime / current.mixDuration < 0.5f) {
|
||||
entry.mixingFrom = mixingFrom;
|
||||
mixingFrom = current;
|
||||
} else
|
||||
entry.mixingFrom = current;
|
||||
// If a mix is in progress, mix from the closest animation.
|
||||
if (mixingFrom != null && current.mixTime / current.mixDuration < 0.5f) {
|
||||
entry.mixingFrom = mixingFrom;
|
||||
mixingFrom = current;
|
||||
} else
|
||||
queue.end(current);
|
||||
entry.mixingFrom = current;
|
||||
|
||||
if (mixingFrom != null) queue.end(mixingFrom);
|
||||
}
|
||||
@ -339,16 +340,17 @@ public class AnimationState {
|
||||
if (animation == null) throw new IllegalArgumentException("animation cannot be null.");
|
||||
TrackEntry current = expandToIndex(trackIndex);
|
||||
TrackEntry entry = trackEntry(trackIndex, animation, loop, current);
|
||||
if (current != null) {
|
||||
if (current == null)
|
||||
setCurrent(trackIndex, entry);
|
||||
else {
|
||||
freeAll(current.next);
|
||||
if (current.trackLast == -1) // If current was never applied, don't mix from it, just replace it.
|
||||
if (current.trackLast == -1) // If current was never applied, replace it.
|
||||
setCurrent(trackIndex, entry);
|
||||
else {
|
||||
current.next = entry;
|
||||
entry.delay = current.trackLast;
|
||||
}
|
||||
} else
|
||||
setCurrent(trackIndex, entry);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -375,7 +377,9 @@ public class AnimationState {
|
||||
|
||||
TrackEntry entry = trackEntry(trackIndex, animation, loop, last);
|
||||
|
||||
if (last != null) {
|
||||
if (last == null)
|
||||
setCurrent(trackIndex, entry);
|
||||
else {
|
||||
last.next = entry;
|
||||
if (delay <= 0) {
|
||||
float duration = last.animationEnd - last.animationStart;
|
||||
@ -384,8 +388,7 @@ public class AnimationState {
|
||||
else
|
||||
delay = 0;
|
||||
}
|
||||
} else
|
||||
setCurrent(trackIndex, entry);
|
||||
}
|
||||
|
||||
entry.delay = delay;
|
||||
return entry;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user