From 852c42bbd438f2096bb5cd1bfb763d61085f3e4b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Apr 2018 19:00:17 +0200 Subject: [PATCH] - 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. --- src/gl/compatibility/gl_20.cpp | 12 ++++++------ src/gl/scene/gl_walls_draw.cpp | 5 +++-- src/vectors.h | 1 - 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 5bf7496eb..42e52733b 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 a5660be3d..e61886971 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 ce1f043af..6bc6b6f8d 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; }