Skip to content

Commit

Permalink
Client|Stereo 3D: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 25, 2014
1 parent ea8ef79 commit 925bbd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 124 deletions.
41 changes: 0 additions & 41 deletions doomsday/client/src/gl/gl_main.cpp
Expand Up @@ -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();
Expand Down
94 changes: 11 additions & 83 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -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 *
Expand Down

0 comments on commit 925bbd0

Please sign in to comment.