]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Tomaz's patch for optimized vectorlength calls in the vertex lighting code, as Vic...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 12 May 2004 16:52:39 +0000 (16:52 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 12 May 2004 16:52:39 +0000 (16:52 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4144 d7cf8633-e32d-0410-b094-e92efae38249

r_shadow.c

index 0b1ec40795b3a775b0e6c45482ce4122a3cc3d46..a0fd87af79050475992e8f029e7782bf1ffdcc57 100644 (file)
@@ -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;
                }