From a0502810065e13a4299ff1cf0475edbdef9f6d5e Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 2 Mar 2019 23:22:12 +0000 Subject: [PATCH] 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 --- source/build/src/polymost.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 94660737f..c83df3b82 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -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! static vsptyp vsp[VSPMAX]; static int32_t gtag; +static float xbl, xbr; +int32_t domost_rejectcount; 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? } + // 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 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 + xbl = px[imin]; vsp[vcnt].x = px[imin]; vsp[vcnt].cy[0] = vsp[vcnt].fy[0] = py[imin]; vcnt++; @@ -5344,6 +5354,8 @@ static void polymost_initmosts(const float * px, const float * py, int const n) } } while (i != j); + xbr = px[i]; + if (px[i] > vsp[vcnt-1].x) { vsp[vcnt].x = px[i]; @@ -5351,6 +5363,8 @@ static void polymost_initmosts(const float * px, const float * py, int const n) vcnt++; } + domost_rejectcount = 0; + vsp_finalize_init(vcnt); gtag = vcnt; }