Alug committed 2024-02-17 22:52:12 +01:00
1 parent 43e2be58da
commit c64e10083b
2 files changed
+140 -8

No files matched your search

+17 -2
View File
@@ -82,7 +82,7 @@ void R_AllocClipSegMemory(void)
//
// Replaces the old R_Clip*WallSegment functions. It draws bits of walls in those
// columns which aren't solid, and updates the solidcol[] array appropriately
static void R_ClipWallSegment(int first, int last, boolean solid)
static void R_ClipWallSegment(INT32 first, INT32 last, boolean solid)
{
while (first < last)
{
@@ -123,6 +123,7 @@ void R_ClearClipSegs(void)
{
memset(solidcol, 0, viewwidth);
}
void R_PortalClearClipSegs(INT32 start, INT32 end)
{
R_ClearClipSegs();
@@ -518,7 +519,21 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
const INT32* check;
// Find the corners of the box that define the edges from current viewpoint.
if ((boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT] ? 1 : 2) + (viewy >= bspcoord[BOXTOP] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8)) == 5)
if (viewx <= bspcoord[BOXLEFT])
boxpos = 0;
else if (viewx < bspcoord[BOXRIGHT])
boxpos = 1;
else
boxpos = 2;
if (viewy >= bspcoord[BOXTOP])
boxpos |= 0;
else if (viewy > bspcoord[BOXBOTTOM])
boxpos |= 1<<2;
else
boxpos |= 2<<2;
if (boxpos == 5)
return true;
check = checkcoord[boxpos];
+123 -6
View File
@@ -1229,6 +1229,19 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
#undef CLAMPMIN
}
// R_ExpandPlaneY
//
// A simple function to modify a visplane's top and bottom for a particular column
// Sort of like R_ExpandPlane in r_plane.c, except this is vertical expansion
static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bottom)
{
// Expand the plane, don't shrink it!
// note: top and bottom default to 0xFFFF and 0x0000 respectively, which is totally compatible with this
if (pl->top[x] > top) pl->top[x] = top;
if (pl->bottom[x] < bottom) pl->bottom[x] = bottom;
}
// R_FFloorCanClip
//
// Returns true if a fake floor can clip a column away.
@@ -1603,7 +1616,7 @@ static void R_RenderSegLoop (void)
floorclip[rw_x] = bottomclip;
}
if ((markceiling || markfloor) && (floorclip[rw_x] <= ceilingclip[rw_x] + 1))
if (floorclip[rw_x] <= ceilingclip[rw_x] + 1)
{
solidcol[rw_x] = 1;
didsolidcol = true;
@@ -1655,6 +1668,77 @@ static void R_RenderSegLoop (void)
colfunc = wallcolfunc;
}
static void R_MarkSegBounds(void)
{
INT32 top, bottom;
INT16 topclip, bottomclip;
for (; rw_x < rw_stopx; rw_x++)
{
// mark floor / ceiling areas
INT32 yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
INT32 yh = bottomfrac>>HEIGHTBITS;
// Mark ceiling
top = ceilingclip[rw_x]+1;
// no space above wall?
if (yl < top)
yl = top;
if (markceiling)
{
if (yl > floorclip[rw_x])
bottom = floorclip[rw_x] - 1;
else
bottom = yl - 1;
if (ceilingplane && top <= bottom)
R_ExpandPlaneY(ceilingplane, rw_x, top, bottom);
}
// Mark floor
bottom = floorclip[rw_x]-1;
// no space below floor?
if (yh > bottom)
yh = bottom;
if (markfloor)
{
if (yh < ceilingclip[rw_x])
top = ceilingclip[rw_x] + 1;
else
top = yh + 1;
if (floorplane && top <= bottom)
R_ExpandPlaneY(floorplane, rw_x, top, bottom);
}
frontscale[rw_x] = rw_scale;
topclip = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
bottomclip = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight;
if (markceiling) // no top wall
ceilingclip[rw_x] = topclip;
if (markfloor) // no bottom wall
floorclip[rw_x] = bottomclip;
if (floorclip[rw_x] <= ceilingclip[rw_x] + 1)
{
solidcol[rw_x] = 1;
didsolidcol = true;
}
rw_scale += rw_scalestep;
topfrac += topstep;
bottomfrac += bottomstep;
}
}
// Uses precalculated seg->length
static INT64 R_CalcSegDist(seg_t* seg, INT64 x2, INT64 y2)
{
@@ -2923,12 +3007,30 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
}
rw_silhouette = &(ds_p->silhouette);
rw_tsilheight = &(ds_p->tsilheight);
rw_bsilheight = &(ds_p->bsilheight);
didsolidcol = false;
if (!segtextured && !numffloors)
{
if (markfloor || markceiling)
R_MarkSegBounds();
else
{
for (; rw_x < rw_stopx; rw_x++)
{
frontscale[rw_x] = rw_scale;
rw_scale += rw_scalestep;
}
}
}
else
{
rw_silhouette = &ds_p->silhouette;
rw_tsilheight = &ds_p->tsilheight;
rw_bsilheight = &ds_p->bsilheight;
R_RenderSegLoop();
}
#ifdef WALLSPLATS
if (linedef->splats && cv_splats.value)
{
@@ -2942,7 +3044,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
else
#endif
R_RenderSegLoop();
//R_RenderSegLoop();
//colfunc = wallcolfunc;
if (portalline) // if curline is a portal, set portalrender for drawseg
@@ -2964,6 +3066,21 @@ void R_StoreWallRange(INT32 start, INT32 stop)
ds_p->tsilheight = backsector->c_slope ? INT32_MIN : backsector->ceilingheight;
}
}
// cph - if a column was made solid by this wall, we _must_ save full clipping info
if (backsector && didsolidcol)
{
if (!(ds_p->silhouette & SIL_BOTTOM))
{
ds_p->silhouette |= SIL_BOTTOM;
ds_p->bsilheight = backsector->f_slope ? INT32_MAX : backsector->floorheight;
}
if (!(ds_p->silhouette & SIL_TOP))
{
ds_p->silhouette |= SIL_TOP;
ds_p->tsilheight = backsector->c_slope ? INT32_MIN : backsector->ceilingheight;
}
}
// save sprite clipping info
if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip)