From: havoc Date: Mon, 2 Dec 2002 01:43:50 +0000 (+0000) Subject: reverted to fast version of trianglefacinglight code, as it was found to be a speed... X-Git-Tag: RELEASE_0_2_0_RC1~38 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=71e7da73e333310428dc7e3b8bbfe06a0a299e4e;p=xonotic%2Fdarkplaces.git reverted to fast version of trianglefacinglight code, as it was found to be a speed gain in benchmarks compared to the light radius checking version fixed an unitialized variable warning git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2668 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/r_shadow.c b/r_shadow.c index 582e7e41..fdbfc47a 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -128,7 +128,7 @@ void R_Shadow_MakeTriangleShadowFlags(const int *elements, const float *vertex, // of the comparison use it, therefore they are both multiplied the // same amount... furthermore the subtract can be done on the // vectors, saving a little bit of math in the dotproducts -#if 0 +#if 1 // fast version // subtracts v1 from v0 and v2, combined into a crossproduct, // combined with a dotproduct of the light location relative to the @@ -142,7 +142,7 @@ void R_Shadow_MakeTriangleShadowFlags(const int *elements, const float *vertex, #else // readable version { - float dir0[3], dir1[3], temp[3], f; + float dir0[3], dir1[3], temp[3]; // calculate two mostly perpendicular edge directions VectorSubtract(v0, v1, dir0); @@ -161,9 +161,7 @@ void R_Shadow_MakeTriangleShadowFlags(const int *elements, const float *vertex, // I.E. flat, so all points give the same answer) // the normal is not normalized because it is used on both sides of // the comparison, so it's magnitude does not matter - //trianglefacinglight[i] = DotProduct(relativelightorigin, temp) >= DotProduct(v0, temp); - f = DotProduct(relativelightorigin, temp) - DotProduct(v0, temp); - trianglefacinglight[i] = f > 0 && f < lightradius * sqrt(DotProduct(temp, temp)); + trianglefacinglight[i] = DotProduct(relativelightorigin, temp) >= DotProduct(v0, temp); } #endif } @@ -612,6 +610,8 @@ int R_Shadow_ScissorForBBoxAndSphere(const float *mins, const float *maxs, const return true; // ok some of it is infront of the view, transform each corner back to // worldspace and then to screenspace and make screen rect + // initialize these variables just to avoid compiler warnings + x1 = y1 = x2 = y2 = 0; for (i = 0;i < 8;i++) { v2[0] = (i & 1) ? smins[0] : smaxs[0];