From eb566c3b70d3d64b2d8e3ecef9f4403f65aa7fcf Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Mon, 25 Mar 2024 23:05:58 +0200 Subject: [PATCH] files/light: rearrange light code --- src/client/refresh/files/light.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/client/refresh/files/light.c b/src/client/refresh/files/light.c index 753a408f..96d03312 100644 --- a/src/client/refresh/files/light.c +++ b/src/client/refresh/files/light.c @@ -297,20 +297,19 @@ R_AddDynamicLights(const msurface_t *surf, const refdef_t *r_newrefdef, float *s_blocklights, const float *s_blocklights_max) { int lnum; - float fdist, frad, fminlight; - vec3_t impact, local; - int t; - int i; int smax, tmax; - dlight_t *dl; - float *plightdest; - float fsacc, ftacc; smax = (surf->extents[0] >> surf->lmshift) + 1; tmax = (surf->extents[1] >> surf->lmshift) + 1; for (lnum = 0; lnum < r_newrefdef->num_dlights; lnum++) { + float ftacc, fdist, frad, fminlight; + vec3_t impact, local; + float *plightdest; + dlight_t *dl; + int t, i; + if (!(surf->dlightbits & (1 << lnum))) { continue; /* not lit by this light */ @@ -347,6 +346,7 @@ R_AddDynamicLights(const msurface_t *surf, const refdef_t *r_newrefdef, for (t = 0, ftacc = 0; t < tmax; t++, ftacc += (1 << surf->lmshift)) { + float fsacc; int s, td; td = local[1] - ftacc; @@ -358,7 +358,7 @@ R_AddDynamicLights(const msurface_t *surf, const refdef_t *r_newrefdef, td *= surf->lmvlen[1]; - for (s = 0, fsacc = 0; s < smax; s++, fsacc += (1 << surf->lmshift), plightdest += 3) + for (s = 0, fsacc = 0; s < smax; s++, fsacc += (1 << surf->lmshift)) { int sd; @@ -383,10 +383,17 @@ R_AddDynamicLights(const msurface_t *surf, const refdef_t *r_newrefdef, if ((fdist < fminlight) && (plightdest < (s_blocklights_max - 3))) { float diff = frad - fdist; + int j; - plightdest[0] += diff * dl->color[0]; - plightdest[1] += diff * dl->color[1]; - plightdest[2] += diff * dl->color[2]; + for (j = 0; j < 3; j++) + { + *plightdest += diff * dl->color[j]; + plightdest ++; + } + } + else + { + plightdest += 3; } } }