revert solidcol stuffs i did ages ago apparently lol

This commit is contained in:
Alug committed 2024-05-25 12:57:41 +02:00
1 parent c1a9c58eb5
commit 6112be232a
4 files changed
+167 -65

No files matched your search

+154 -51
View File
@@ -71,56 +71,156 @@ void R_ClearDrawSegs(void)
ds_p = drawsegs;
}
// Fix from boom.
static UINT32 maxsegs;
// CPhipps -
// Instead of clipsegs, let's try using an array with one entry for each column,
// indicating whether it's blocked by a solid wall yet or not.
UINT8 *solidcol;
// newend is one past the last valid seg
static cliprange_t *newend;
static cliprange_t *solidsegs;
void R_AllocClipSegMemory(void)
{
solidcol = Z_Realloc(solidcol, sizeof(*solidcol) * viewwidth, PU_STATIC, NULL);
UINT32 newendpos = newend - solidsegs;
maxsegs = max(BASEVIDWIDTH/2+1, viewwidth/2+1);
solidsegs = Z_Realloc(solidsegs, sizeof(*solidsegs) * maxsegs, PU_STATIC, NULL);
newend = solidsegs + newendpos;
}
//
// CPhipps -
// R_ClipWallSegment
// R_ClipSolidWallSegment
// Does handle solid walls,
// e.g. single sided LineDefs (middle texture)
// that entirely block the view.
//
// 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(INT32 first, INT32 last, boolean solid, boolean soliddontrender)
static void R_ClipSolidWallSegment(INT32 first, INT32 last)
{
while (first < last)
cliprange_t *next;
cliprange_t *start;
// Find the first range that touches the range (adjacent pixels are touching).
start = solidsegs;
while (start->last < first - 1)
start++;
if (first < start->first)
{
UINT8 *p;
if (solidcol[first])
if (last < start->first - 1)
{
p = memchr(solidcol+first, 0, last-first);
if (!p)
return; // All solid
// Post is entirely visible (above start), so insert a new clippost.
R_StoreWallRange(first, last);
next = newend;
newend++;
// NO MORE CRASHING!
if (newend - solidsegs > maxsegs)
I_Error("R_ClipSolidWallSegment: Solid Segs overflow!\n");
first = p - solidcol;
while (next != start)
{
*next = *(next-1);
next--;
}
next->first = first;
next->last = last;
return;
}
else
// There is a fragment above *start.
R_StoreWallRange(first, start->first - 1);
// Now adjust the clip size.
start->first = first;
}
// Bottom contained in start?
if (last <= start->last)
return;
next = start;
while (last >= (next+1)->first - 1)
{
// There is a fragment between two posts.
R_StoreWallRange(next->last + 1, (next+1)->first - 1);
next++;
if (last <= next->last)
{
p = memchr(solidcol+first, 1, last-first);
int to;
if (!p)
to = last;
else
to = p - solidcol;
if (!soliddontrender)
R_StoreWallRange(first, to-1);
if (solid)
memset(solidcol+first, 1, to-first);
first = to;
// Bottom is contained in next.
// Adjust the clip size.
start->last = next->last;
goto crunch;
}
}
// There is a fragment after *next.
R_StoreWallRange(next->last + 1, last);
// Adjust the clip size.
start->last = last;
// Remove start+1 to next from the clip list, because start now covers their area.
crunch:
if (next == start)
return; // Post just extended past the bottom of one post.
while (next++ != newend)
*++start = *next; // Remove a post.
newend = start + 1;
// NO MORE CRASHING!
if (newend - solidsegs > maxsegs)
I_Error("R_ClipSolidWallSegment: Solid Segs overflow!\n");
}
//
// R_ClipPassWallSegment
// Clips the given range of columns, but does not include it in the clip list.
// Does handle windows, e.g. LineDefs with upper and lower texture.
//
static inline void R_ClipPassWallSegment(INT32 first, INT32 last, boolean soliddontrender)
{
cliprange_t *start;
// Find the first range that touches the range
// (adjacent pixels are touching).
start = solidsegs;
while (start->last < first - 1)
start++;
if (first < start->first)
{
if (last < start->first - 1)
{
// Post is entirely visible (above start).
if (!soliddontrender)
R_StoreWallRange(first, last);
return;
}
// There is a fragment above *start.
if (!soliddontrender)
R_StoreWallRange(first, start->first - 1);
}
// Bottom contained in start?
if (last <= start->last)
return;
while (last >= (start+1)->first - 1)
{
// There is a fragment between two posts.
if (!soliddontrender)
R_StoreWallRange(start->last + 1, (start+1)->first - 1);
start++;
if (last <= start->last)
return;
}
// There is a fragment after *next.
if (!soliddontrender)
R_StoreWallRange(start->last + 1, last);
}
//
@@ -128,18 +228,19 @@ static void R_ClipWallSegment(INT32 first, INT32 last, boolean solid, boolean so
//
void R_ClearClipSegs(void)
{
memset(solidcol, 0, viewwidth);
solidsegs[0].first = -0x7fffffff;
solidsegs[0].last = -1;
solidsegs[1].first = viewwidth;
solidsegs[1].last = 0x7fffffff;
newend = solidsegs + 2;
}
void R_PortalClearClipSegs(INT32 start, INT32 end)
{
R_ClearClipSegs();
for (INT32 x = 0; x < start; x++)
solidcol[x] = 1;
for (INT32 x = end; x < viewwidth; x++)
solidcol[x] = 1;
solidsegs[0].first = -0x7fffffff;
solidsegs[0].last = start-1;
solidsegs[1].first = end;
solidsegs[1].last = 0x7fffffff;
newend = solidsegs + 2;
}
//
@@ -499,14 +600,14 @@ static void R_AddLine(seg_t *line)
clippass:
g_walloffscreen = false;
if (g_walloffscreen)
R_ClipWallSegment(x1, x2, false , true);
R_ClipPassWallSegment(x1, x2 - 1, true);
else
R_ClipWallSegment(x1, x2, false , false);
R_ClipPassWallSegment(x1, x2 - 1, false);
return;
clipsolid:
g_walloffscreen = false;
R_ClipWallSegment(x1, x2, false , false);
R_ClipSolidWallSegment(x1, x2 - 1);
}
//
@@ -539,6 +640,7 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
angle_t angle1, angle2;
INT32 sx1, sx2, boxpos;
const INT32* check;
cliprange_t *start;
// Find the corners of the box that define the edges from current viewpoint.
if (viewx <= bspcoord[BOXLEFT])
@@ -595,11 +697,12 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
if (sx1 >= sx2)
return false;
if (!memchr(solidcol+sx1, 0, sx2-sx1))
{
// All columns it covers are already solidly covered
return false;
}
start = solidsegs;
while (start->last < sx2)
start++;
if (sx1 >= start->first && sx2 <= start->last)
return false; // The clippost contains the new span.
return true;
}
-2
View File
@@ -34,8 +34,6 @@ extern drawseg_t *ds_p;
extern INT32 doorclosed;
extern boolean g_walloffscreen;
extern UINT8 *solidcol;
// BSP?
void R_ClearClipSegs(void);
void R_PortalClearClipSegs(INT32 start, INT32 end);
+11
View File
@@ -25,6 +25,17 @@
#include "screen.h" // MAXVIDWIDTH, MAXVIDHEIGHT
//
// ClipWallSegment
// Clips the given range of columns
// and includes it in the new clip list.
//
typedef struct
{
INT32 first;
INT32 last;
} cliprange_t;
// Silhouette, needed for clipping segs (mainly) and sprites representing things.
#define SIL_NONE 0
#define SIL_BOTTOM 1
+2 -12
View File
@@ -1194,8 +1194,6 @@ static boolean R_FFloorCanClip(visffloor_t *pfloor)
#define HEIGHTBITS 12
#define HEIGHTUNIT (1<<HEIGHTBITS)
static boolean didsolidcol; // True if at least one column was marked solid
static void R_RenderSegLoop (void)
{
angle_t angle;
@@ -1549,12 +1547,6 @@ static void R_RenderSegLoop (void)
floorclip[rw_x] = bottomclip;
}
if ((markceiling || markfloor) && (floorclip[rw_x] <= ceilingclip[rw_x] + 1))
{
solidcol[rw_x] = 1;
didsolidcol = true;
}
if (maskedtexture || numthicksides)
{
// save texturecol for backdrawing of masked mid texture
@@ -1599,7 +1591,7 @@ static void R_RenderSegLoop (void)
bottomfrac += bottomstep;
}
colfunc = wallcolfunc;
//colfunc = wallcolfunc;
}
// Uses precalculated seg->length
@@ -2830,8 +2822,6 @@ void R_StoreWallRange(INT32 start, INT32 stop)
rw_tsilheight = &(ds_p->tsilheight);
rw_bsilheight = &(ds_p->bsilheight);
didsolidcol = false;
#ifdef WALLSPLATS
if (linedef->splats && cv_splats.value)
{
@@ -2847,7 +2837,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
#endif
R_RenderSegLoop();
//colfunc = wallcolfunc;
colfunc = wallcolfunc;
if (portalline) // if curline is a portal, set portalrender for drawseg
ds_p->portalpass = portalrender+1;