]> git.mxchange.org Git - flightgear.git/commitdiff
Fixed a bad bug which was showing itself with tiny triangles which caused
authorcurt <curt>
Thu, 20 May 1999 04:27:20 +0000 (04:27 +0000)
committercurt <curt>
Thu, 20 May 1999 04:27:20 +0000 (04:27 +0000)
the region point to be calculated outside the region which caused things to
be colored improperly.  Fixed by only evaluating the points of the current
contour (rather than the whole polygon) when generating the region points.

Tools/Construct/Triangulate/polygon.cxx

index 2cd824f663912e091e5a4cd810d0c5c47f52b9b6..a3eb0abdef0d963ce94c9c0d586ced08f10d6970 100644 (file)
@@ -150,26 +150,15 @@ void FGPolygon::calc_point_inside( const int contour,
 
     p3.sety(100);
     
-    for ( int i = 0; i < (int)poly.size(); ++i ) {
-       cout << "contour = " << i << " size = " << poly[i].size() << endl;
-       for ( int j = 0; j < (int)(poly[i].size() - 1); ++j ) {
-           // cout << "  p1 = " << poly[i][j] << " p2 = " 
-           //      << poly[i][j+1] << endl;
-           p1 = trinodes.get_node( poly[i][j] );
-           p2 = trinodes.get_node( poly[i][j+1] );
-
-           if ( intersects(p1, p2, m.x(), &result) ) {
-               // cout << "intersection = " << result << endl;
-               if ( ( result.y() < p3.y() ) &&
-                    ( result.y() > m.y() + FG_EPSILON ) ) {
-                   p3 = result;
-               }
-           }
-       }
-       // cout << "  p1 = " << poly[i][0] << " p2 = " 
-       //      << poly[i][poly[i].size() - 1] << endl;
-       p1 = trinodes.get_node( poly[i][0] );
-       p2 = trinodes.get_node( poly[i][poly[i].size() - 1] );
+    // for ( int i = 0; i < (int)poly.size(); ++i ) {
+    int i = contour;
+    cout << "contour = " << i << " size = " << poly[i].size() << endl;
+    for ( int j = 0; j < (int)(poly[i].size() - 1); ++j ) {
+       // cout << "  p1 = " << poly[i][j] << " p2 = " 
+       //      << poly[i][j+1] << endl;
+       p1 = trinodes.get_node( poly[i][j] );
+       p2 = trinodes.get_node( poly[i][j+1] );
+       
        if ( intersects(p1, p2, m.x(), &result) ) {
            // cout << "intersection = " << result << endl;
            if ( ( result.y() < p3.y() ) &&
@@ -178,6 +167,18 @@ void FGPolygon::calc_point_inside( const int contour,
            }
        }
     }
+    // cout << "  p1 = " << poly[i][0] << " p2 = " 
+    //      << poly[i][poly[i].size() - 1] << endl;
+    p1 = trinodes.get_node( poly[i][0] );
+    p2 = trinodes.get_node( poly[i][poly[i].size() - 1] );
+    if ( intersects(p1, p2, m.x(), &result) ) {
+       // cout << "intersection = " << result << endl;
+       if ( ( result.y() < p3.y() ) &&
+            ( result.y() > m.y() + FG_EPSILON ) ) {
+           p3 = result;
+       }
+    }
+    // }
     cout << "low intersection of other segment = " << p3 << endl;
 
     // 4. take midpoint of p2 && m as an arbitrary point inside polygon