From 623fab8ea84231c59e3bc1eb788420a2aff84753 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 1 Feb 2024 02:03:23 +0100 Subject: [PATCH] Revert "clean this up a little" This reverts commit 99c9d921e3ab3ee3fde3dcf141e20323e064902a. --- src/hardware/hw_main.c | 49 ++++++++++++++++---------------- src/hardware/r_opengl/r_opengl.c | 3 +- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b181d3ab9..40e885c17 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3731,39 +3731,40 @@ skip_stuff_for_portals: // use returned value as multiplier for the added values from p_thrust thing // P_InterceptVector needs divlines which need dx and dy, dx=x2-x1 dy=y2-y1 - -// returns true if the point is on the correct (viewable) side of the -// portal destination line -static boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y) +static boolean HWR_PortalCheckBBox(fixed_t *bspcoord) { - // we are checking if the point is on the viewable side of the portal exit. + vertex_t closest_point; + if (!portalclipline) + return true; + + // we are looking for a bounding box corner that is on the viewable side of the portal exit. // being exactly on the portal exit line is not enough to pass the test. // P_PointOnLineSide could behave differently from this expectation on this case, // so first check if the point is precisely on the line, and then if not, check the side. - vertex_t closest_point; - P_ClosestPointOnLine(x, y, gl_portalclipline, &closest_point); - if (closest_point.x != x || closest_point.y != y) + P_ClosestPointOnLine(bspcoord[BOXLEFT], bspcoord[BOXTOP], portalclipline, &closest_point); + if (closest_point.x != bspcoord[BOXLEFT] || closest_point.y != bspcoord[BOXTOP]) { - if (P_PointOnLineSide(x, y, gl_portalclipline) != gl_portalviewside) + if (P_PointOnLineSide(bspcoord[BOXLEFT], bspcoord[BOXTOP], portalclipline) != portalviewside) return true; } - return false; -} - -// Check if bounding box is (partially or fully) in the correct side -// of the portal destination. -static boolean HWR_PortalCheckBBox(fixed_t *bspcoord) -{ - if (!portalclipline) - return true; - - if (HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXTOP]) || - HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) || - HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) || - HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM])) + P_ClosestPointOnLine(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], portalclipline, &closest_point); + if (closest_point.x != bspcoord[BOXLEFT] || closest_point.y != bspcoord[BOXBOTTOM]) { - return true; + if (P_PointOnLineSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], portalclipline) != portalviewside) + return true; + } + P_ClosestPointOnLine(bspcoord[BOXRIGHT], bspcoord[BOXTOP], portalclipline, &closest_point); + if (closest_point.x != bspcoord[BOXRIGHT] || closest_point.y != bspcoord[BOXTOP]) + { + if (P_PointOnLineSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP], portalclipline) != portalviewside) + return true; + } + P_ClosestPointOnLine(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM], portalclipline, &closest_point); + if (closest_point.x != bspcoord[BOXRIGHT] || closest_point.y != bspcoord[BOXBOTTOM]) + { + if (P_PointOnLineSide(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM], portalclipline) != portalviewside) + return true; } // we did not find any reason to pass the check, so return failure diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 970b3d525..68188e372 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1038,7 +1038,6 @@ void SetStates(void) pglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - pglEnable(GL_STENCIL_TEST); pglEnable(GL_DEPTH_TEST); // check the depth buffer pglDepthMask(GL_TRUE); // enable writing to depth buffer pglClearDepth(1.0f); @@ -1058,6 +1057,8 @@ void SetStates(void) pglLoadIdentity(); pglScalef(1.0f, 1.0f, -1.0f); pglGetFloatv(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer) + + pglEnable(GL_STENCIL_TEST); } void GLFramebuffer_Generate(void)