Don't prepare shadows of lights that aren't in view.

git-svn-id: https://svn.eduke32.com/eduke32@1292 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2009-04-01 18:34:11 +00:00
parent 8181b1141d
commit 82605aa44c
2 changed files with 22 additions and 1 deletions

View file

@ -156,6 +156,7 @@ typedef struct s_prlight {
GLfloat transform[16]; GLfloat transform[16];
float frustum[5 * 4]; float frustum[5 * 4];
int32_t rtindex; int32_t rtindex;
char isinview;
} _prlight; } _prlight;
extern _prlight staticlights[PR_MAXLIGHTS]; extern _prlight staticlights[PR_MAXLIGHTS];
@ -189,6 +190,7 @@ typedef struct s_prplane {
// lights // lights
char lights[PR_MAXLIGHTS]; char lights[PR_MAXLIGHTS];
char lightcount; char lightcount;
char drawn;
} _prplane; } _prplane;
typedef struct s_prsector { typedef struct s_prsector {

View file

@ -703,6 +703,8 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da
while (i < numsectors) while (i < numsectors)
{ {
prsectors[i]->controlstate = 0; prsectors[i]->controlstate = 0;
prsectors[i]->ceil.drawn = 0;
prsectors[i]->floor.drawn = 0;
prsectors[i]->wallsproffset = 0.0f; prsectors[i]->wallsproffset = 0.0f;
prsectors[i]->floorsproffset = 0.0f; prsectors[i]->floorsproffset = 0.0f;
i++; i++;
@ -711,6 +713,9 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da
while (i < numwalls) while (i < numwalls)
{ {
prwalls[i]->controlstate = 0; prwalls[i]->controlstate = 0;
prwalls[i]->wall.drawn = 0;
prwalls[i]->over.drawn = 0;
prwalls[i]->mask.drawn = 0;
i++; i++;
} }
@ -1070,6 +1075,8 @@ void polymer_addlight(_prlight light)
prlights[lightcount].rtindex = -1; prlights[lightcount].rtindex = -1;
} }
prlights[lightcount].isinview = 0;
polymer_culllight(lightcount); polymer_culllight(lightcount);
lightcount++; lightcount++;
@ -1460,6 +1467,8 @@ static void polymer_drawplane(_prplane* plane)
if (plane->indices) if (plane->indices)
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
} }
plane->drawn = 1;
} }
static void polymer_inb4mirror(GLfloat* buffer, GLfloat* plane) static void polymer_inb4mirror(GLfloat* buffer, GLfloat* plane)
@ -3766,10 +3775,14 @@ static void polymer_culllight(char lightindex)
if (polymer_planeinlight(&s->floor, light)) { if (polymer_planeinlight(&s->floor, light)) {
s->floor.lights[s->floor.lightcount] = lightindex; s->floor.lights[s->floor.lightcount] = lightindex;
s->floor.lightcount++; s->floor.lightcount++;
if (s->floor.drawn)
light->isinview = 1;
} }
if (polymer_planeinlight(&s->ceil, light)) { if (polymer_planeinlight(&s->ceil, light)) {
s->ceil.lights[s->ceil.lightcount] = lightindex; s->ceil.lights[s->ceil.lightcount] = lightindex;
s->ceil.lightcount++; s->ceil.lightcount++;
if (s->ceil.drawn)
light->isinview = 1;
} }
i = 0; i = 0;
@ -3780,14 +3793,20 @@ static void polymer_culllight(char lightindex)
if (polymer_planeinlight(&w->wall, light)) { if (polymer_planeinlight(&w->wall, light)) {
w->wall.lights[w->wall.lightcount] = lightindex; w->wall.lights[w->wall.lightcount] = lightindex;
w->wall.lightcount++; w->wall.lightcount++;
if (w->wall.drawn)
light->isinview = 1;
} }
if (polymer_planeinlight(&w->over, light)) { if (polymer_planeinlight(&w->over, light)) {
w->over.lights[w->over.lightcount] = lightindex; w->over.lights[w->over.lightcount] = lightindex;
w->over.lightcount++; w->over.lightcount++;
if (w->over.drawn)
light->isinview = 1;
} }
if (polymer_planeinlight(&w->mask, light)) { if (polymer_planeinlight(&w->mask, light)) {
w->mask.lights[w->mask.lightcount] = lightindex; w->mask.lights[w->mask.lightcount] = lightindex;
w->mask.lightcount++; w->mask.lightcount++;
if (w->mask.drawn)
light->isinview = 1;
if ((wall[sec->wallptr + i].nextsector != -1) && if ((wall[sec->wallptr + i].nextsector != -1) &&
(!cullingstate[wall[sec->wallptr + i].nextsector])) { (!cullingstate[wall[sec->wallptr + i].nextsector])) {
@ -3828,7 +3847,7 @@ static void polymer_prepareshadows(void)
while ((i < lightcount) && (j < 4)) while ((i < lightcount) && (j < 4))
{ {
if (prlights[i].radius) if (prlights[i].radius && prlights[i].isinview)
{ {
prlights[i].rtindex = j + 1; prlights[i].rtindex = j + 1;