From 0423ff81842ea7b2754cc29ad99071e0f0545c46 Mon Sep 17 00:00:00 2001 From: plagman Date: Sat, 20 Aug 2011 21:05:49 +0000 Subject: [PATCH] Polymer: propagate lights across vertical boundaries. Check all the bunch siblings if we get a floor/ceiling hit and walk them if their own planes hit. git-svn-id: https://svn.eduke32.com/eduke32@1981 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/polymer.c | 53 ++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 3614a2335..f94d7ef42 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -5228,6 +5228,9 @@ static inline void polymer_culllight(int16_t lighti) int32_t i; int32_t j; int32_t zdiff; + int32_t checkror; + int16_t bunchnum; + int16_t ns; _prsector *s; _prwall *w; sectortype *sec; @@ -5244,16 +5247,39 @@ static inline void polymer_culllight(int16_t lighti) polymer_pokesector(sectorqueue[front]); + checkror = FALSE; + zdiff = light->z - s->floorz; if (zdiff < 0) zdiff = -zdiff; zdiff >>= 4; if (!light->radius && !(sec->floorstat & 1)) { - if (zdiff < light->range) + if (zdiff < light->range) { polymer_addplanelight(&s->floor, lighti); - } else if (polymer_planeinlight(&s->floor, light)) + checkror = TRUE; + } + } else if (polymer_planeinlight(&s->floor, light)) { polymer_addplanelight(&s->floor, lighti); + checkror = TRUE; + } + + // queue ROR neighbors + if (checkror && (sec->floorstat & 1024) && + (bunchnum = yax_getbunch(sectorqueue[front], YAX_FLOOR)) >= 0) { + + for (SECTORS_OF_BUNCH(bunchnum, YAX_CEILING, ns)) { + + if (ns >= 0 && !drawingstate[ns] && + polymer_planeinlight(&prsectors[ns]->ceil, light)) { + + sectorqueue[back++] = ns; + drawingstate[ns] = 1; + } + } + } + + checkror = FALSE; zdiff = light->z - s->ceilingz; if (zdiff < 0) @@ -5261,10 +5287,29 @@ static inline void polymer_culllight(int16_t lighti) zdiff >>= 4; if (!light->radius && !(sec->ceilingstat & 1)) { - if (zdiff < light->range) + if (zdiff < light->range) { polymer_addplanelight(&s->ceil, lighti); - } else if (polymer_planeinlight(&s->ceil, light)) + checkror = TRUE; + } + } else if (polymer_planeinlight(&s->ceil, light)) { polymer_addplanelight(&s->ceil, lighti); + checkror = TRUE; + } + + // queue ROR neighbors + if (checkror && (sec->ceilingstat & 1024) && + (bunchnum = yax_getbunch(sectorqueue[front], YAX_CEILING)) >= 0) { + + for (SECTORS_OF_BUNCH(bunchnum, YAX_FLOOR, ns)) { + + if (ns >= 0 && !drawingstate[ns] && + polymer_planeinlight(&prsectors[ns]->floor, light)) { + + sectorqueue[back++] = ns; + drawingstate[ns] = 1; + } + } + } i = 0; while (i < sec->wallnum)