]> git.mxchange.org Git - flightgear.git/blobdiff - Objects/fragment.cxx
Removed an extraneous output message.
[flightgear.git] / Objects / fragment.cxx
index 645a5c5eafea94eecbde2c08898a588bc12bdac1..2466dfd7690264775f6be7944f764b2f7174f2db 100644 (file)
@@ -23,8 +23,9 @@
 
 
 #include <Include/fg_constants.h>
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
 #include <Math/mat3.h>
+#include <Math/point3d.hxx>
 #include <Scenery/tile.hxx>
 
 #include "fragment.hxx"
@@ -68,8 +69,7 @@ fgFRAGMENT::fgFRAGMENT ( const fgFRAGMENT & rhs ) :
     material_ptr   ( rhs.material_ptr    ),
     tile_ptr       ( rhs.tile_ptr        ),
     display_list   ( rhs.display_list    ),
-    faces          ( rhs.faces           ),
-    num_faces      ( rhs.num_faces       )
+    faces          ( rhs.faces           )
 {
 }
 
@@ -93,13 +93,12 @@ fgFRAGMENT & fgFRAGMENT::operator = ( const fgFRAGMENT & rhs )
 // intersection found, 0 otherwise.  If it intesects, result is the
 // point of intersection
 
-int fgFRAGMENT::intersect( const fgPoint3d *end0,
-                          const fgPoint3d *end1,
+int fgFRAGMENT::intersect( const Point3D& end0,
+                          const Point3D& end1,
                           int side_flag,
-                          fgPoint3d *result) const
+                          Point3D& result) const
 {
     fgTILE *t;
-    fgFACE face;
     MAT3vec v1, v2, n, center;
     double p1[3], p2[3], p3[3];
     double x, y, z;  // temporary holding spot for result
@@ -116,22 +115,19 @@ int fgFRAGMENT::intersect( const fgPoint3d *end0,
     // printf("Intersecting\n");
 
     // traverse the face list for this fragment
-    const_iterator current = faces.begin();
     const_iterator last = faces.end();
-    while ( current != last ) {
-       face = *current;
-       current++;
-
+    for ( const_iterator current = faces.begin(); current != last; ++current )
+    {
        // printf(".");
 
        // get face vertex coordinates
-       center[0] = t->center.x;
-       center[1] = t->center.y;
-       center[2] = t->center.z;
+       center[0] = t->center.x();
+       center[1] = t->center.y();
+       center[2] = t->center.z();
 
-       MAT3_ADD_VEC(p1, t->nodes[face.n1], center);
-       MAT3_ADD_VEC(p2, t->nodes[face.n2], center);
-       MAT3_ADD_VEC(p3, t->nodes[face.n3], center);
+       MAT3_ADD_VEC(p1, t->nodes[(*current).n1], center);
+       MAT3_ADD_VEC(p2, t->nodes[(*current).n2], center);
+       MAT3_ADD_VEC(p3, t->nodes[(*current).n3], center);
 
        // printf("point 1 = %.2f %.2f %.2f\n", p1[0], p1[1], p1[2]);
        // printf("point 2 = %.2f %.2f %.2f\n", p2[0], p2[1], p2[2]);
@@ -157,9 +153,9 @@ int fgFRAGMENT::intersect( const fgPoint3d *end0,
        // printf("p3(d) = %.2f\n", a * p3[0] + b * p3[1] + c * p3[2]);
 
        // calculate the line coefficients for the specified line
-       x0 = end0->x;  x1 = end1->x;
-       y0 = end0->y;  y1 = end1->y;
-       z0 = end0->z;  z1 = end1->z;
+       x0 = end0.x();  x1 = end1.x();
+       y0 = end0.y();  y1 = end1.y();
+       z0 = end0.z();  z1 = end1.z();
 
        if ( fabs(x1 - x0) > FG_EPSILON ) {
            a1 = 1.0 / (x1 - x0);
@@ -206,9 +202,7 @@ int fgFRAGMENT::intersect( const fgPoint3d *end0,
                // everything is too close together to tell the difference
                // so the current intersection point should work as good
                // as any
-               result->x = x;
-               result->y = y;
-               result->z = z;
+               result = Point3D(x, y, z);
                return(1);
            }
            side1 = FG_SIGN (t1 - t2);
@@ -288,9 +282,7 @@ int fgFRAGMENT::intersect( const fgPoint3d *end0,
        } else {
            // all dimensions are really small so lets call it close
            // enough and return a successful match
-           result->x = x;
-           result->y = y;
-           result->z = z;
+           result = Point3D(x, y, z);
            return(1);
        }
 
@@ -322,9 +314,7 @@ int fgFRAGMENT::intersect( const fgPoint3d *end0,
        }
 
        // printf( "intersection point = %.2f %.2f %.2f\n", x, y, z);
-       result->x = x;
-       result->y = y;
-       result->z = z;
+       result = Point3D(x, y, z);
        return(1);
     }
 
@@ -334,6 +324,21 @@ int fgFRAGMENT::intersect( const fgPoint3d *end0,
 }
 
 // $Log$
+// Revision 1.6  1998/10/18 01:17:20  curt
+// Point3D tweaks.
+//
+// Revision 1.5  1998/10/16 00:54:37  curt
+// Converted to Point3D class.
+//
+// Revision 1.4  1998/09/15 01:35:03  curt
+// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
+// duplicating work.)
+// Tweaked fgTileMgrRender() do not calc tile matrix unless necessary.
+// removed some unneeded stuff from fgTileMgrCurElev()
+//
+// Revision 1.3  1998/09/08 21:40:42  curt
+// Updates from Bernie Bright.
+//
 // Revision 1.2  1998/09/01 19:03:07  curt
 // Changes contributed by Bernie Bright <bbright@c031.aone.net.au>
 //  - The new classes in libmisc.tgz define a stream interface into zlib.