From 27533a1dcdb1b6d38f00600e68b46347edb79f25 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 1 Feb 2024 02:03:00 +0100 Subject: [PATCH] Revert "replace check" This reverts commit 36eaaee202c4d1f7e86dd2b24dcfe5573ac2f280. --- src/hardware/hw_main.c | 32 +++++++++++++++++++++++++------- src/hardware/hw_main.h | 1 - 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 15b019e67..d7f89f13c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2881,13 +2881,30 @@ void HWR_AddLine(seg_t *line) angle1 = R_PointToPseudoAngle(v1x, v1y); angle2 = R_PointToPseudoAngle(v2x, v2y); - // do extra checks on the seg when rendering portals: - // don't render segs that are behind the portal destination line - if (portalclipline && gr_portal != - !HWR_PortalCheckPointSide(line->v1->x, line->v1->y) && - !HWR_PortalCheckPointSide(line->v2->x, line->v2->y)) + // do an extra culling check when rendering portals + // check if any line vertex is on the viewable side of the portal target line + // if not, the line can be culled. + if (portalclipline)// portalclipline should be NULL when we are not rendering portal contents { - return; + vertex_t closest_point; + boolean pass = false; + + // similar idea than in PortalCheckBBox, but checking the line vertices instead + // TODO could make the check more efficient and not check anything if pass==true from earlier or something + P_ClosestPointOnLine(line->v1->x, line->v1->y, portalclipline, &closest_point); + if (closest_point.x != line->v1->x || closest_point.y != line->v1->y) + { + if (P_PointOnLineSide(line->v1->x, line->v1->y, portalclipline) != portalviewside) + pass = true; + } + P_ClosestPointOnLine(line->v2->x, line->v2->y, portalclipline, &closest_point); + if (closest_point.x != line->v2->x || closest_point.y != line->v2->y) + { + if (P_PointOnLineSide(line->v2->x, line->v2->y, portalclipline) != portalviewside) + pass = true; + } + if (!pass) + return; } if (gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH) @@ -3714,9 +3731,10 @@ 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 -boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y) +static boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y) { // we are checking if the point is on the viewable side of the portal exit. // being exactly on the portal exit line is not enough to pass the test. diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index edab7f879..2c05e4e8e 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -89,7 +89,6 @@ void HWR_SetViewSize(void); void HWR_AddCommands(void); void HWR_SetTransform(float fpov, player_t *player); void HWR_ClearClipper(void); -boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y); boolean HWR_UseShader(void); boolean HWR_ShouldUsePaletteRendering(void);