Fix for screwy view when you lean too far forward.

This commit is contained in:
Andrzej Kapolka 2013-10-09 10:40:20 -07:00
parent 1b4daa8eb9
commit dfd5f7d53e

View file

@ -401,6 +401,10 @@ void ViewFrustum::computeOffAxisFrustum(float& left, float& right, float& bottom
far = max(far, -corners[i].z);
}
// make sure the near clip isn't too small to be valid
const float MIN_NEAR = 0.01f;
near = max(MIN_NEAR, near);
// get the near/far normal and use it to find the clip planes
glm::vec4 normal = eyeMatrix * glm::vec4(0.0f, 0.0f, 1.0f, 0.0f);
nearClipPlane = glm::vec4(-normal.x, -normal.y, -normal.z, glm::dot(normal, corners[0]));