A curious Polymost optimization from Nuke.YKT

This bails out of drawing any domost spans that seem to be entirely outside of the range of the screen coordinates. Since this seems so obvious, I have to wonder if Polymost is supposed to be doing this elsewhere already...

git-svn-id: https://svn.eduke32.com/eduke32@7379 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-03-02 23:22:12 +00:00
parent e61831ad5d
commit a050281006

View file

@ -38,6 +38,8 @@ typedef struct { float x, cy[2], fy[2]; int32_t tag; int16_t n, p, ctag, ftag; }
#define VSPMAX 2048 //<- careful! #define VSPMAX 2048 //<- careful!
static vsptyp vsp[VSPMAX]; static vsptyp vsp[VSPMAX];
static int32_t gtag; static int32_t gtag;
static float xbl, xbr;
int32_t domost_rejectcount;
static float dxb1[MAXWALLSB], dxb2[MAXWALLSB]; static float dxb1[MAXWALLSB], dxb2[MAXWALLSB];
@ -3562,6 +3564,13 @@ static void polymost_domost(float x0, float y0, float x1, float y1)
y1 += DOMOST_OFFSET; //necessary? y1 += DOMOST_OFFSET; //necessary?
} }
// Test if span is outside screen bounds
if (x1+DOMOST_OFFSET < xbl || x0-DOMOST_OFFSET > xbr)
{
domost_rejectcount++;
return;
}
vec2f_t const dm0 = { x0, y0 }; vec2f_t const dm0 = { x0, y0 };
vec2f_t const dm1 = { x1, y1 }; vec2f_t const dm1 = { x1, y1 };
@ -5296,6 +5305,7 @@ static void polymost_initmosts(const float * px, const float * py, int const n)
int32_t vcnt = 1; //0 is dummy solid node int32_t vcnt = 1; //0 is dummy solid node
xbl = px[imin];
vsp[vcnt].x = px[imin]; vsp[vcnt].x = px[imin];
vsp[vcnt].cy[0] = vsp[vcnt].fy[0] = py[imin]; vsp[vcnt].cy[0] = vsp[vcnt].fy[0] = py[imin];
vcnt++; vcnt++;
@ -5344,6 +5354,8 @@ static void polymost_initmosts(const float * px, const float * py, int const n)
} }
} while (i != j); } while (i != j);
xbr = px[i];
if (px[i] > vsp[vcnt-1].x) if (px[i] > vsp[vcnt-1].x)
{ {
vsp[vcnt].x = px[i]; vsp[vcnt].x = px[i];
@ -5351,6 +5363,8 @@ static void polymost_initmosts(const float * px, const float * py, int const n)
vcnt++; vcnt++;
} }
domost_rejectcount = 0;
vsp_finalize_init(vcnt); vsp_finalize_init(vcnt);
gtag = vcnt; gtag = vcnt;
} }