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; }