fix portal clipping being completely completely broken on kart maps

truly amazing
This commit is contained in:
Alug 2025-06-08 22:01:41 +02:00
parent 1c5dc89b33
commit e63f68e732
4 changed files with 35 additions and 5 deletions

View file

@ -37,6 +37,32 @@ void Portal_InitList (void)
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.
*/
void Portal_ClipApply (const portal_t* portal)
@ -158,6 +184,9 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con
portal->clipline = line2;
if (mapnamespace == MNS_SRB2KART)
Portal_ClipRange(portal);
g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg
}

View file

@ -58,6 +58,7 @@ void Portal_Remove (portal_t* portal);
void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2);
void Portal_AddSkybox (const visplane_t* plane);
void Portal_ClipRange (portal_t* portal);
void Portal_ClipApply (const portal_t* portal);
void Portal_AddSkyboxPortals (void);

View file

@ -1596,7 +1596,7 @@ static void R_RenderSegLoop (drawcolumndata_t* dc)
// Portal line
// Spans the entire height of a single-sided line or
// the "window" of a double-sided line.
if (g_portal)
if (g_portal && (mapnamespace != MNS_SRB2KART))
{
I_Assert(rw_x >= g_portal->start && rw_x < g_portal->end);
i = rw_x - g_portal->start;
@ -2245,7 +2245,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|| frontsector->extra_colormap != backsector->extra_colormap
|| (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags))
// Portals block traversal behind them
|| g_portal
|| (g_portal && mapnamespace != MNS_SRB2KART)
// Highlighting death pits
|| (cv_debugfinishline.value && frontsector->damagetype != backsector->damagetype))
{
@ -2283,7 +2283,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|| frontsector->extra_colormap != backsector->extra_colormap
|| (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags))
// Portals block traversal behind them
|| g_portal
|| (g_portal && mapnamespace != MNS_SRB2KART)
// Highlighting death pits
|| (cv_debugfinishline.value && frontsector->damagetype != backsector->damagetype))
{

View file

@ -1402,7 +1402,7 @@ lumpnum_t W_CheckNumForName(const char *name)
INT32 i;
UINT32 hash = name ? quickncasehash(name, 8) : 0;
lumpnum_t check = INT16_MAX;
if (name == NULL)
return LUMPERROR;
@ -1454,7 +1454,7 @@ lumpnum_t W_CheckNumForLongName(const char *name)
INT32 i;
UINT32 hash = name ? quickncasehash(name, 8) : 0;
lumpnum_t check = INT16_MAX;
if (name == NULL)
return LUMPERROR;