daMuzza I had assumed that animState->apply() overwrote all bone local values and so any previous modifications I made would be undone?
Yes, but AnimationState apply
only affects keyed properties. Properties not keyed in the animations being applied are not changed. You can use Skeleton setBonesToSetupPose
(or setToSetupPose
) to reset all bones to a known state (the setup pose).
daMuzza Previously I tried taking my two state copies of the bone positions/rotations in local space, and interpolating between them instead. This avoiding warping, but the legs that have Inherit_NoRotationOrReflection on them would always end up flipped in the wrong direction as soon as the interpolation began.
This sounds very close to what you want, just with a special case for the inherit mode(s) you use. Keeping everything in local space avoids some nasty behavior, like when interpolating world rotations.
daMuzza The side effect I'm seeing is that the top of the head on 'hero-pro' that I'm using for testing becomes slightly warped.
Hmm, hard to say why. Maybe more inherit mode pain, if the head (or neck/etc) bone doesn't inherit scale.
You might look at TransformConstraint. It has code to interpolate between local and world bone transform properties (the mix between the target bone and constrained bone(s)).
Note world rotations are by definition 0-360, because it is simply the direction the bone is pointing. When interpolating two world rotations, the challenge is there are 2 solutions: clockwise and counterclockwise. You can choose the shortest direction, but that may become the longest direction over time, as the rag doll and animation rotations change. When that happens your shortest direction interpolation flips to the other side -- a very noticeable, jarring jump. AnimationState solves this by remembering the shortest direction of the first interpolation and sticking with it. If you can stay in local space, it's much better because you won't have this problem at all.
I think you can do this in a solid way. I'm happy to add some utilities that would help, but I'm not sure what utilities would be useful in our generic runtimes, where there isn't a ragdoll physics system to integrate with. Maybe Harald has some input (on Monday) or can point to spine-unity code relevant to your use case.