Ensure sector portals are rendered when they would otherwise be missed

This commit is contained in:
Lactozilla 2023-08-23 15:46:48 -03:00
parent 395e9bdd20
commit e230d38aad
4 changed files with 19 additions and 3 deletions

View file

@ -6203,6 +6203,11 @@ static boolean P_IsSectorPortalValid(sectorportal_t *secportal)
}
}
boolean P_SectorHasPortal(sector_t *sector)
{
return P_SectorHasFloorPortal(sector) || P_SectorHasCeilingPortal(sector);
}
boolean P_SectorHasFloorPortal(sector_t *sector)
{
return P_IsSectorPortalValid(&sector->portal_floor);
@ -6215,7 +6220,11 @@ boolean P_SectorHasCeilingPortal(sector_t *sector)
boolean P_CompareSectorPortals(sectorportal_t *a, sectorportal_t *b)
{
if (a->type != b->type)
if (a == NULL && b == NULL)
return true;
else if (!a || !b)
return false;
else if (a->type != b->type)
return false;
switch (a->type)

View file

@ -521,6 +521,7 @@ INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max);
void P_SetupSignExit(player_t *player);
boolean P_IsFlagAtBase(mobjtype_t flag);
boolean P_SectorHasPortal(sector_t *sector);
boolean P_SectorHasFloorPortal(sector_t *sector);
boolean P_SectorHasCeilingPortal(sector_t *sector);
boolean P_CompareSectorPortals(sectorportal_t *a, sectorportal_t *b);

View file

@ -357,6 +357,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back)
{
if (P_SectorHasPortal(front) && !P_SectorHasPortal(back))
return false;
else if (!P_SectorHasPortal(front) && P_SectorHasPortal(back))
return false;
return (
!line->polyseg &&
back->ceilingpic == front->ceilingpic
@ -578,7 +583,6 @@ static void R_AddLine(seg_t *line)
// 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 (R_IsEmptyLine(line, frontsector, backsector))
return;
@ -915,6 +919,7 @@ static void R_Subsector(size_t num)
if (P_GetSectorFloorZAt(frontsector, viewx, viewy) < viewz
|| frontsector->floorpic == skyflatnum
|| P_SectorHasFloorPortal(frontsector)
|| (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum))
{
floorplane = R_FindPlane(frontsector, frontsector->floorheight, frontsector->floorpic, floorlightlevel,
@ -925,6 +930,7 @@ static void R_Subsector(size_t num)
if (P_GetSectorCeilingZAt(frontsector, viewx, viewy) > viewz
|| frontsector->ceilingpic == skyflatnum
|| P_SectorHasCeilingPortal(frontsector)
|| (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum))
{
ceilingplane = R_FindPlane(frontsector, frontsector->ceilingheight, frontsector->ceilingpic,

View file

@ -451,7 +451,7 @@ visplane_t *R_FindPlane(sector_t *sector, fixed_t height, INT32 picnum, INT32 li
&& check->plangle == plangle
&& check->slope == slope
&& check->polyobj == polyobj
&& check->portalsector == portalsector)
&& P_CompareSectorPortals(check->portalsector, portalsector))
{
return check;
}