* Out of screen bug fixed 4.x-dev

Sun, 16 May 2021 08:54:01 +0300

author
cemkalyoncu
date
Sun, 16 May 2021 08:54:01 +0300
branch
4.x-dev
changeset 1675
4570148bf7c1
parent 1674
4c5951fbb123
child 1676
fb58d2230f7b

* Out of screen bug fixed

Source/Gorgon/CGI/Polygon.h file | annotate | diff | comparison | revisions
Testing/Source/Manual/CGI.cpp file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/CGI/Polygon.h	Sun May 16 08:31:54 2021 +0300
+++ b/Source/Gorgon/CGI/Polygon.h	Sun May 16 08:54:01 2021 +0300
@@ -93,7 +93,7 @@
                 if(x2 > line.MaxX())
                     x2 = line.MaxX();
                 
-                if(miny < ymax && maxy >= ymin) {
+                if(miny < ymax && maxy > ymin) {
                     if(strict)
                         edges.push_back(edge{miny, maxy, x1*scale, x2*scale, slopeinv, listind, (int8_t)line.YDirection()});
                     else
@@ -115,9 +115,20 @@
         
         std::vector<ScanLineDrawOrder> drawlist;
         
+        while(edgeit != edges.end() && edgeit->ymin < ymin) {
+            edge &e = *edgeit;
+            
+            e.x1 += (ymin - edgeit->ymin) * e.slopeinv;
+            e.x2 += (ymin - edgeit->ymin) * e.slopeinv;
+            
+            activelines.push_back({e.ymax - 1, e.x1, e.x2, e.slopeinv, e.index, e.dir});
+            
+            edgeit++;
+        }
+        
         for(int y = ymin; y<ymax; y++) {
             //find new active lines
-            while(edgeit != edges.end() && edgeit->ymin <= y) {
+            while(edgeit != edges.end() && edgeit->ymin == y) {
                 edge &e = *edgeit;
                 
                 activelines.push_back({e.ymax - 1, e.x1, e.x2, e.slopeinv, e.index, e.dir});
@@ -241,7 +252,7 @@
         
         if(ceil(ymin) > floor(ymax)) return;
         
-        if(S_ > 1) { //subpixel
+        if(S_ >= 1) { //subpixel
             int ew = xmax-xmin+1; //effective width
             std::vector<int> cnts(ew); //line buffer for counting
             int yminint = (int)floor(ymin*S_);
--- a/Testing/Source/Manual/CGI.cpp	Sun May 16 08:31:54 2021 +0300
+++ b/Testing/Source/Manual/CGI.cpp	Sun May 16 08:54:01 2021 +0300
@@ -49,7 +49,7 @@
     
     auto start = std::chrono::high_resolution_clock::now();
     
-    DrawLines(bmp, list, 10, SolidFill<>(Color::White));
+    DrawLines<1>(bmp, list, 10, SolidFill<>(Color::White));
     
     double t = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start).count() / 1000.0;
     std::cout << t << std::endl;

mercurial