MyAvatar: refactored updateFromHMDSensorMatrix() a bit by splitting it into several methods, because
it was getting quite large and becoming hard to follow.
* beginStraighteningLean() - can be called when we would like to trigger a re-centering action.
* shouldBeginStraighteningLean() - contains some of the logic to decide if we should begin a re-centering action.
for now it encapulates the capsule check.
* processStraighteningLean() - performs the actual re-centering calculation.
New code was added to MyAvatar::updateFromHMDSensorMatrix() to trigger re-centering when the avatar speed rises
over a threshold.
Secondly the Rig::computeMotionAnimationState() state machine for animGraph added a state change hysteresis
of 100ms. This hysteresis should help smooth over two issues.
1) When the delta position is 0, because the physics timestep was not evaluated.
2) During re-centering due to desired motion, the avatar velocity can fluctuate causing undesired animation state fluctuation.
This should help the case when a user avatar is stuck in an
uncomfortable pose for a long period of time. If they stop
moving their head, the body should recenter itself and
appear more natural.
Added an AtRestDetector class. That tracks the average and variance
of both position and rotation (quaternion logarithms), then
detects when the variance falls under a threshold.
Also, renamed variables with the straighting prefix to straightening.
The calculation that determined where the body position relative to the HMD
was incorrect, one of the components was in the wrong coordinate frame.
Now use the skeleton's bind pose to compute the proper avatar offsets for the eyes, neck and hips.
Use these offsets to calculate where the hips should be given a specific hmd position and orientation.
Also, added a bug fix for Rig, which would cause a -1 index deference when an avatar was missing
certain named joints, such as, "LeftEye", "Neck" and "Head".
Moved myAvatar->updateFromHMDSensorMatrix from Application::update
back into Application::paintGL, so it occurs between
displayPlugin->preRender() and displayPlugin->display().
We should render with the most up-to-date camera position as possible,
and sample it at the same frequency as the display rate.
This is a blend of the previous 'sitting' and 'standing' HMD modes.
Basically, when you move your head within a small range (20cm) your
avatar will lean appropriately, however when you cross that threshold
your body will move underneath you, re-centering your head above the body.
While this occurs the avatar should play the appropriate walking animations.