Merge pull request #16 from alufolie91/fixsoftskywalls

Fix Skywalls and Culling on binary maps ( Software renderer edition). Thanks Alug!
This commit is contained in:
NepDisk 2024-09-11 12:08:19 -04:00 committed by GitHub
commit f22d4cd470
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 158 additions and 82 deletions

View file

@ -510,20 +510,23 @@ static void R_AddLine(seg_t *line)
doorclosed = 0;
if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum)
bothceilingssky = true;
if (backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum)
bothfloorssky = true;
if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then
if (udmf)
{
if (!line->polyseg &&
!line->sidedef->midtexture
&& ((!frontsector->ffloors && !backsector->ffloors)
|| Tag_Compare(&frontsector->tags, &backsector->tags)))
return; // line is empty, don't even bother
if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum)
bothceilingssky = true;
if (backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum)
bothfloorssky = true;
goto clippass; // treat like wide open window instead
if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then
{
if (!line->polyseg &&
!line->sidedef->midtexture
&& ((!frontsector->ffloors && !backsector->ffloors)
|| Tag_Compare(&frontsector->tags, &backsector->tags)))
return; // line is empty, don't even bother
goto clippass; // treat like wide open window instead
}
}
// Closed door.
@ -540,70 +543,131 @@ static void R_AddLine(seg_t *line)
SLOPEPARAMS( backsector->f_slope, backf1, backf2, backsector-> floorheight)
SLOPEPARAMS( backsector->c_slope, backc1, backc2, backsector->ceilingheight)
#undef SLOPEPARAMS
// if both ceilings are skies, consider it always "open"
// same for floors
if (!bothceilingssky && !bothfloorssky)
if (udmf)
{
if ((backc1 <= frontf1 && backc2 <= frontf2)
|| (backf1 >= frontc1 && backf2 >= frontc2))
// if both ceilings are skies, consider it always "open"
// same for floors
if (!bothceilingssky && !bothfloorssky)
{
goto clipsolid;
if ((backc1 <= frontf1 && backc2 <= frontf2)
|| (backf1 >= frontc1 && backf2 >= frontc2))
{
goto clipsolid;
}
// Check for automap fix. Store in doorclosed for r_segs.c
doorclosed = (backc1 <= backf1 && backc2 <= backf2
&& ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture)
&& ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture));
if (doorclosed)
goto clipsolid;
}
// Check for automap fix. Store in doorclosed for r_segs.c
doorclosed = (backc1 <= backf1 && backc2 <= backf2
&& ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture)
&& ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture));
if (doorclosed)
goto clipsolid;
// Window.
if (!bothceilingssky) // ceilings are always the "same" when sky
if (backc1 != frontc1 || backc2 != frontc2)
goto clippass;
if (!bothfloorssky) // floors are always the "same" when sky
if (backf1 != frontf1 || backf2 != frontf2)
goto clippass;
}
else
{
if (viewsector != backsector && viewsector != frontsector)
{
if ((backc1 <= frontf1 && backc2 <= frontf2)
|| (backf1 >= frontc1 && backf2 >= frontc2))
{
goto clipsolid;
}
// Window.
if (!bothceilingssky) // ceilings are always the "same" when sky
if (backc1 != frontc1 || backc2 != frontc2)
goto clippass;
if (!bothfloorssky) // floors are always the "same" when sky
if (backf1 != frontf1 || backf2 != frontf2)
// Check for automap fix. Store in doorclosed for r_segs.c
doorclosed = (backc1 <= backf1 && backc2 <= backf2
&& ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture)
&& ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture)
&& (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum));
if (doorclosed)
goto clipsolid;
}
// Window.
if (backc1 != frontc1 || backc2 != frontc2
|| backf1 != frontf1 || backf2 != frontf2)
{
goto clippass;
}
}
}
else
{
// if both ceilings are skies, consider it always "open"
// same for floors
if (!bothceilingssky && !bothfloorssky)
if (udmf)
{
if (backsector->ceilingheight <= frontsector->floorheight
|| backsector->floorheight >= frontsector->ceilingheight)
// if both ceilings are skies, consider it always "open"
// same for floors
if (!bothceilingssky && !bothfloorssky)
{
goto clipsolid;
if (backsector->ceilingheight <= frontsector->floorheight
|| backsector->floorheight >= frontsector->ceilingheight)
{
goto clipsolid;
}
// Check for automap fix. Store in doorclosed for r_segs.c
//
// This is used to fix the automap bug which
// showed lines behind closed doors simply because the door had a dropoff.
//
// It assumes that Doom has already ruled out a door being closed because
// of front-back closure (e.g. front floor is taller than back ceiling).
//
// if door is closed because back is shut:
doorclosed = backsector->ceilingheight <= backsector->floorheight
// preserve a kind of transparent door/lift special effect:
&& (backsector->ceilingheight >= frontsector->ceilingheight || curline->sidedef->toptexture)
&& (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture);
if (doorclosed)
goto clipsolid;
}
// Check for automap fix. Store in doorclosed for r_segs.c
//
// This is used to fix the automap bug which
// showed lines behind closed doors simply because the door had a dropoff.
//
// It assumes that Doom has already ruled out a door being closed because
// of front-back closure (e.g. front floor is taller than back ceiling).
//
// if door is closed because back is shut:
doorclosed = backsector->ceilingheight <= backsector->floorheight
// preserve a kind of transparent door/lift special effect:
&& (backsector->ceilingheight >= frontsector->ceilingheight || curline->sidedef->toptexture)
&& (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture);
if (doorclosed)
goto clipsolid;
// Window.
if (!bothceilingssky) // ceilings are always the "same" when sky
if (backsector->ceilingheight != frontsector->ceilingheight)
goto clippass;
if (!bothfloorssky) // floors are always the "same" when sky
if (backsector->floorheight != frontsector->floorheight)
goto clippass;
}
else
{
if (viewsector != backsector && viewsector != frontsector)
{
if (backsector->ceilingheight <= frontsector->floorheight
|| backsector->floorheight >= frontsector->ceilingheight)
{
goto clipsolid;
}
// Window.
if (!bothceilingssky) // ceilings are always the "same" when sky
if (backsector->ceilingheight != frontsector->ceilingheight)
goto clippass;
if (!bothfloorssky) // floors are always the "same" when sky
if (backsector->floorheight != frontsector->floorheight)
// Check for automap fix. Store in doorclosed for r_segs.c
doorclosed = (backsector->ceilingheight <= backsector->floorheight
&& (backsector->ceilingheight >= frontsector->ceilingheight || curline->sidedef->toptexture)
&& (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture)
&& (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum));
if (doorclosed)
goto clipsolid;
}
// Window.
if (backsector->ceilingheight != frontsector->ceilingheight
|| backsector->floorheight != frontsector->floorheight)
{
goto clippass;
}
}
}
// Reject empty lines used for triggers and special events.

View file

@ -2024,25 +2024,38 @@ void R_StoreWallRange(INT32 start, INT32 stop)
worldlow -= viewz;
worldlowslope -= viewz;
// hack to allow height changes in outdoor areas
// This is what gets rid of the upper textures if there should be sky
if (frontsector->ceilingpic == skyflatnum
&& backsector->ceilingpic == skyflatnum)
if (udmf) // more mess yippie
{
bothceilingssky = true;
}
// hack to allow height changes in outdoor areas
// This is what gets rid of the upper textures if there should be sky
if (frontsector->ceilingpic == skyflatnum
&& backsector->ceilingpic == skyflatnum)
{
bothceilingssky = true;
}
// likewise, but for floors and upper textures
if (frontsector->floorpic == skyflatnum
&& backsector->floorpic == skyflatnum)
// likewise, but for floors and upper textures
if (frontsector->floorpic == skyflatnum
&& backsector->floorpic == skyflatnum)
{
bothfloorssky = true;
}
}
else
{
bothfloorssky = true;
// hack to allow height changes in outdoor areas
if (frontsector->ceilingpic == skyflatnum
&& backsector->ceilingpic == skyflatnum)
{
worldtopslope = worldhighslope =
worldtop = worldhigh;
}
}
ds_p->sprtopclip = ds_p->sprbottomclip = NULL;
ds_p->silhouette = 0;
if (!bothfloorssky)
if (!bothfloorssky || !udmf)
{
if (worldbottomslope > worldlowslope || worldbottom > worldlow)
{
@ -2060,7 +2073,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
}
if (!bothceilingssky)
if (!bothceilingssky || !udmf)
{
if (worldtopslope < worldhighslope || worldtop < worldhigh)
{
@ -2078,7 +2091,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
}
if (!bothceilingssky && !bothfloorssky)
if (!bothceilingssky && !bothfloorssky || !udmf)
{
if (worldhigh <= worldbottom && worldhighslope <= worldbottomslope)
{
@ -2098,7 +2111,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
//SoM: 3/25/2000: This code fixes an automap bug that didn't check
// frontsector->ceiling and backsector->floor to see if a door was closed.
// Without the following code, sprites get displayed behind closed doors.
if (!bothceilingssky && !bothfloorssky)
if (!bothceilingssky && !bothfloorssky || !udmf)
{
if (doorclosed || (worldhigh <= worldbottom && worldhighslope <= worldbottomslope))
{
@ -2133,7 +2146,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
}
if (bothfloorssky)
if (!udmf && bothfloorssky)
{
// see double ceiling skies comment
// this is the same but for upside down thok barriers where the floor is sky and the ceiling is normal
@ -2165,7 +2178,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
markfloor = false;
}
if (bothceilingssky)
if (!udmf && bothceilingssky)
{
// double ceiling skies are special
// we don't want to lower the ceiling clipping, (no new plane is drawn anyway)
@ -2198,10 +2211,11 @@ void R_StoreWallRange(INT32 start, INT32 stop)
markceiling = false;
}
if (!bothceilingssky && !bothfloorssky)
if (!bothceilingssky && !bothfloorssky || !udmf)
{
if ((worldhigh <= worldbottom && worldhighslope <= worldbottomslope)
|| (worldlow >= worldtop && worldlowslope >= worldtopslope))
if ((udmf && ((worldhigh <= worldbottom && worldhighslope <= worldbottomslope)
|| (worldlow >= worldtop && worldlowslope >= worldtopslope))) || (! udmf && (backsector->ceilingheight <= frontsector->floorheight ||
backsector->floorheight >= frontsector->ceilingheight)))
{
// closed door
markceiling = markfloor = true;
@ -2209,8 +2223,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
// check TOP TEXTURE
if (!bothceilingssky // never draw the top texture if on
&& (worldhigh < worldtop || worldhighslope < worldtopslope))
if ((udmf && !bothceilingssky || !udmf) && (worldhigh < worldtop || worldhighslope < worldtopslope)) // never draw the top texture if on
{
fixed_t texheight;
// top texture
@ -2240,8 +2253,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
}
// check BOTTOM TEXTURE
if (!bothfloorssky // never draw the bottom texture if on
&& (worldlow > worldbottom || worldlowslope > worldbottomslope)) // Only if VISIBLE!!!
if ((udmf && !bothfloorssky || !udmf) && (worldlow > worldbottom || worldlowslope > worldbottomslope)) // never draw the top texture if on
{
// bottom texture
bottomtexture = R_GetTextureNum(sidedef->bottomtexture);