From 5e15507f0fc13b7f22d39bf2cc77b16d606e8660 Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 13 Oct 2010 17:18:55 +0000 Subject: [PATCH] adjust for left handed coordinate system in a reflected view git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10521 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gl_rmain.c b/gl_rmain.c index 7b251da3..a066f6cd 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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 -- 2.39.2