From dfd5f7d53e0d5d24457dcdb9e146b2ed72bcfa09 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 9 Oct 2013 10:40:20 -0700 Subject: [PATCH] Fix for screwy view when you lean too far forward. --- libraries/voxels/src/ViewFrustum.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index b6249ad3ab..51d7639678 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -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]));