From fc90cfdff490507521dcc7f49db46f2d35c3d93b Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Sun, 3 Mar 2013 13:46:31 +1030 Subject: [PATCH] light: use fadedist instead of scaledDistance() Signed-off-by: Kevin Shanahan --- light/ltface.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/light/ltface.c b/light/ltface.c index b6ed1244..a0fbf98b 100644 --- a/light/ltface.c +++ b/light/ltface.c @@ -439,30 +439,6 @@ CalcPoints(lightinfo_t * l) static int c_culldistplane; static int c_proper; -/* - * ============================================== - * LIGHT: Attenuation formulae setup functions - * ============================================== - */ -static vec_t -scaledDistance(vec_t distance, const entity_t *light) -{ - switch (light->formula) { - case LF_LINEAR: - return scaledist * light->atten * distance; - case LF_INVERSE: - case LF_INVERSE2: - case LF_INVERSE2A: - case LF_INFINITE: - case LF_LOCALMIN: - /* Return a small distance to prevent culling these lights, since we */ - /* know these formulae won't fade to nothing. */ - return (distance <= 0.0) ? -0.25 : 0.25; - default: - Error("Internal error: unknown light formula"); - } -} - static vec_t scaledLight(vec_t distance, const entity_t *light) { @@ -515,11 +491,11 @@ SingleLightFace(const entity_t *light, lightinfo_t * l, dist = DotProduct(light->origin, l->facenormal) - l->facedist; /* don't bother with lights behind the surface */ - if (scaledDistance(dist, light) < 0) + if (dist < 0) return; /* don't bother with light too far away */ - if (scaledDistance(dist, light) > abs(light->light)) { + if (dist > light->fadedist) { c_culldistplane++; return; }