]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
adjust for left handed coordinate system in a reflected view
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 13 Oct 2010 17:18:55 +0000 (17:18 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 13 Oct 2010 17:18:55 +0000 (17:18 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10521 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index 7b251da3de5e3ae421802b1525777ace6f8fcf0d..a066f6cdb3342c221382ec3fb4e7732e6d7d9320 100644 (file)
@@ -8012,7 +8012,7 @@ static void R_View_SetFrustum(const int *scissor)
 {
        int i;
        double fpx, fnx, fpy, fny;
-       vec3_t forward, left, up, origin;
+       vec3_t forward, left, up, origin, v;
 
        if(scissor)
        {
@@ -8109,6 +8109,18 @@ static void R_View_SetFrustum(const int *scissor)
                CrossProduct(r_refdef.view.frustumcorner[0], r_refdef.view.frustumcorner[1], r_refdef.view.frustum[2].normal);
                CrossProduct(r_refdef.view.frustumcorner[3], r_refdef.view.frustumcorner[2], r_refdef.view.frustum[3].normal);
 
+               // in a NORMAL view, forward cross left == up
+               // in a REFLECTED view, forward cross left == down
+               // so our cross products above need to be adjusted for a left handed coordinate system
+               CrossProduct(forward, left, v);
+               if(DotProduct(v, up) < 0)
+               {
+                       VectorNegate(r_refdef.view.frustum[0].normal, r_refdef.view.frustum[0].normal);
+                       VectorNegate(r_refdef.view.frustum[1].normal, r_refdef.view.frustum[1].normal);
+                       VectorNegate(r_refdef.view.frustum[2].normal, r_refdef.view.frustum[2].normal);
+                       VectorNegate(r_refdef.view.frustum[3].normal, r_refdef.view.frustum[3].normal);
+               }
+
                // Leaving those out was a mistake, those were in the old code, and they
                // fix a reproducable bug in this one: frustum culling got fucked up when viewmatrix was an identity matrix
                // I couldn't reproduce it after adding those normalizations. --blub