mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 12:31:54 +00:00
Set portal clipping in R_RenderSegLoop
Previously, line-based portals accessed global ceilingclip/floorclip before the current seg was rendered. This means clipping for such portals would be based on whichever seg happened to render before. Additionally, ceilingclip/floorclip have more to do with clipping the visplanes than the height of the wall between (for instance, using these values doesn't work for two-sided lines that create a "window" between the planes). The correct approach that should always work is using the midtexture's height from inside of R_RenderSegLoop.
This commit is contained in:
parent
20692de47a
commit
4e79b4ead2
3 changed files with 23 additions and 36 deletions
|
|
@ -38,32 +38,6 @@ void Portal_InitList (void)
|
||||||
portal_base = portal_cap = NULL;
|
portal_base = portal_cap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Store the clipping window for a portal in its given range.
|
|
||||||
*
|
|
||||||
* The window is copied from the current window at the time
|
|
||||||
* the function is called, so it is useful for converting one-sided
|
|
||||||
* lines into portals.
|
|
||||||
*/
|
|
||||||
void Portal_ClipRange (portal_t* portal)
|
|
||||||
{
|
|
||||||
INT32 start = portal->start;
|
|
||||||
INT32 end = portal->end;
|
|
||||||
INT16 *ceil = portal->ceilingclip;
|
|
||||||
INT16 *floor = portal->floorclip;
|
|
||||||
fixed_t *scale = portal->frontscale;
|
|
||||||
|
|
||||||
INT32 i;
|
|
||||||
for (i = 0; i < end-start; i++)
|
|
||||||
{
|
|
||||||
*ceil = ceilingclip[start+i];
|
|
||||||
ceil++;
|
|
||||||
*floor = floorclip[start+i];
|
|
||||||
floor++;
|
|
||||||
*scale = frontscale[start+i];
|
|
||||||
scale++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Apply the clipping window from a portal.
|
/** Apply the clipping window from a portal.
|
||||||
*/
|
*/
|
||||||
void Portal_ClipApply (const portal_t* portal)
|
void Portal_ClipApply (const portal_t* portal)
|
||||||
|
|
@ -187,8 +161,6 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con
|
||||||
|
|
||||||
portal->clipline = line2;
|
portal->clipline = line2;
|
||||||
|
|
||||||
Portal_ClipRange(portal);
|
|
||||||
|
|
||||||
g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg
|
g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ void Portal_Remove (portal_t* portal);
|
||||||
void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2);
|
void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2);
|
||||||
void Portal_AddSkybox (const player_t* player, const visplane_t* plane);
|
void Portal_AddSkybox (const player_t* player, const visplane_t* plane);
|
||||||
|
|
||||||
void Portal_ClipRange (portal_t* portal);
|
|
||||||
void Portal_ClipApply (const portal_t* portal);
|
void Portal_ClipApply (const portal_t* portal);
|
||||||
|
|
||||||
void Portal_AddSkyboxPortals (const player_t* player);
|
void Portal_AddSkyboxPortals (const player_t* player);
|
||||||
|
|
|
||||||
30
src/r_segs.c
30
src/r_segs.c
|
|
@ -1525,6 +1525,21 @@ static void R_RenderSegLoop (void)
|
||||||
|
|
||||||
frontscale[rw_x] = rw_scale;
|
frontscale[rw_x] = rw_scale;
|
||||||
|
|
||||||
|
const INT16 topclip = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
|
||||||
|
const INT16 bottomclip = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight;
|
||||||
|
|
||||||
|
// Portal line
|
||||||
|
// Spans the entire height of a single-sided line or
|
||||||
|
// the "window" of a double-sided line.
|
||||||
|
if (g_portal)
|
||||||
|
{
|
||||||
|
I_Assert(rw_x >= g_portal->start && rw_x < g_portal->end);
|
||||||
|
i = rw_x - g_portal->start;
|
||||||
|
g_portal->frontscale[i] = rw_scale;
|
||||||
|
g_portal->ceilingclip[i] = topclip;
|
||||||
|
g_portal->floorclip[i] = bottomclip;
|
||||||
|
}
|
||||||
|
|
||||||
// draw the wall tiers
|
// draw the wall tiers
|
||||||
if (midtexture)
|
if (midtexture)
|
||||||
{
|
{
|
||||||
|
|
@ -1566,16 +1581,13 @@ static void R_RenderSegLoop (void)
|
||||||
{
|
{
|
||||||
// note: don't use min/max macros, since casting from INT32 to INT16 is involved here
|
// note: don't use min/max macros, since casting from INT32 to INT16 is involved here
|
||||||
if (markceiling && (!rw_ceilingmarked))
|
if (markceiling && (!rw_ceilingmarked))
|
||||||
ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
|
ceilingclip[rw_x] = topclip;
|
||||||
if (markfloor && (!rw_floormarked))
|
if (markfloor && (!rw_floormarked))
|
||||||
floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight;
|
floorclip[rw_x] = bottomclip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
INT16 topclip = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
|
|
||||||
INT16 bottomclip = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight;
|
|
||||||
|
|
||||||
// two sided line
|
// two sided line
|
||||||
if (toptexture)
|
if (toptexture)
|
||||||
{
|
{
|
||||||
|
|
@ -2145,7 +2157,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||||
|| backsector->floorlightsec != frontsector->floorlightsec
|
|| backsector->floorlightsec != frontsector->floorlightsec
|
||||||
//SoM: 4/3/2000: Check for colormaps
|
//SoM: 4/3/2000: Check for colormaps
|
||||||
|| frontsector->extra_colormap != backsector->extra_colormap
|
|| frontsector->extra_colormap != backsector->extra_colormap
|
||||||
|| (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags)))
|
|| (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags))
|
||||||
|
// Portals block traversal behind them
|
||||||
|
|| g_portal)
|
||||||
{
|
{
|
||||||
markfloor = true;
|
markfloor = true;
|
||||||
}
|
}
|
||||||
|
|
@ -2178,7 +2192,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||||
|| backsector->ceilinglightsec != frontsector->ceilinglightsec
|
|| backsector->ceilinglightsec != frontsector->ceilinglightsec
|
||||||
//SoM: 4/3/2000: Check for colormaps
|
//SoM: 4/3/2000: Check for colormaps
|
||||||
|| frontsector->extra_colormap != backsector->extra_colormap
|
|| frontsector->extra_colormap != backsector->extra_colormap
|
||||||
|| (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags)))
|
|| (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags))
|
||||||
|
// Portals block traversal behind them
|
||||||
|
|| g_portal)
|
||||||
{
|
{
|
||||||
markceiling = true;
|
markceiling = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue