Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
  • Jisk/srb-2-beef-jerky
117 results
Select Git revision
Show changes
Commits on Source (2)
  • Lactozilla's avatar
    Optimize R_StoreWallRange · a44af519
    Lactozilla authored
    Sometimes a drawseg doesn't have any textures to render, meaning R_RenderSegLoop
    might end up doing a lot of checks that aren't needed. R_MarkSegBounds is a
    reduced version of R_RenderSegLoop for that situation.
    
    Also, this commit removes clipsegs, like PrBoom-plus does.
    a44af519
  • Lactozilla's avatar
    Remove redundant check · a04bef7d
    Lactozilla authored
    a04bef7d
......@@ -52,163 +52,65 @@ void R_ClearDrawSegs(void)
ds_p = drawsegs;
}
// Fix from boom.
#define MAXSEGS (MAXVIDWIDTH/2+1)
// 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[MAXVIDWIDTH];
// newend is one past the last valid seg
static cliprange_t *newend;
static cliprange_t solidsegs[MAXSEGS];
//
// R_ClipSolidWallSegment
// Does handle solid walls,
// e.g. single sided LineDefs (middle texture)
// that entirely block the view.
// CPhipps -
// R_ClipWallSegment
//
static void R_ClipSolidWallSegment(INT32 first, INT32 last)
// 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)
{
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)
{
if (last < start->first - 1)
{
// 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");
while (next != start)
{
*next = *(next-1);
next--;
}
next->first = first;
next->last = last;
return;
}
// 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)
while (first < last)
{
// There is a fragment between two posts.
R_StoreWallRange(next->last + 1, (next+1)->first - 1);
next++;
UINT8 *p;
if (last <= next->last)
if (solidcol[first])
{
// 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)
{
cliprange_t *start;
// Find the first range that touches the range
// (adjacent pixels are touching).
start = solidsegs;
while (start->last < first - 1)
start++;
p = memchr(solidcol+first, 0, last-first);
if (!p)
return; // All solid
if (first < start->first)
{
if (last < start->first - 1)
{
// Post is entirely visible (above start).
R_StoreWallRange(first, last);
return;
first = p - solidcol;
}
else
{
p = memchr(solidcol+first, 1, last-first);
// There is a fragment above *start.
R_StoreWallRange(first, start->first - 1);
}
int to;
if (!p)
to = last;
else
to = p - solidcol;
// Bottom contained in start?
if (last <= start->last)
return;
R_StoreWallRange(first, to-1);
while (last >= (start+1)->first - 1)
{
// There is a fragment between two posts.
R_StoreWallRange(start->last + 1, (start+1)->first - 1);
start++;
if (solid)
memset(solidcol+first, 1, to-first);
if (last <= start->last)
return;
first = to;
}
}
// There is a fragment after *next.
R_StoreWallRange(start->last + 1, last);
}
//
// R_ClearClipSegs
//
void R_ClearClipSegs(void)
{
solidsegs[0].first = -0x7fffffff;
solidsegs[0].last = -1;
solidsegs[1].first = viewwidth;
solidsegs[1].last = 0x7fffffff;
newend = solidsegs + 2;
memset(solidcol, 0, viewwidth);
}
void R_PortalClearClipSegs(INT32 start, INT32 end)
{
solidsegs[0].first = -0x7fffffff;
solidsegs[0].last = start-1;
solidsegs[1].first = end;
solidsegs[1].last = 0x7fffffff;
newend = solidsegs + 2;
}
R_ClearClipSegs();
for (INT32 x = 0; x < start; x++)
solidcol[x] = 1;
for (INT32 x = end; x < viewwidth; x++)
solidcol[x] = 1;
}
// R_DoorClosed
//
......@@ -615,11 +517,11 @@ static void R_AddLine(seg_t *line)
return;
clippass:
R_ClipPassWallSegment(x1, x2 - 1);
R_ClipWallSegment(x1, x2, false);
return;
clipsolid:
R_ClipSolidWallSegment(x1, x2 - 1);
R_ClipWallSegment(x1, x2, true);
}
//
......@@ -652,10 +554,23 @@ 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 ((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];
......@@ -684,14 +599,14 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
sx2 = viewangletox[angle2];
// Does not cross a pixel.
if (sx1 >= sx2) return false;
start = solidsegs;
while (start->last < sx2)
start++;
if (sx1 >= sx2)
return false;
if (sx1 >= start->first && sx2 <= start->last)
return false; // The clippost contains the new span.
if (!memchr(solidcol+sx1, 0, sx2-sx1))
{
// All columns it covers are already solidly covered
return false;
}
return true;
}
......@@ -1399,7 +1314,7 @@ void R_RenderPortalHorizonLine(sector_t *sector)
firstseg = NULL;
curline = &segs[0];
R_ClipSolidWallSegment(portalclipstart, portalclipend);
R_ClipWallSegment(portalclipstart, portalclipend, true);
curline = NULL;
}
......@@ -38,6 +38,8 @@ extern boolean horizonline;
extern INT32 doorclosed;
extern UINT8 solidcol[MAXVIDWIDTH];
// BSP?
void R_ClearClipSegs(void);
void R_PortalClearClipSegs(INT32 start, INT32 end);
......
......@@ -27,17 +27,6 @@
#include "taglist.h"
//
// 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
......
......@@ -973,6 +973,8 @@ static boolean R_FFloorCanClip(visffloor_t *pfloor)
return (cv_ffloorclip.value && !R_IsFFloorTranslucent(pfloor) && !pfloor->polyobj);
}
static boolean didsolidcol; // True if at least one column was marked solid
//
// R_RenderSegLoop
// Draws zero, one, or two textures (and possibly a masked
......@@ -1389,6 +1391,12 @@ 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 (maskedtexturecol)
maskedtexturecol[rw_x] = texturecolumn + rw_offsetx;
......@@ -1450,6 +1458,76 @@ static void R_RenderSegLoop (void)
}
}
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)
{
......@@ -2784,11 +2862,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();
}
R_RenderSegLoop();
colfunc = colfuncs[BASEDRAWFUNC];
if (portalline) // if curline is a portal, set portalrender for drawseg
......@@ -2796,6 +2893,21 @@ void R_StoreWallRange(INT32 start, INT32 stop)
else
ds_p->portalpass = 0;
// 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 (maskedtexture || (ds_p->silhouette & (SIL_TOP | SIL_BOTTOM)))
{
......