- only draw visible 3D-lights.

This commit is contained in:
Christoph Oelckers 2016-02-01 16:13:07 +01:00
parent bddad29acb
commit 1ad310e69b

View file

@ -343,6 +343,13 @@ void GLWall::RenderTextured(int rflags)
glEnable(GL_CLIP_DISTANCE4); glEnable(GL_CLIP_DISTANCE4);
for (unsigned i = 0; i < lightlist->Size(); i++) for (unsigned i = 0; i < lightlist->Size(); i++)
{
secplane_t &lowplane = i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane;
// this must use the exact same calculation method as GLWall::Process etc.
float low1 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[0]));
float low2 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[1]));
if (low1 < ztop[0] && low2 < ztop[1])
{ {
int thisll = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; int thisll = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel;
FColormap thiscm; FColormap thiscm;
@ -350,9 +357,11 @@ void GLWall::RenderTextured(int rflags)
thiscm.CopyFrom3DLight(&(*lightlist)[i]); thiscm.CopyFrom3DLight(&(*lightlist)[i]);
gl_SetColor(thisll, rel, thiscm, absalpha); gl_SetColor(thisll, rel, thiscm, absalpha);
if (type != RENDERWALL_M2SNF) gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add); if (type != RENDERWALL_M2SNF) gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add);
gl_RenderState.SetSplitPlanes((*lightlist)[i].plane, i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane); gl_RenderState.SetSplitPlanes((*lightlist)[i].plane, lowplane);
RenderWall(rflags); RenderWall(rflags);
} }
if (low1 <= zbottom[0] && low2 <= zbottom[1]) break;
}
glDisable(GL_CLIP_DISTANCE3); glDisable(GL_CLIP_DISTANCE3);
glDisable(GL_CLIP_DISTANCE4); glDisable(GL_CLIP_DISTANCE4);