slightly cleanup addline stuff

no clue why i just didnt do this before lel
This commit is contained in:
Alug committed 2025-06-30 08:17:08 +02:00
1 parent 6fad476ccb
commit 34a2c08bdb
4 files changed
+50 -64

No files matched your search

+4 -3
View File
@@ -371,12 +371,13 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly)
line_t *line = lseg->linedef;
// portal check
if (!gl_maphasportals && line->special == 40 && lseg->side == 0)
if (!gl_maphasportals && line->special == PORTALSPECIAL && lseg->side == 0)
{
// Find the other side!
INT32 line2 = P_FindSpecialLineFromTag(40, line->tag, -1);
INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, -1);
if (line == &lines[line2])
line2 = P_FindSpecialLineFromTag(40, line->tag, line2);
line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, line2);
if (line2 >= 0) // found it!
gl_maphasportals = 1;
}
+42 -58
View File
@@ -2361,6 +2361,40 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2)
// SoM: Backsector needs to be run through R_FakeFlat
static sector_t tempsec;
auto do_addline = [&](bool dontdraw) {
if (!line->backsector)
{
gld_clipper_SafeAddClipRange(angle2, angle1);
}
else
{
gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true);
if (CheckClip(gl_frontsector, gl_backsector))
{
gld_clipper_SafeAddClipRange(angle2, angle1);
checkforemptylines = false;
}
// Reject empty lines used for triggers and special events.
// Identical floor and ceiling on both sides,
// identical light levels on both sides,
// and no middle texture.
if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector))
return;
}
if constexpr (Type == AddLineType::kPortal)
{
if (gl_portal_state != GLPORTAL_SEARCH && !dontdraw)// no need to do this during the portal check
HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D
}
else if constexpr (Type == AddLineType::kNormal)
{
HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D
}
};
if constexpr (Type == AddLineType::kPortal)
{
boolean dont_draw = false;
@@ -2377,15 +2411,15 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2)
if (gl_portal_state == GLPORTAL_STENCIL || gl_portal_state == GLPORTAL_DEPTH)
goto doaddline;
if (line->linedef->special == 40)
if (line->linedef->special == PORTALSPECIAL)
{
if (line->side == 0)
{
// Find the other side!
INT32 line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, -1);
INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, -1);
if (line->linedef == &lines[line2])
line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2);
line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, line2);
if (line2 >= 0) // found it!
{
@@ -2400,59 +2434,11 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2)
}
doaddline:
if (!line->backsector)
{
gld_clipper_SafeAddClipRange(angle2, angle1);
}
else
{
gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true);
if (CheckClip(gl_frontsector, gl_backsector))
{
gld_clipper_SafeAddClipRange(angle2, angle1);
checkforemptylines = false;
}
// Reject empty lines used for triggers and special events.
// Identical floor and ceiling on both sides,
// identical light levels on both sides,
// and no middle texture.
if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector))
return;
}
if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check
HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D
return;
do_addline(dont_draw); // no need to do this during the portal check
}
if constexpr (Type == AddLineType::kNormal)
else if constexpr (Type == AddLineType::kNormal)
{
if (!line->backsector)
{
gld_clipper_SafeAddClipRange(angle2, angle1);
}
else
{
gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true);
if (CheckClip(gl_frontsector, gl_backsector))
{
gld_clipper_SafeAddClipRange(angle2, angle1);
checkforemptylines = false;
}
// Reject empty lines used for triggers and special events.
// Identical floor and ceiling on both sides,
// identical light levels on both sides,
// and no middle texture.
if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector))
return;
}
HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D
return;
do_addline(false);
}
}
@@ -3286,8 +3272,7 @@ static void HWR_RenderBSPNode(INT32 bspnum)
if (!(HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1])))
return;
}
if constexpr (Type == BspType::kNormal)
else if constexpr (Type == BspType::kNormal)
{
// Recursively divide front space (toward the viewer).
HWR_RenderBSPNode<BspType::kNormal>(bsp->children[side]);
@@ -5599,8 +5584,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl
// woo we back
HWR_SetPortalState(oldgl_portal_state);
}
if constexpr (Type == RenderViewpointType::kNormal)
else if constexpr (Type == RenderViewpointType::kNormal)
{
// Recursively "render" the BSP tree.
HWR_RenderBSPNode<BspType::kNormal>((INT32)numnodes-1);
+3 -3
View File
@@ -385,15 +385,15 @@ static void R_AddLine(seg_t *line)
backsector = line->backsector;
// Portal line
if (line->linedef->special == 40 && line->side == 0)
if (line->linedef->special == PORTALSPECIAL && line->side == 0)
{
if (portalrender < cv_maxportals.value)
{
// Find the other side!
INT32 line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, -1);
INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, -1);
if (line->linedef == &lines[line2])
line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2);
line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, line2);
if (line2 >= 0) // found it!
{
+1
View File
@@ -420,6 +420,7 @@ typedef enum
} slopetype_t;
#define HORIZONSPECIAL 41
#define PORTALSPECIAL 40
typedef struct line_s
{