mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 09:21:36 +00:00
Re-implements the old light priority system, removes applylights() and optimizes the light invalidation code.
git-svn-id: https://svn.eduke32.com/eduke32@1405 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
dbb84c7ee8
commit
b112e1d3c3
1 changed files with 81 additions and 42 deletions
|
@ -917,6 +917,7 @@ void polymer_drawsprite(int32_t snum)
|
|||
float xratio, yratio, ang;
|
||||
float spos[3];
|
||||
GLfloat *inbuffer;
|
||||
uint8_t curpriority;
|
||||
|
||||
if (pr_verbosity >= 3) OSD_Printf("PR : Sprite %i...\n", snum);
|
||||
|
||||
|
@ -1068,6 +1069,10 @@ void polymer_drawsprite(int32_t snum)
|
|||
|
||||
spriteplane.lightcount = 0;
|
||||
|
||||
curpriority = 0;
|
||||
|
||||
while (curpriority < pr_maxlightpriority)
|
||||
{
|
||||
i = j = 0;
|
||||
while (j < lightcount)
|
||||
{
|
||||
|
@ -1075,6 +1080,12 @@ void polymer_drawsprite(int32_t snum)
|
|||
i++;
|
||||
}
|
||||
|
||||
if (prlights[i].priority != curpriority) {
|
||||
i++;
|
||||
j++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (polymer_planeinlight(&spriteplane, &prlights[i]))
|
||||
{
|
||||
spriteplane.lights[spriteplane.lightcount] = i;
|
||||
|
@ -1083,6 +1094,8 @@ void polymer_drawsprite(int32_t snum)
|
|||
i++;
|
||||
j++;
|
||||
}
|
||||
curpriority++;
|
||||
}
|
||||
|
||||
if ((tspr->cstat & 64) && ((tspr->cstat>>4) & 3))
|
||||
bglEnable(GL_CULL_FACE);
|
||||
|
@ -1119,6 +1132,9 @@ int16_t polymer_addlight(_prlight* light)
|
|||
if (lightcount >= PR_MAXLIGHTS)
|
||||
return (-1);
|
||||
|
||||
if (light->priority > pr_maxlightpriority)
|
||||
return (-1);
|
||||
|
||||
lighti = 0;
|
||||
while ((lighti < PR_MAXLIGHTS) && (prlights[lighti].flags.active)) {
|
||||
lighti++;
|
||||
|
@ -2317,6 +2333,9 @@ static void polymer_updatewall(int16_t wallnum)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (w->invalidid != invalid)
|
||||
polymer_invalidatesectorlights(sectorofwall(wallnum));
|
||||
|
||||
w->invalidid = invalid;
|
||||
w->cstat = wal->cstat;
|
||||
w->picnum = wallpicnum;
|
||||
|
@ -2336,8 +2355,6 @@ static void polymer_updatewall(int16_t wallnum)
|
|||
}
|
||||
}
|
||||
|
||||
polymer_invalidatesectorlights(sectorofwall(wallnum));
|
||||
|
||||
w->underover = underwall = overwall = 0;
|
||||
|
||||
if (wal->cstat & 8)
|
||||
|
@ -3113,6 +3130,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
|||
float sradius, lradius;
|
||||
int16_t modellights[PR_MAXLIGHTS];
|
||||
char modellightcount;
|
||||
uint8_t curpriority;
|
||||
|
||||
m = (md3model_t*)models[tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].modelid];
|
||||
updateanimation((md2model_t *)m,tspr);
|
||||
|
@ -3259,6 +3277,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
|||
mdspritematerial.mdspritespace = GL_TRUE;
|
||||
|
||||
modellightcount = 0;
|
||||
curpriority = 0;
|
||||
|
||||
// light culling
|
||||
if (lightcount)
|
||||
|
@ -3279,6 +3298,8 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
|||
polymer_transformpoint(spos, tspos, spritemodelview);
|
||||
polymer_transformpoint(tspos, spos, rootmodelviewmatrix);
|
||||
|
||||
while (curpriority < pr_maxlightpriority)
|
||||
{
|
||||
i = j = 0;
|
||||
while (j < lightcount)
|
||||
{
|
||||
|
@ -3286,6 +3307,12 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
|||
i++;
|
||||
}
|
||||
|
||||
if (prlights[i].priority != curpriority) {
|
||||
i++;
|
||||
j++;
|
||||
continue;
|
||||
}
|
||||
|
||||
lradius = prlights[i].range / 1000.0f;
|
||||
|
||||
lpos[0] = prlights[i].y;
|
||||
|
@ -3310,7 +3337,8 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
|||
i++;
|
||||
j++;
|
||||
}
|
||||
|
||||
curpriority++;
|
||||
}
|
||||
}
|
||||
|
||||
for (surfi=0;surfi<m->head.numsurfs;surfi++)
|
||||
|
@ -4236,9 +4264,15 @@ static void polymer_addplanelight(_prplane* plane, int16_t lighti)
|
|||
{
|
||||
int16_t i;
|
||||
|
||||
if (plane->lightcount == PR_MAXLIGHTS)
|
||||
return;
|
||||
|
||||
i = 0;
|
||||
while (i < PR_MAXLIGHTS)
|
||||
{
|
||||
if ((plane->lights[i] != -1) && (prlights[plane->lights[i]].priority > prlights[lighti].priority))
|
||||
break;
|
||||
|
||||
if (plane->lights[i] == -1)
|
||||
{
|
||||
plane->lights[i] = lighti;
|
||||
|
@ -4247,6 +4281,11 @@ static void polymer_addplanelight(_prplane* plane, int16_t lighti)
|
|||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
memcpy(&plane->lights[i+1], &plane->lights[i], sizeof(int16_t) * (PR_MAXLIGHTS - (i+1)));
|
||||
|
||||
plane->lights[i] = lighti;
|
||||
plane->lightcount++;
|
||||
}
|
||||
|
||||
static void polymer_deleteplanelight(_prplane* plane, int16_t lighti)
|
||||
|
|
Loading…
Reference in a new issue