From ff1eb7f3f21826582d9ac509c4e7c86ec518ddbf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 25 Jun 2018 10:27:02 +0200 Subject: [PATCH 1/4] - calculate a proper opening range when encountering a sector portal on a one-sided line in the sight checking code --- src/p_sight.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 1854b743b..d53343594 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -151,6 +151,7 @@ public: void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, double x, double y) { open.portalflags = 0; + open.bottom = open.top = 0; sector_t *front = linedef->frontsector; sector_t *back = linedef->backsector; @@ -159,8 +160,10 @@ void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, doubl // single sided line if (linedef->flags & ML_PORTALCONNECT) { - if (!front->PortalBlocksSight(sector_t::ceiling)) open.portalflags |= SO_TOPFRONT; - if (!front->PortalBlocksSight(sector_t::floor)) open.portalflags |= SO_BOTTOMFRONT; + if (!front->PortalBlocksSight(sector_t::ceiling)) open.top = LINEOPEN_MAX, open.portalflags |= SO_TOPFRONT; + if (!front->PortalBlocksSight(sector_t::floor)) open.bottom = LINEOPEN_MIN, open.portalflags |= SO_BOTTOMFRONT; + if (open.top == 0) open.top = front->floorplane.ZatPoint(x, y); + if (open.bottom == 0) open.bottom = front->ceilingplane.ZatPoint(x, y); } open.range = 0; @@ -213,7 +216,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) // // ignore self referencing sectors if COMPAT_TRACE is on - if ((i_compatflags & COMPATF_TRACE) && li->frontsector == li->backsector) + if ((i_compatflags & COMPATF_TRACE) && li->frontsector == li->backsector) return true; double trX = Trace.x + Trace.dx * in->frac; @@ -224,7 +227,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) { // This may not skip P_SightOpening, but only reduce the open range to 0. open.range = 0; - open.bottom = open.top; + if (open.bottom != LINEOPEN_MIN) open.bottom = open.top; } FLinePortal *lport = li->getPortal(); From f8272287d21e6455323418c7c5db242089496c9b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 26 Jun 2018 02:19:47 +0200 Subject: [PATCH 2/4] - make softpoly use the r_dynlights cvar --- src/polyrenderer/scene/poly_plane.cpp | 6 ++++++ src/polyrenderer/scene/poly_wall.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/polyrenderer/scene/poly_plane.cpp b/src/polyrenderer/scene/poly_plane.cpp index 55a4c11d0..08a8897e7 100644 --- a/src/polyrenderer/scene/poly_plane.cpp +++ b/src/polyrenderer/scene/poly_plane.cpp @@ -269,6 +269,12 @@ void RenderPolyPlane::SetLightLevel(PolyRenderThread *thread, PolyDrawArgs &args void RenderPolyPlane::SetDynLights(PolyRenderThread *thread, PolyDrawArgs &args, subsector_t *sub, bool ceiling) { + if (!r_dynlights) + { + args.SetLights(nullptr, 0); + return; + } + FLightNode *light_list = sub->lighthead; auto cameraLight = PolyCameraLight::Instance(); diff --git a/src/polyrenderer/scene/poly_wall.cpp b/src/polyrenderer/scene/poly_wall.cpp index 02eb5e7b2..7aae2c32c 100644 --- a/src/polyrenderer/scene/poly_wall.cpp +++ b/src/polyrenderer/scene/poly_wall.cpp @@ -374,6 +374,12 @@ void RenderPolyWall::Render(PolyRenderThread *thread) void RenderPolyWall::SetDynLights(PolyRenderThread *thread, PolyDrawArgs &args) { + if (!r_dynlights) + { + args.SetLights(nullptr, 0); + return; + } + FLightNode *light_list = (LineSeg && LineSeg->sidedef) ? LineSeg->sidedef->lighthead : nullptr; auto cameraLight = PolyCameraLight::Instance(); From e402babfc00a84c1000dae39e458ed1880a5d470 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Jun 2018 08:23:07 +0200 Subject: [PATCH 3/4] Fixed: Software rendered models checked the wrong CVAR for enabled dynamic lights. --- src/polyrenderer/scene/poly_model.cpp | 2 +- src/swrenderer/things/r_model.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/polyrenderer/scene/poly_model.cpp b/src/polyrenderer/scene/poly_model.cpp index 4251589d9..a49212989 100644 --- a/src/polyrenderer/scene/poly_model.cpp +++ b/src/polyrenderer/scene/poly_model.cpp @@ -56,7 +56,7 @@ PolyModelRenderer::PolyModelRenderer(PolyRenderThread *thread, const Mat4f &worl void PolyModelRenderer::AddLights(AActor *actor) { - if (gl_lights && actor) + if (r_dynlights && actor) { auto &addedLights = Thread->AddedLightsArray; diff --git a/src/swrenderer/things/r_model.cpp b/src/swrenderer/things/r_model.cpp index 0991d1d45..70995c32c 100644 --- a/src/swrenderer/things/r_model.cpp +++ b/src/swrenderer/things/r_model.cpp @@ -98,7 +98,7 @@ namespace swrenderer void SWModelRenderer::AddLights(AActor *actor) { - if (gl_lights && actor) + if (r_dynlights && actor) { auto &addedLights = Thread->AddedLightsArray; From 0ed1077f2992aa2d0d509f091e905684dcdae75d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Jun 2018 08:51:21 +0200 Subject: [PATCH 4/4] - correct checks for HasDynamicLights --- src/d_main.cpp | 2 +- src/g_shared/a_dynlight.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 4172909bc..ea727b6fb 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -786,7 +786,7 @@ void D_Display () // // Check for the presence of dynamic lights at the start of the frame once. - if (gl_lights) + if ((gl_lights && vid_rendermode == 4) || (r_dynlights && vid_rendermode != 4)) { TThinkerIterator it(STAT_DLIGHT); level.HasDynamicLights = !!it.Next(); diff --git a/src/g_shared/a_dynlight.h b/src/g_shared/a_dynlight.h index ae2493ca2..fa9d5840e 100644 --- a/src/g_shared/a_dynlight.h +++ b/src/g_shared/a_dynlight.h @@ -3,6 +3,7 @@ #include "actor.h" #include "cycler.h" +EXTERN_CVAR(Bool, r_dynlights) EXTERN_CVAR(Bool, gl_lights) EXTERN_CVAR(Bool, gl_attachedlights)