From fcb2bf97e211d7adfeced927eadc3c450a343724 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 18 Nov 2025 21:52:42 +0100 Subject: [PATCH] fix opengl portals (and its contents) being culled in some cases they shouldnt be we do culling per our viewmatrix since a while, which wasnt properly set up for portals beforehand and used whatever was last which was then incorrectly applied to portal culling :chaobaba: --- src/hardware/hw_main.cpp | 12 ++++++++---- src/hardware/hw_portal.c | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index ce1ab6667..b53b7cb82 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5456,10 +5456,14 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_ currentportallist = &portallist; HWR_SetPortalState(GLPORTAL_SEARCH); - HWR_ClearClipper(); + HWR_SetTransform(fpov); + HWR_ClearSprites(); + HWR_ClearClipper(); if (rootportal) + { HWR_PortalClipping(rootportal); + } validcount++; @@ -5477,14 +5481,14 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_ } } - // draw normal things in current frame in current incremented stencil buffer area - HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); - HWR_SetTransform(fpov); HWR_ClearSprites(); HWR_ClearClipper(); + // draw normal things in current frame in current incremented stencil buffer area + HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); + if constexpr (Type == RenderViewpointType::kPortal) { if (allow_portals && rootportal) diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index d8ad87354..952bd0e66 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -38,7 +38,7 @@ void HWR_PortalClipping(gl_portal_t *portal) gld_clipper_SafeAddClipRange(portal->angle1, portal->angle2); } -static gl_portal_t* HWR_Portal_Add (seg_t *seg) +static gl_portal_t* HWR_Portal_Add(seg_t *seg) { gl_portal_t *portal = Z_Malloc(sizeof(gl_portal_t), PU_STATIC, NULL); @@ -120,8 +120,8 @@ void HWR_PortalFrame(gl_portal_t* portal) viewz = portal->viewz; viewangle = portal->viewangle; - //viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); - //viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); + viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); + viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); if (portal->clipline != -1) {