]> git.mxchange.org Git - flightgear.git/blobdiff - Objects/fragment.hxx
Portability changes for the Borland compiler.
[flightgear.git] / Objects / fragment.hxx
index 3c9e728e4a92c8597ab6be9b8995a241af862626..70f15ad8e28678cabfee164ceb183f0bc20ef1ff 100644 (file)
 #include <GL/glut.h>
 #include <XGL/xgl.h>
 
-#if defined ( __sun__ )
-extern "C" void *memmove(void *, const void *, size_t);
-extern "C" void *memset(void *, int, size_t);
-#endif
-
 #include <vector>
 
 #include <Bucket/bucketutils.h>
-#include <Include/fg_types.h>
+// #include <Include/fg_types.h>
 #include "Include/fg_constants.h"
 #include <Math/mat3.h>
+#include <Math/point3d.hxx>
 
-#ifdef NEEDNAMESPACESTD
-using namespace std;
-#endif
-
+#include <Include/compiler.h>
+//FG_USING_NAMESPACE(std);
+FG_USING_STD(vector);
 
 // Maximum nodes per tile
 #define MAX_NODES 2000
@@ -66,34 +61,29 @@ using namespace std;
 class fgTILE;
 class fgMATERIAL;
 
+// Object fragment data class
+class fgFRAGMENT {
 
-class fgFACE {
-public:
-    int n1, n2, n3;
+private:
+    struct fgFACE {
+       int n1, n2, n3;
 
-    explicit fgFACE( int a = 0, int b =0, int c =0 )
-       : n1(a), n2(b), n3(c) {}
+       fgFACE( int a = 0, int b =0, int c =0 )
+           : n1(a), n2(b), n3(c) {}
 
-    fgFACE( const fgFACE & image )
-       : n1(image.n1), n2(image.n2), n3(image.n3) {}
+       fgFACE( const fgFACE & image )
+           : n1(image.n1), n2(image.n2), n3(image.n3) {}
 
-    ~fgFACE() {}
+       fgFACE& operator= ( const fgFACE & image ) {
+           n1 = image.n1; n2 = image.n2; n3 = image.n3; return *this;
+       }
 
-    bool operator < ( const fgFACE & rhs ) { return n1 < rhs.n1; }
-};
-
-inline bool
-operator == ( const fgFACE& lhs, const fgFACE & rhs )
-{
-    return (lhs.n1 == rhs.n1) && (lhs.n2 == rhs.n2) && (lhs.n3 == rhs.n3);
-}
-
-// Object fragment data class
-class fgFRAGMENT {
+       ~fgFACE() {}
+    };
 
 public:
     // culling data for this object fragment (fine grain culling)
-    fgPoint3d center;
+    Point3D center;
     double bounding_radius;
 
     // variable offset data for this object fragment for this frame
@@ -122,13 +112,16 @@ public:
 
     container faces;
 
+public:
+
     // number of faces in this fragment
-    int num_faces;
+    int num_faces() {
+       return faces.size();
+    }
 
     // Add a face to the face list
     void add_face(int n1, int n2, int n3) {
        faces.push_back( fgFACE(n1,n2,n3) );
-       num_faces++;
     }
 
     // test if line intesects with this fragment.  p0 and p1 are the
@@ -136,13 +129,13 @@ public:
     // to see that end points are on opposite sides of face.  Returns
     // 1 if it intersection found, 0 otherwise.  If it intesects,
     // result is the point of intersection
-    int intersect( const fgPoint3d *end0,
-                  const fgPoint3d *end1,
+    int intersect( const Point3D& end0,
+                  const Point3D& end1,
                   int side_flag,
-                  fgPoint3d *result) const;
+                  Point3D& result) const;
 
     // Constructors
-    fgFRAGMENT () : num_faces(0) { /*faces.reserve(512);*/}
+    fgFRAGMENT () { /*faces.reserve(512);*/}
     fgFRAGMENT ( const fgFRAGMENT &image );
 
     // Destructor
@@ -151,26 +144,34 @@ public:
     // operators
     fgFRAGMENT & operator = ( const fgFRAGMENT & rhs );
 
-    bool operator <  ( const fgFRAGMENT & rhs ) {
+    bool operator <  ( const fgFRAGMENT & rhs ) const {
        // This is completely arbitrary. It satisfies RW's STL implementation
        return bounding_radius < rhs.bounding_radius;
     }
 
     void init() {
        faces.erase( faces.begin(), faces.end() );
-       num_faces = 0;
     }
 
-    int deleteDisplayList() {
+    int deleteDisplayList() const {
        xglDeleteLists( display_list, 1 ); return 0;
     }
+
+    friend bool operator== ( const fgFRAGMENT::fgFACE & lhs,
+                            const fgFRAGMENT::fgFACE & rhs );
+    friend bool operator== ( const fgFRAGMENT & lhs, const fgFRAGMENT & rhs );
 };
 
+inline bool
+operator== ( const fgFRAGMENT::fgFACE& lhs,
+            const fgFRAGMENT::fgFACE& rhs )
+{
+    return (lhs.n1 == rhs.n1) && (lhs.n2 == rhs.n2) && (lhs.n3 == rhs.n3);
+}
+
 inline bool
 operator == ( const fgFRAGMENT & lhs, const fgFRAGMENT & rhs ) {
-    return (( lhs.center.x - rhs.center.x ) < FG_EPSILON &&
-           ( lhs.center.y - rhs.center.y ) < FG_EPSILON &&
-           ( lhs.center.z - rhs.center.z ) < FG_EPSILON    );
+    return lhs.center == rhs.center;
 }
 
 
@@ -178,6 +179,45 @@ operator == ( const fgFRAGMENT & lhs, const fgFRAGMENT & rhs ) {
 
 
 // $Log$
+// Revision 1.7  1998/11/02 18:29:00  curt
+// Portability changes for the Borland compiler.
+//
+// Revision 1.6  1998/10/16 00:54:38  curt
+// Converted to Point3D class.
+//
+// Revision 1.5  1998/09/15 01:35:04  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.4  1998/09/10 19:07:09  curt
+// /Simulator/Objects/fragment.hxx
+//   Nested fgFACE inside fgFRAGMENT since its not used anywhere else.
+//
+// ./Simulator/Objects/material.cxx
+// ./Simulator/Objects/material.hxx
+//   Made fgMATERIAL and fgMATERIAL_MGR bona fide classes with private
+//   data members - that should keep the rabble happy :)
+//
+// ./Simulator/Scenery/tilemgr.cxx
+//   In viewable() delay evaluation of eye[0] and eye[1] in until they're
+//   actually needed.
+//   Change to fgTileMgrRender() to call fgMATERIAL_MGR::render_fragments()
+//   method.
+//
+// ./Include/fg_stl_config.h
+// ./Include/auto_ptr.hxx
+//   Added support for g++ 2.7.
+//   Further changes to other files are forthcoming.
+//
+// Brief summary of changes required for g++ 2.7.
+//   operator->() not supported by iterators: use (*i).x instead of i->x
+//   default template arguments not supported,
+//   <functional> doesn't have mem_fun_ref() needed by callbacks.
+//   some std include files have different names.
+//   template member functions not supported.
+//
 // Revision 1.3  1998/09/08 21:40:44  curt
 // Updates from Bernie Bright.
 //