highfidelity/hifi — pull request #3828 by AndrewMeadows (2014-11-19 18:07:22+00:00)
Title: don't slide feet during idle animations

Philip asked if we could hack the avatar skeleton to shift its hips such that the feet do not slide when running an idle animation. This provides such a feature which can be enabled via the menu: Avatar --> Shift hips for idle animations, which defaults to false if never yet set.

This is a bit of a HACK although it shows promise as a proper feature. It might be possible to enhance the logic so that the animation itself could actually move the avatar around (rather than just provide a render offset for the skeleton model).

Here is how it works:

(1) Both toe joint positions (if they exist) are examined to determine the one that has the lowest y value in the avatar frame. This becomes the "standing foot" and its avatar-frame "step position" is remembered.

(2) As the animation moves the standing foot around we compute the offset of this foot from its step position and compute an offset to move the hips such that the foot appears to remain stationary.

(3) If the other toe joint happens to drop significantly below the other then it becomes the new standing foot, and the offsets are adjusted accordingly.

BTW, one theoretical aspect of this feature is that if you have an animation where the avatar pulls its feet up (for instance, goes into a crouch) then the avatar's apparent hip location should actually drop down such that the standing foot stays in one spot. I haven't tested this but it should work.

Here are its problems / limitations:

(A) Like the JS script call MyAvatar::setSkeletonOffset() the hips offset only works when the avatar's client camera is in third person. This is true not only for the local state, but for the state that is relayed up through the avatar-mixer for other clients. So when switching to first-person the feature stops working and everyone sees the idle animation feet start to slip. This was done to avoid breaking any camera placement stuff when in oculus.

(B) It is possible for a "walking" idle animation to cause the hips offset to increase indefinitely... up to a limit of 1.0 meter. When the hips offset reaches the limit the avatar will start to treadmill in place.

(C) The logic doesn't know an standing animation from a anything else, so if the avatar is running a strange non-standing animation then it might look bad when the lowest foot does not move.

(D) This feature only works for interface avatars -- does not work for bots.