From a9d9ba2b84f8598e6724203a51d322dfd8b9e16b Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 12 May 2004 16:52:39 +0000 Subject: [PATCH] Tomaz's patch for optimized vectorlength calls in the vertex lighting code, as Vic suggested git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4144 d7cf8633-e32d-0410-b094-e92efae38249 --- r_shadow.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/r_shadow.c b/r_shadow.c index 0b1ec407..a0fd87af 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -1108,7 +1108,7 @@ static void R_Shadow_VertexShadingWithXYZAttenuation(int numverts, const float * if ((dot = DotProduct(n, v)) > 0) { dist = sqrt(dist); - intensity = dot / (VectorLength(v) * VectorLength(n)); + intensity = dot / sqrt(VectorLength2(v) * VectorLength2(n)); intensity *= pow(1 - dist, r_shadow_attenpower) * r_shadow_attenscale; VectorScale(lightcolor, intensity, color4f); color4f[3] = 1; @@ -1139,7 +1139,7 @@ static void R_Shadow_VertexShadingWithZAttenuation(int numverts, const float *ve Matrix4x4_Transform3x3(m, normal3f, n); if ((dot = DotProduct(n, v)) > 0) { - intensity = dot / (VectorLength(v) * VectorLength(n)); + intensity = dot / sqrt(VectorLength2(v) * VectorLength2(n)); intensity *= pow(1 - dist, r_shadow_attenpower) * r_shadow_attenscale; VectorScale(lightcolor, intensity, color4f); color4f[3] = 1; @@ -1168,7 +1168,7 @@ static void R_Shadow_VertexShading(int numverts, const float *vertex3f, const fl Matrix4x4_Transform3x3(m, normal3f, n); if ((dot = DotProduct(n, v)) > 0) { - intensity = dot / (VectorLength(v) * VectorLength(n)); + intensity = dot / sqrt(VectorLength2(v) * VectorLength2(n)); VectorScale(lightcolor, intensity, color4f); color4f[3] = 1; } -- 2.39.2