]> 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)
committerRudolf Polzer <divverent@alientrap.org>
Wed, 13 Oct 2010 19:28:20 +0000 (21:28 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10521 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=5e15507f0fc13b7f22d39bf2cc77b16d606e8660

gl_rmain.c

index 72d76872e9ddf1b7355bdeba0bc43db96595de1f..bb6ae16808936f61c2040190a37443edddd72896 100644 (file)
@@ -7317,7 +7317,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)
        {
@@ -7414,6 +7414,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