2 // Height Over Terrain and Assosciated Routines for FlightGear based Scenery
3 // Written by Norman Vine, started 2000.
9 # error This library requires C++
12 #include <simgear/compiler.h>
18 #define FAST_HITLIST__TEST 1
32 FGHitRec( ssgEntity *e, int idx, sgdVec3 p, sgdVec3 n ) {
35 sgdSetVec3(point,p[0],p[1],p[2]);
36 sgdSetVec3(normal,n[0],n[1],n[2]);
39 ssgEntity *get_entity(void) { return ent; }
40 int get_face(void) { return index; }
41 double *get_point(void) { return point; }
42 double *get_normal(void) { return normal; }
51 vector < FGHitRec > list;
56 FGHitList() { last = NULL; test_dist=DBL_MAX; }
57 void init(void) { list.clear(); test_dist=DBL_MAX; }
58 void clear(void) { init(); last = NULL; }
59 void add( ssgEntity *ent, int idx, sgdVec3 point, sgdVec3 normal ) {
60 list.push_back( FGHitRec( ent,idx,point,normal) );
63 int num_hits(void) { return list.size(); }
64 ssgEntity *get_entity(int i) { return list[i].get_entity(); }
65 ssgEntity *last_hit(void) { return last; }
66 int get_face(int i) { return list[i].get_face(); }
67 double *get_point(int i) { return list[i].get_point(); }
68 double *get_normal(int i) { return list[i].get_normal(); }
70 void Intersect( ssgBranch *branch,
71 sgdVec3 orig, sgdVec3 dir );
72 void Intersect( ssgBranch *scene, sgdMat4 m,
73 sgdVec3 orig, sgdVec3 dir );
75 void IntersectBranch( ssgBranch *branch, sgdMat4 m,
76 sgdVec3 orig, sgdVec3 dir);
78 void IntersectCachedLeaf( sgdVec3 orig, sgdVec3 dir);
80 int IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
81 sgdVec3 orig, sgdVec3 dir );
83 int IntersectPolyOrFanLeaf( ssgLeaf *leaf, sgdMat4 m,
84 sgdVec3 orig, sgdVec3 dir );
86 int IntersectTriLeaf( ssgLeaf *leaf, sgdMat4 m,
87 sgdVec3 orig, sgdVec3 dir );
89 int IntersectStripLeaf( ssgLeaf *leaf, sgdMat4 m,
90 sgdVec3 orig, sgdVec3 dir );
92 int IntersectQuadsLeaf( ssgLeaf *leaf, sgdMat4 m,
93 sgdVec3 orig, sgdVec3 dir );
97 // Associated function, assuming a wgs84 world with 0,0,0 at the
98 // center, find the current terrain intersection elevation for the
100 bool fgCurrentElev( sgdVec3 abs_view_pos,
101 sgdVec3 scenery_center,
102 ssgTransform *terra_transform,
104 double *terrain_elev,
108 bool fgCurrentElev( sgdVec3 abs_view_pos,
109 sgdVec3 scenery_center,
111 double *terrain_elev,
115 #endif // _HITLIST_HXX