1
0
Fork 0

Here is a cleaned up hitlist that should solve the PLib conflict

and fixes a 'potential bug' if the FGFS View code were to change

I also consolidated the specialized IntersectLeaf()
as they really didn't gain us much outside of their having
'more direct access into the SSG controlled data'

I would like to see the fgCurrentElevation functions moved
out of hitlist.cxx.

The one obstacle is their being dependent on my PLib
auxillary functions

ssgGetEntityTransform()
ssgGetCurrentBSphere()

code has been run through astyle with the default options
This commit is contained in:
curt 2002-03-18 16:25:16 +00:00
parent 8138c82b58
commit 464f036f35
2 changed files with 413 additions and 674 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
// hitlist.hxx // hitlist.hxx
// Height Over Terrain and Assosciated Routines for FlightGear based Scenery // Height Over Terrain and Assosciated Routines for FlightGear based Scenery
// Written by Norman Vine, started 2000. // Written by Norman Vine, started 2000.
@ -15,8 +15,6 @@
#include <plib/ssg.h> #include <plib/ssg.h>
#define FAST_HITLIST__TEST 1
SG_USING_STD(vector); SG_USING_STD(vector);
class FGHitRec { class FGHitRec {
@ -30,10 +28,10 @@ private:
public: public:
FGHitRec( ssgEntity *e, int idx, sgdVec3 p, sgdVec3 n ) { FGHitRec( ssgEntity *e, int idx, sgdVec3 p, sgdVec3 n ) {
ent = e; ent = e;
index = idx; index = idx;
sgdSetVec3(point,p[0],p[1],p[2]); sgdSetVec3(point,p[0],p[1],p[2]);
sgdSetVec3(normal,n[0],n[1],n[2]); sgdSetVec3(normal,n[0],n[1],n[2]);
} }
ssgEntity *get_entity(void) { return ent; } ssgEntity *get_entity(void) { return ent; }
@ -53,12 +51,14 @@ private:
public: public:
FGHitList() { last = NULL; test_dist=DBL_MAX; } FGHitList();
~FGHitList();
void init(void) { list.clear(); test_dist=DBL_MAX; } void init(void) { list.clear(); test_dist=DBL_MAX; }
void clear(void) { init(); last = NULL; } void clear(void) { init(); last = NULL; }
void add( ssgEntity *ent, int idx, sgdVec3 point, sgdVec3 normal ) { void add( ssgEntity *ent, int idx, sgdVec3 point, sgdVec3 normal ) {
list.push_back( FGHitRec( ent,idx,point,normal) ); list.push_back( FGHitRec( ent,idx,point,normal) );
last = ent; last = ent;
} }
int num_hits(void) { return list.size(); } int num_hits(void) { return list.size(); }
ssgEntity *get_entity(int i) { return list[i].get_entity(); } ssgEntity *get_entity(int i) { return list[i].get_entity(); }
@ -66,50 +66,37 @@ public:
int get_face(int i) { return list[i].get_face(); } int get_face(int i) { return list[i].get_face(); }
double *get_point(int i) { return list[i].get_point(); } double *get_point(int i) { return list[i].get_point(); }
double *get_normal(int i) { return list[i].get_normal(); } double *get_normal(int i) { return list[i].get_normal(); }
void Intersect( ssgBranch *branch, void Intersect( ssgBranch *branch, sgdVec3 orig, sgdVec3 dir );
sgdVec3 orig, sgdVec3 dir ); void Intersect( ssgBranch *scene, sgdMat4 m, sgdVec3 orig, sgdVec3 dir );
void Intersect( ssgBranch *scene, sgdMat4 m,
sgdVec3 orig, sgdVec3 dir ); void IntersectBranch( ssgBranch *branch, sgdMat4 m, sgdVec3 orig, sgdVec3 dir);
void IntersectBranch( ssgBranch *branch, sgdMat4 m,
sgdVec3 orig, sgdVec3 dir);
void IntersectCachedLeaf( sgdVec3 orig, sgdVec3 dir);
int IntersectLeaf( ssgLeaf *leaf, sgdMat4 m, int IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
sgdVec3 orig, sgdVec3 dir ); sgdVec3 orig, sgdVec3 dir );
int IntersectPolyOrFanLeaf( ssgLeaf *leaf, sgdMat4 m, int IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
sgdVec3 orig, sgdVec3 dir ); sgdVec3 orig, sgdVec3 dir,
GLenum primType );
int IntersectTriLeaf( ssgLeaf *leaf, sgdMat4 m,
sgdVec3 orig, sgdVec3 dir );
int IntersectStripLeaf( ssgLeaf *leaf, sgdMat4 m,
sgdVec3 orig, sgdVec3 dir );
int IntersectQuadsLeaf( ssgLeaf *leaf, sgdMat4 m,
sgdVec3 orig, sgdVec3 dir );
}; };
// 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 // center, find the current terrain intersection elevation for the
// point specified. // point specified.
bool fgCurrentElev( sgdVec3 abs_view_pos, bool fgCurrentElev( sgdVec3 abs_view_pos,
sgdVec3 scenery_center, sgdVec3 scenery_center,
ssgTransform *terra_transform, ssgTransform *terra_transform,
FGHitList *hit_list, FGHitList *hit_list,
double *terrain_elev, double *terrain_elev,
double *radius, double *radius,
double *normal ); double *normal );
bool fgCurrentElev( sgdVec3 abs_view_pos, bool fgCurrentElev( sgdVec3 abs_view_pos,
sgdVec3 scenery_center, sgdVec3 scenery_center,
FGHitList *hit_list, FGHitList *hit_list,
double *terrain_elev, double *terrain_elev,
double *radius, double *radius,
double *normal ); double *normal );
#endif // _HITLIST_HXX #endif // _HITLIST_HXX