From 90e410cf4792460e907c0cd21de692ffe8439844 Mon Sep 17 00:00:00 2001 From: plagman Date: Mon, 26 Mar 2012 00:55:53 +0000 Subject: [PATCH] polymer: cull sprite lights after computing sprite geometry This was broken ever since updatesprite() had been forked off drawsprite() and would cause static lights to never hit static sprites until one or the other changed, after which the light would always get culled against outdated sprite geometry. git-svn-id: https://svn.eduke32.com/eduke32@2536 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/polymer.c | 56 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index f55543d58..b70aa9654 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -3498,35 +3498,9 @@ void polymer_updatesprite(int32_t snum) if (tspr->cstat & 48 && searchit != 2) { uint32_t crc = crc32once((uint8_t *)tspr, offsetof(spritetype, owner)); - int32_t curpriority = 0; if (crc == s->crc && tspr->picnum == curpicnum) return; s->crc = crc; - - polymer_resetplanelights(&s->plane); - - while (curpriority < pr_maxlightpriority) - { - i = j = 0; - while (j < lightcount) - { - while (!prlights[i].flags.active) - i++; - - if (prlights[i].priority != curpriority) - { - i++; - j++; - continue; - } - - if (polymer_planeinlight(&s->plane, &prlights[i])) - polymer_addplanelight(&s->plane, i); - i++; - j++; - } - curpriority++; - } } polymer_getbuildmaterial(&s->plane.material, curpicnum, tspr->pal, tspr->shade, 4); @@ -3684,6 +3658,36 @@ void polymer_updatesprite(int32_t snum) bglDeleteBuffersARB(1, &s->plane.vbo); s->plane.vbo = 0; } + + if (tspr->cstat & 48) + { + int32_t curpriority = 0; + + polymer_resetplanelights(&s->plane); + + while (curpriority < pr_maxlightpriority) + { + i = j = 0; + while (j < lightcount) + { + while (!prlights[i].flags.active) + i++; + + if (prlights[i].priority != curpriority) + { + i++; + j++; + continue; + } + + if (polymer_planeinlight(&s->plane, &prlights[i])) + polymer_addplanelight(&s->plane, i); + i++; + j++; + } + curpriority++; + } + } } // SKIES