* A small bug related to polyfill is fixed 4.x-dev

Mon, 12 Jul 2021 20:43:54 +0300

author
cemkalyoncu
date
Mon, 12 Jul 2021 20:43:54 +0300
branch
4.x-dev
changeset 1714
8f26a5085048
parent 1713
80875b924288
child 1715
32784d399331

* A small bug related to polyfill is fixed

Source/Gorgon/CGI/Polygon.h file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/CGI/Polygon.h	Mon Jul 12 17:44:02 2021 +0300
+++ b/Source/Gorgon/CGI/Polygon.h	Mon Jul 12 20:43:54 2021 +0300
@@ -83,8 +83,8 @@
                 
                 auto min = line.PointAtMinY();
                 
-                int miny = int(min.Y * scale);
-                int maxy = int(line.MaxY() * scale);
+                int miny = (int)round(min.Y * scale);
+                int maxy = (int)round(line.MaxY() * scale);
                 
                 if(miny == maxy || miny > ymax || maxy < ymin)
                     continue;
@@ -177,12 +177,18 @@
                             winding += it->dir;
                         }
                     }
+
+                    Float nx;
+
+                    if(strict == polygonstrictmode::outside)
+                        nx = it->x2;
+                    else
+                        nx = it->x1;
+
+                    nx = Clamp(nx, it->minx, it->maxx);
                     
-                    if(winding == 0 && start < it->x1) {
-                        if(strict == polygonstrictmode::outside)
-                            drawlist.push_back({start, Clamp(it->x2, it->minx, it->maxx), index});
-                        else
-                            drawlist.push_back({start, Clamp(it->x1, it->minx, it->maxx), index});
+                    if(winding == 0 && start < nx) {
+                        drawlist.push_back({start, nx, index});
                     }
                 }
                 

mercurial