Fixing the avatar / HMD pose compisition for Oculus

This commit is contained in:
Bradley Austin Davis 2015-07-23 17:48:06 -04:00
parent 3d2139691c
commit 00342d2c76
2 changed files with 6 additions and 4 deletions

View file

@ -942,13 +942,13 @@ void Application::paintGL() {
// Using the latter will cause the camera to wobble with idle animations,
// or with changes from the face tracker
_myCamera.setPosition(_myAvatar->getDefaultEyePosition());
if (!getActiveDisplayPlugin()->isHmd()) {
_myCamera.setPosition(_myAvatar->getDefaultEyePosition());
_myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation());
} else {
auto camMat = _myAvatar->getSensorToWorldMatrix() * getHMDSensorPose();
_myCamera.setPosition(extractTranslation(camMat));
_myCamera.setRotation(glm::quat_cast(camMat));
// The plugin getModelview() call below will compose the base
// avatar transform with the HMD pose.
_myCamera.setRotation(_myAvatar->getOrientation());
}
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
if (isHMDMode()) {

View file

@ -65,6 +65,8 @@ glm::mat4 OculusBaseDisplayPlugin::getEyePose(Eye eye) const {
return toGlm(_eyePoses[eye]);
}
// Should NOT be used for rendering as this will mess up timewarp. Use the getModelview() method above for
// any use of head poses for rendering, ensuring you use the correct eye
glm::mat4 OculusBaseDisplayPlugin::getHeadPose() const {
ovrTrackingState state = ovrHmd_GetTrackingState(_hmd, 0.0f);
return toGlm(state.HeadPose.ThePose);