Thanks Pharan! :makeup:
BinaryCats ha scritto:wonder: that's what I said!
Riiight. :think: Also, I wanted JSON and set/addAnimation calls and got a Unity project!
I can reproduce like this:
state.setAnimation(0, "walk", true);
state.addAnimation(0, "jump", true, 0.25f).mixDuration = 4;
state.addAnimation(0, "run", true, 1).mixDuration = 0;
There's also a similar test case where the run mixDuration is 1 second. This is what the track entries look like:
walk
then: jump, 4s mixDuration
then, during walk -> jump mix: run, 1s mixDuration
walk.mixingFrom = null
jump.mixingFrom = walk
jump.mixDuration = 4
run.mixingFrom = jump
run.mixDuration = 1
jump to run completes:
walk.mixingFrom = null
run.mixingFrom = walk
run.mixDuration = 4
I noticed in the code Pharan pointed out that TrackEntry#mixAlpha is not copied like mixDuration and mixTime. However, I still see snapping when jump completes. My conclusion is that it never makes sense to remove an entry from the middle of the mixingFrom linked list.
Let's say walk keys 0, jump keys 100, and run keys 200. walk to jump goes 0 to 100 and jump to run goes from that to 200. If jump to run completes and we remove jump, we are left with walk to run going 0 to 200. If walk to jump was 50% then walk to jump should have been 50, but after removing jump 50% becomes 100. This causes bones to snap when jump completes.
If we don't remove jump then it works correctly. walk to jump keeps mixing from 0 to 100, then run is applied at 100% (since the jump to run mix has completed). This example is a bit dumb because most likely run keys everything that walk and jump key, so completely overwrites their poses. However, it is possible to mix animations that don't key the same values, so it's possible that walk to jump would be changing something run doesn't.
If removing from the middle of the linked list didn't cause snapping, it would be nice to avoid a long linked list when repeatedly interrupting long mix durations. It seems this optimization isn't possible though. I've committed the changes to spine-libgdx and they'll make their way to the other runtimes soon.
[libgdx] Only remove mixingFrom entries from the end of the list.@99ca32d