- fixed dynamic lights in legacy mode.

Since they mess around with the texture coordinates, these need to be backed up and restored afterward.
There was also an issue with the ValidNormal check that was suffering from imprecisions that cause walls to be skipped, so the check was removed because it was mostly pointless.
This commit is contained in:
Christoph Oelckers 2018-04-29 19:00:17 +02:00
parent 6cd8b1b3eb
commit 852c42bbd4
3 changed files with 9 additions and 9 deletions

View File

@ -755,11 +755,6 @@ static bool PrepareLight(GLWall *wall, ADynamicLight * light, int pass)
auto normal = glseg.Normal();
p.Set(normal, -normal.X * glseg.x1 - normal.Z * glseg.y1);
if (!p.ValidNormal())
{
return false;
}
if (!gl_SetupLight(wall->seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, true, pass != GLPASS_LIGHTTEX))
{
return false;
@ -817,6 +812,9 @@ void FDrawInfo::RenderLightsCompat(GLWall *wall, int pass)
return;
}
auto vertcountsave = wall->vertcount;
auto vertindexsave = wall->vertindex;
texcoord save[4];
memcpy(save, wall->tcs, sizeof(wall->tcs));
while (node)
@ -833,12 +831,14 @@ void FDrawInfo::RenderLightsCompat(GLWall *wall, int pass)
if (PrepareLight(wall, light, pass))
{
wall->vertcount = 0;
wall->MakeVertices(this, false);
RenderWall(wall, GLWall::RWF_TEXTURED);
}
node = node->nextLight;
}
memcpy(wall->tcs, save, sizeof(wall->tcs));
wall->vertcount = 0;
wall->vertcount = vertcountsave;
wall->vertindex = vertindexsave;
}
//==========================================================================

View File

@ -310,6 +310,8 @@ void FDrawInfo::AddWall(GLWall *wall)
bool translucent = !!(wall->flags & GLWall::GLWF_TRANSLUCENT);
int list;
wall->MakeVertices(this, translucent);
if (translucent) // translucent walls
{
if (!gl.legacyMode && mDrawer->FixedColormap == CM_DEFAULT && wall->gltexture != nullptr)
@ -318,7 +320,6 @@ void FDrawInfo::AddWall(GLWall *wall)
wall->dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
}
wall->ViewDistance = (r_viewpoint.Pos - (wall->seg->linedef->v1->fPos() + wall->seg->linedef->Delta() / 2)).XY().LengthSquared();
wall->MakeVertices(this, true);
auto newwall = drawlists[GLDL_TRANSLUCENT].NewWall();
*newwall = *wall;
}
@ -347,12 +348,12 @@ void FDrawInfo::AddWall(GLWall *wall)
{
list = masked ? GLDL_MASKEDWALLS : GLDL_PLAINWALLS;
}
wall->MakeVertices(this, false);
auto newwall = drawlists[list].NewWall();
*newwall = *wall;
if (!masked) newwall->ProcessDecals(this);
}
wall->dynlightindex = -1;
wall->vertcount = 0;
}
//==========================================================================

View File

@ -1704,7 +1704,6 @@ public:
}
bool PointOnSide(FVector3 &v) { return PointOnSide(v.X, v.Y, v.Z); }
bool ValidNormal() { return m_normal.LengthSquared() == 1.f; }
float A() { return m_normal.X; }
float B() { return m_normal.Y; }