From dee99139f56dd496e04febbe5e2edd5b978216da Mon Sep 17 00:00:00 2001 From: plagman Date: Sun, 2 Oct 2011 07:09:15 +0000 Subject: [PATCH] Polymer: constantly get the textures handle for projective spotlights Getting the texture handles without requiring invalidation means we can handle ART-animating tilenums without impacting performance too much. git-svn-id: https://svn.eduke32.com/eduke32@2058 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/polymer.c | 74 +++++++++++++++++++---------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 4283b9f74..c04708805 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -1449,9 +1449,28 @@ int16_t polymer_addlight(_prlight* light) Bmemcpy(&prlights[lighti], light, sizeof(_prlight)); - if (light->radius) + if (light->radius) { polymer_processspotlight(&prlights[lighti]); + // get the texture handle for the lightmap + if (light->tilenum > 0) { + int16_t picnum = light->tilenum; + pthtyp* pth; + + if (picanm[picnum] & 192) + picnum += animateoffs(picnum, 0); + + if (!waloff[picnum]) + loadtile(picnum); + + pth = NULL; + pth = gltexcache(picnum, 0, 0); + + if (pth) + light->lightmap = pth->glpic; + } + } + prlights[lighti].flags.isinview = 0; prlights[lighti].flags.active = 1; @@ -5066,20 +5085,42 @@ static void polymer_updatelights(void) do { - if (prlights[i].flags.active && prlights[i].flags.invalidate) { + _prlight* light = &prlights[i]; + + if (light->flags.active && light->flags.invalidate) { // highly suboptimal polymer_removelight(i); - if (prlights[i].radius) - polymer_processspotlight(&prlights[i]); + if (light->radius) + polymer_processspotlight(light); polymer_culllight(i); - prlights[i].flags.invalidate = 0; + light->flags.invalidate = 0; } - if (prlights[i].flags.active) - prlights[i].rtindex = -1; + if (light->flags.active) { + // get the texture handle for the lightmap + if (light->radius && light->tilenum > 0) + { + int16_t picnum = light->tilenum; + pthtyp* pth; + + if (picanm[picnum] & 192) + picnum += animateoffs(picnum, 0); + + if (!waloff[picnum]) + loadtile(picnum); + + pth = NULL; + pth = gltexcache(picnum, 0, 0); + + if (pth) + light->lightmap = pth->glpic; + } + + light->rtindex = -1; + } } while (++i < PR_MAXLIGHTS); } @@ -5259,26 +5300,7 @@ static void polymer_processspotlight(_prlight* light) polymer_extractfrustum(light->transform, light->proj, light->frustum); light->rtindex = -1; - - // get the texture handle for the lightmap light->lightmap = 0; - if (light->tilenum > 0) - { - int16_t picnum = light->tilenum; - pthtyp* pth; - - if (picanm[picnum] & 192) - picnum += animateoffs(picnum, 0); - - if (!waloff[picnum]) - loadtile(picnum); - - pth = NULL; - pth = gltexcache(picnum, 0, 0); - - if (pth) - light->lightmap = pth->glpic; - } } static inline void polymer_culllight(int16_t lighti)