mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-21 17:26:45 +08:00
Debugging AnimationState.
This commit is contained in:
parent
3bf261dc4b
commit
2e87ab8f9f
@ -60,6 +60,9 @@ public class AnimationState {
|
|||||||
boolean animationsChanged;
|
boolean animationsChanged;
|
||||||
private float timeScale = 1;
|
private float timeScale = 1;
|
||||||
|
|
||||||
|
StringBuilder last = new StringBuilder();
|
||||||
|
StringBuilder log = new StringBuilder();
|
||||||
|
|
||||||
final Pool<TrackEntry> trackEntryPool = new Pool() {
|
final Pool<TrackEntry> trackEntryPool = new Pool() {
|
||||||
protected Object newObject () {
|
protected Object newObject () {
|
||||||
return new TrackEntry();
|
return new TrackEntry();
|
||||||
@ -169,6 +172,7 @@ public class AnimationState {
|
|||||||
// Apply current entry.
|
// Apply current entry.
|
||||||
float animationLast = current.animationLast, animationTime = current.getAnimationTime();
|
float animationLast = current.animationLast, animationTime = current.getAnimationTime();
|
||||||
Array<Timeline> timelines = current.animation.timelines;
|
Array<Timeline> timelines = current.animation.timelines;
|
||||||
|
log("apply current: " + current + ", mix: " + mix + " * " + current.alpha);
|
||||||
if (mix == 1) {
|
if (mix == 1) {
|
||||||
for (int ii = 0, n = timelines.size; ii < n; ii++)
|
for (int ii = 0, n = timelines.size; ii < n; ii++)
|
||||||
timelines.get(ii).apply(skeleton, animationLast, animationTime, events, 1, false, false);
|
timelines.get(ii).apply(skeleton, animationLast, animationTime, events, 1, false, false);
|
||||||
@ -194,7 +198,17 @@ public class AnimationState {
|
|||||||
|
|
||||||
queue.drain();
|
queue.drain();
|
||||||
|
|
||||||
System.out.println();
|
if (!log.toString().equals(last.toString())) {
|
||||||
|
System.out.println(log);
|
||||||
|
last.setLength(0);
|
||||||
|
last.append(log);
|
||||||
|
}
|
||||||
|
log.setLength(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void log (String m) {
|
||||||
|
log.append(m);
|
||||||
|
log.append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
private float applyMixingFrom (TrackEntry entry, Skeleton skeleton, float alpha) {
|
private float applyMixingFrom (TrackEntry entry, Skeleton skeleton, float alpha) {
|
||||||
@ -222,12 +236,14 @@ public class AnimationState {
|
|||||||
if (firstFrame) from.timelinesRotation.setSize(timelineCount << 1);
|
if (firstFrame) from.timelinesRotation.setSize(timelineCount << 1);
|
||||||
float[] timelinesRotation = from.timelinesRotation.items;
|
float[] timelinesRotation = from.timelinesRotation.items;
|
||||||
|
|
||||||
System.out.println(entry.mixingFrom + " -> " + entry + ": " + entry.mixTime / entry.mixDuration);
|
log("applyMixingFrom: " + entry.mixingFrom + " -> " + entry + ", mix: " + entry.mixTime / entry.mixDuration);
|
||||||
|
if (timelineCount == 0) log("apply from: " + from + " " + alphaFull + " * " + entry.alpha);
|
||||||
|
|
||||||
for (int i = 0; i < timelineCount; i++) {
|
for (int i = 0; i < timelineCount; i++) {
|
||||||
Timeline timeline = timelines.get(i);
|
Timeline timeline = timelines.get(i);
|
||||||
boolean setupPose = timelinesFirst[i];
|
boolean setupPose = timelinesFirst[i];
|
||||||
float a = timelinesLast[i] ? alphaMix : alphaFull;
|
float a = timelinesLast[i] ? alphaMix : alphaFull;
|
||||||
|
log("apply from: " + from + " " + a + " * " + entry.alpha);
|
||||||
if (timeline instanceof RotateTimeline) {
|
if (timeline instanceof RotateTimeline) {
|
||||||
applyRotateTimeline((RotateTimeline)timeline, skeleton, animationLast, animationTime, events, a, setupPose, setupPose,
|
applyRotateTimeline((RotateTimeline)timeline, skeleton, animationLast, animationTime, events, a, setupPose, setupPose,
|
||||||
timelinesRotation, i << 1, firstFrame);
|
timelinesRotation, i << 1, firstFrame);
|
||||||
@ -382,18 +398,29 @@ public class AnimationState {
|
|||||||
queue.drain();
|
queue.drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCurrent (int index, TrackEntry entry) {
|
private void setCurrent (int index, TrackEntry current) {
|
||||||
TrackEntry current = expandToIndex(index);
|
TrackEntry from = expandToIndex(index);
|
||||||
tracks.set(index, entry);
|
tracks.set(index, current);
|
||||||
|
|
||||||
if (current != null) {
|
if (from != null) {
|
||||||
queue.interrupt(current);
|
queue.interrupt(from);
|
||||||
entry.mixingFrom = current;
|
current.mixingFrom = from;
|
||||||
entry.mixTime = Math.max(0, entry.mixDuration - current.trackTime);
|
// entry.mixTime = Math.max(0, entry.mixDuration - current.trackTime);
|
||||||
current.timelinesRotation.clear(); // BOZO - Needed? Recursive?
|
// log("setCurrent mixTime: " + entry.mixDuration + " - " + current.trackTime + " = " + entry.mixTime);
|
||||||
|
current.mixTime = 0;
|
||||||
|
|
||||||
|
from.timelinesRotation.clear(); // BOZO - Needed? Recursive?
|
||||||
|
|
||||||
|
// float alpha = 1;
|
||||||
|
float duration = from.animationEnd - from.animationStart;
|
||||||
|
if (duration > 0) from.alpha *= (from.getAnimationTime() - from.animationStart) / duration;
|
||||||
|
// do {
|
||||||
|
// from.alpha *= alpha;
|
||||||
|
// from = from.mixingFrom;
|
||||||
|
// } while (from != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
queue.start(entry);
|
queue.start(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see #setAnimation(int, Animation, boolean) */
|
/** @see #setAnimation(int, Animation, boolean) */
|
||||||
@ -699,7 +726,7 @@ public class AnimationState {
|
|||||||
float eventThreshold, attachmentThreshold, drawOrderThreshold;
|
float eventThreshold, attachmentThreshold, drawOrderThreshold;
|
||||||
float animationStart, animationEnd, animationLast, nextAnimationLast;
|
float animationStart, animationEnd, animationLast, nextAnimationLast;
|
||||||
float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale;
|
float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale;
|
||||||
float alpha, mixTime, mixDuration;
|
float alpha, mixTime, mixDuration, mixAlpha;
|
||||||
final BooleanArray timelinesFirst = new BooleanArray(), timelinesLast = new BooleanArray();
|
final BooleanArray timelinesFirst = new BooleanArray(), timelinesLast = new BooleanArray();
|
||||||
final FloatArray timelinesRotation = new FloatArray();
|
final FloatArray timelinesRotation = new FloatArray();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user