in deriveBodyFromHMDSensor, avoid using invalid head pose

This commit is contained in:
Seth Alves 2017-06-05 08:58:40 -07:00
parent 1b719ee654
commit 27669d44a7

View file

@ -2338,10 +2338,13 @@ glm::quat MyAvatar::getWorldBodyOrientation() const {
// old school meat hook style
glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
// HMD is in sensor space.
const glm::vec3 headPosition = getHeadControllerPoseInSensorFrame().translation;
const glm::quat headOrientation = getHeadControllerPoseInSensorFrame().rotation * Quaternions::Y_180;
glm::vec3 headPosition;
glm::quat headOrientation;
auto headPose = getHeadControllerPoseInSensorFrame();
if (headPose.isValid()) {
headPosition = getHeadControllerPoseInSensorFrame().translation;
headOrientation = getHeadControllerPoseInSensorFrame().rotation * Quaternions::Y_180;
}
const glm::quat headOrientationYawOnly = cancelOutRollAndPitch(headOrientation);
const Rig& rig = _skeletonModel->getRig();