fixed overdlow when calculating winding of large polygons in the
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Sat, 15 Sep 2018 16:32:52 +0000 (19:32 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Sat, 15 Sep 2018 16:32:52 +0000 (19:32 +0300)
rasterizert

src/polytmpl.h

index d61ac8e..2147666 100644 (file)
@@ -96,7 +96,7 @@ void POLYFILL(struct pvertex *pv, int nverts)
        int winding = 0;
        for(i=0; i<nverts; i++) {
                int next = NEXTIDX(i);
        int winding = 0;
        for(i=0; i<nverts; i++) {
                int next = NEXTIDX(i);
-               winding += (pv[next].x - pv[i].x) * (pv[next].y + pv[i].y);
+               winding += ((pv[next].x - pv[i].x) >> 8) * ((pv[next].y + pv[i].y) >> 8);
        }
 
        /* +1 to avoid crashing due to off-by-one rounding errors in the rasterization */
        }
 
        /* +1 to avoid crashing due to off-by-one rounding errors in the rasterization */