diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 5bf7496eb2..42e52733b2 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -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; } //========================================================================== diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index a5660be3db..e61886971e 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -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; } //========================================================================== diff --git a/src/vectors.h b/src/vectors.h index ce1f043afc..6bc6b6f8df 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -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; }