]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/hitlist.hxx
Patch from Julian Foad:
[flightgear.git] / src / Scenery / hitlist.hxx
index 709b23a205fb106b12b8d05f12aa986781561647..df54ef26a6abbe4ff6c016a089537774893a09d9 100644 (file)
@@ -1,3 +1,7 @@
+// hitlist.hxx
+// Height Over Terrain and Assosciated Routines for FlightGear based Scenery
+// Written by Norman Vine, started 2000.
+
 #ifndef _HITLIST_HXX
 #define _HITLIST_HXX
 
@@ -13,7 +17,6 @@
 
 SG_USING_STD(vector);
 
-
 class FGHitRec {
 
 private:
@@ -25,10 +28,10 @@ private:
 public:
 
     FGHitRec( ssgEntity *e, int idx, sgdVec3 p, sgdVec3 n ) {
-       ent = e;
-       index = idx;
-       sgdSetVec3(point,p[0],p[1],p[2]);
-       sgdSetVec3(normal,n[0],n[1],n[2]);
+        ent = e;
+        index = idx;
+        sgdSetVec3(point,p[0],p[1],p[2]);
+        sgdSetVec3(normal,n[0],n[1],n[2]);
     }
 
     ssgEntity *get_entity(void) { return ent; }
@@ -44,15 +47,18 @@ private:
 
     ssgEntity *last;
     vector < FGHitRec > list;
+    double test_dist;
 
 public:
 
-    FGHitList() { last = NULL; }
-    void init(void) { list.clear(); }
+    FGHitList();
+    ~FGHitList();
+
+    void init(void) { list.clear(); test_dist=DBL_MAX; }
     void clear(void) { init(); last = NULL; }
     void add( ssgEntity *ent, int idx, sgdVec3 point, sgdVec3 normal ) {
-       list.push_back( FGHitRec( ent,idx,point,normal) );
-       last = ent;
+        list.push_back( FGHitRec( ent,idx,point,normal) );
+        last = ent;
     }
     int num_hits(void) { return list.size(); }
     ssgEntity *get_entity(int i)  { return list[i].get_entity(); }
@@ -60,46 +66,37 @@ public:
     int get_face(int i)           { return list[i].get_face(); }
     double *get_point(int i)      { return list[i].get_point(); }
     double *get_normal(int i)     { return list[i].get_normal(); }
-               
-    void Intersect( ssgBranch *branch,
-                   sgdVec3 orig, sgdVec3 dir );
-               
-    void IntersectBranch( ssgBranch *branch, sgdMat4 m,
-                         sgdVec3 orig, sgdVec3 dir);
-               
-    void IntersectCachedLeaf( sgdMat4 m,
-                             sgdVec3 orig, sgdVec3 dir);
-               
-    int IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
-                      sgdVec3 orig, sgdVec3 dir );
-};
 
+    void Intersect( ssgBranch *branch, sgdVec3 orig, sgdVec3 dir );
+    void Intersect( ssgBranch *scene, sgdMat4 m, sgdVec3 orig, sgdVec3 dir );
 
-inline void FGHitList::Intersect( ssgBranch *scene,
-                                 sgdVec3 orig, sgdVec3 dir )
-{
-    sgdMat4 m;
+    void IntersectBranch( ssgBranch *branch, sgdMat4 m, sgdVec3 orig, sgdVec3 dir);
 
-    init();
+    int IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
+                       sgdVec3 orig, sgdVec3 dir );
 
-    if( last_hit() ) {
-       sgdMakeIdentMat4 ( m ) ;
-       IntersectCachedLeaf(m, orig, dir);
-    }
-    if( ! num_hits() ) {
-       clear();
-       sgdMakeIdentMat4 ( m ) ;
-       IntersectBranch( scene, m, orig, dir);
-    }
-}
+    int IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
+                       sgdVec3 orig, sgdVec3 dir,
+                       GLenum primType );
+};
 
 
-// Associated function, assuming a wgs84 world with 0,0,0 at the
+// Associated functions, assuming a wgs84 world with 0,0,0 at the
 // center, find the current terrain intersection elevation for the
 // point specified.
-bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
-                   FGHitList *hit_list,
-                   double *terrain_elev, double *radius, double *normal );
-
+bool fgCurrentElev( sgdVec3 abs_view_pos,
+                    sgdVec3 scenery_center,
+                    ssgTransform *terra_transform,
+                    FGHitList *hit_list,
+                    double *terrain_elev,
+                    double *radius,
+                    double *normal );
+
+bool fgCurrentElev( sgdVec3 abs_view_pos,
+                    sgdVec3 scenery_center,
+                    FGHitList *hit_list,
+                    double *terrain_elev,
+                    double *radius,
+                    double *normal );
 
 #endif // _HITLIST_HXX