From 925bbd08c928223d1ed993702517f4374976156b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Tue, 25 Feb 2014 14:33:49 +0200 Subject: [PATCH] Client|Stereo 3D: Cleanup --- doomsday/client/src/gl/gl_main.cpp | 41 ----------- doomsday/client/src/render/rend_main.cpp | 94 +++--------------------- 2 files changed, 11 insertions(+), 124 deletions(-) diff --git a/doomsday/client/src/gl/gl_main.cpp b/doomsday/client/src/gl/gl_main.cpp index 020fb978ac..73d07503df 100644 --- a/doomsday/client/src/gl/gl_main.cpp +++ b/doomsday/client/src/gl/gl_main.cpp @@ -562,47 +562,6 @@ Matrix4f GL_GetProjectionMatrix() return vrCfg().projectionMatrix(Rend_FieldOfView(), size, glNearClip, glFarClip); } -#if 0 - // We're assuming pixels are squares. - float aspect = viewpw / (float) viewph; - - if (vrCfg().mode() == VRConfig::OculusRift) - { - aspect = vrCfg().oculusRift().aspect(); - // A little trigonometry to apply aspect ratio to angles - float x = tan(0.5 * de::degreeToRadian(Rend_FieldOfView())); - yfov = de::radianToDegree(2.0 * atan2(x/aspect, 1.0f)); - } - else - { - yfov = Rend_FieldOfView() / aspect; - } - - float fH = tan(0.5 * de::degreeToRadian(yfov)) * glNearClip; - float fW = fH*aspect; - /* - * Asymmetric frustum shift is computed to realign screen-depth items after view point has shifted. - * Asymmetric frustum shift method is probably superior to competing toe-in stereo 3D method: - * - AFS preserves identical near and far clipping planes in both views - * - AFS shows items at/near infinity better - * - AFS conforms to what stereo 3D photographers call "ortho stereo" - * Asymmetric frustum shift is used for all stereo 3D modes except Oculus Rift mode, which only - * applies the viewpoint shift. - */ - float frustumShift = 0; - if (vrCfg().frustumShift()) - { - frustumShift = vrCfg().eyeShift() * glNearClip / vrCfg().screenDistance(); - } - - return Matrix4f::frustum(-fW - frustumShift, fW - frustumShift, - -fH, fH, - glNearClip, glFarClip) * - Matrix4f::translate(Vector3f(-vrCfg().eyeShift(), 0, 0)) * - Matrix4f::scale(Vector3f(1, 1, -1)); -} -#endif - void GL_ProjectionMatrix() { DENG_ASSERT_IN_MAIN_THREAD(); diff --git a/doomsday/client/src/render/rend_main.cpp b/doomsday/client/src/render/rend_main.cpp index cd7e2fd7e9..ef0a701557 100644 --- a/doomsday/client/src/render/rend_main.cpp +++ b/doomsday/client/src/render/rend_main.cpp @@ -512,103 +512,31 @@ Matrix4f Rend_GetModelViewMatrix(int consoleNum, bool useAngles) if(useAngles) { - //bool scheduledLate = false; - float yaw = vang; float pitch = vpitch; float roll = 0; - /* - static float storedPitch, storedRoll, storedYaw; - */ + /// @todo Elevate roll angle use into viewer_t, and maybe all the way up into player + /// model. /* - if(VR::viewPositionHeld()) + * Pitch and yaw can be taken directly from the head tracker, as the game is aware of + * these values and is syncing with them independently (however, game has more + * latency). + */ + if((vrCfg().mode() == VRConfig::OculusRift) && vrCfg().oculusRift().isReady()) { - roll = storedRoll; - pitch = storedPitch; - yaw = storedYaw; - } - else*/ + Vector3f const pry = vrCfg().oculusRift().headOrientation(); - { - /// @todo Elevate roll angle use into viewer_t, and maybe all the way up into player - /// model. + // Use angles directly from the Rift for best response. + roll = -radianToDegree(pry[1]); + pitch = radianToDegree(pry[0]); - /* - * Pitch and yaw can be taken directly from the head tracker, as the game is aware of - * these values and is syncing with them independently (however, game has more - * latency). - */ - if((vrCfg().mode() == VRConfig::OculusRift) && vrCfg().oculusRift().isReady()) - { - Vector3f const pry = vrCfg().oculusRift().headOrientation(); - - // Use angles directly from the Rift for best response. - roll = -radianToDegree(pry[1]); - pitch = radianToDegree(pry[0]); - -#if 0 - - static float previousRiftYaw = 0; - static float previousVang2 = 0; - - // Desired view angle without interpolation? - float vang2 = viewData->latest.angle / (float) ANGLE_MAX *360 - 90; - - // Late-scheduled update - scheduledLate = true; - roll = -radianToDegree(pry[1]); - pitch = radianToDegree(pry[0]); - - // Yaw might have a contribution from mouse/keyboard. - // So only late schedule if it seems to be head tracking only. - yaw = vang2; // default no late schedule - float currentRiftYaw = radianToDegree(pry[2]); - float dRiftYaw = currentRiftYaw - previousRiftYaw; - while (dRiftYaw > 180) dRiftYaw -= 360; - while (dRiftYaw < -180) dRiftYaw += 360; - float dVang = vang2 - previousVang2; - while (dVang > 180) dVang -= 360; - while (dVang < -180) dVang += 360; - if (abs(dVang) < 2.0 * abs(dRiftYaw)) // Mostly head motion - { - yaw = storedYaw + dRiftYaw; - float dy = vang2 - yaw; - while (dy > 180) dy -= 360; - while (dy < -180) dy += 360; - yaw += 0.05 * dy; // ease slowly toward target angle - } - else - { - yaw = vang2; // No interpolation if not from head tracker - } - - previousRiftYaw = currentRiftYaw; - previousVang2 = vang2; -#endif - } - - /* - if(!scheduledLate) - { - // Vanilla angle update - roll = 0; - pitch = vpitch; - yaw = vang; - }*/ } modelView = Matrix4f::rotate(roll, Vector3f(0, 0, 1)) * Matrix4f::rotate(pitch, Vector3f(1, 0, 0)) * Matrix4f::rotate(yaw, Vector3f(0, 1, 0)); - - /* - // Keep these for possible use in later frames. - storedRoll = roll; - storedPitch = pitch; - storedYaw = yaw; - */ } return (modelView *