From 6a7fe88d68bdb3bdba5c5966a2d3ba5202025f5c Mon Sep 17 00:00:00 2001 From: plagman Date: Sun, 7 Jun 2009 20:27:45 +0000 Subject: [PATCH] This adds a fast light culling test for non-sloped floors and ceilings (TerminX suggested that change). git-svn-id: https://svn.eduke32.com/eduke32@1419 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/polymer.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 09947fb87..4e1ce032b 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -4489,6 +4489,7 @@ static inline void polymer_culllight(int16_t lighti) int32_t back; int32_t i; int32_t j; + int32_t zdiff; _prsector *s; _prwall *w; sectortype *sec; @@ -4508,13 +4509,27 @@ static inline void polymer_culllight(int16_t lighti) polymer_pokesector(sectorqueue[front]); - if (polymer_planeinlight(&s->floor, light)) { - polymer_addplanelight(&s->floor, lighti); - } + zdiff = light->z - s->floorz; + if (zdiff < 0) + zdiff = -zdiff; + zdiff >>= 4; - if (polymer_planeinlight(&s->ceil, light)) { + if (!light->radius && !sec->floorheinum) { + if (zdiff < light->range) + polymer_addplanelight(&s->floor, lighti); + } else if (polymer_planeinlight(&s->floor, light)) + polymer_addplanelight(&s->floor, lighti); + + zdiff = light->z - s->ceilingz; + if (zdiff < 0) + zdiff = -zdiff; + zdiff >>= 4; + + if (!light->radius && !sec->ceilingheinum) { + if (zdiff < light->range) + polymer_addplanelight(&s->ceil, lighti); + } else if (polymer_planeinlight(&s->ceil, light)) polymer_addplanelight(&s->ceil, lighti); - } i = 0; while (i < sec->wallnum)