1
0
Fork 0

Updates, optimizations, and restructures from Norman Vine.

This commit is contained in:
curt 2000-06-15 22:32:26 +00:00
parent 0f4ff744c6
commit cd1a471f7e
7 changed files with 357 additions and 912 deletions

View file

@ -1,6 +1,7 @@
noinst_LIBRARIES = libScenery.a
libScenery_a_SOURCES = \
hitlist.cxx hitlist.hxx \
scenery.cxx scenery.hxx \
tilecache.cxx tilecache.hxx \
tileentry.cxx tileentry.hxx \

View file

@ -30,6 +30,7 @@
#endif
#include <plib/sg.h>
#include <simgear/math/point3d.hxx>
@ -51,6 +52,9 @@ struct fgSCENERY {
// the distance (radius) from the center of the earth to the
// current scenery elevation point
double cur_radius;
// unit normal at point used to determine current elevation
sgdVec3 cur_normal;
};
extern struct fgSCENERY scenery;

View file

@ -95,5 +95,3 @@ extern FGTileCache global_tile_cache;
#endif // _TILECACHE_HXX

View file

@ -45,6 +45,7 @@ FGTileEntry::FGTileEntry ( void )
state(Unused)
{
nodes.clear();
select_ptr = NULL;
}
@ -129,6 +130,7 @@ void FGTileEntry::free_tile() {
if( parent ) {
// my_remove_branch( select_ptr );
parent->removeKid( select_ptr );
select_ptr = NULL;
} else {
FG_LOG( FG_TERRAIN, FG_ALERT,
"parent pointer is NULL! Dying" );

View file

@ -99,9 +99,6 @@ public:
double bounding_radius;
Point3D offset;
// model view matrix for this tile
GLfloat model_view[16];
// this tile's official location in the world
FGBucket tile_bucket;
@ -178,32 +175,7 @@ public:
// Return this tile's offset
inline Point3D get_offset( void ) const { return offset; }
// Calculate the model_view transformation matrix for this tile
inline void update_view_matrix(GLfloat *MODEL_VIEW)
{
#if defined( USE_MEM ) || defined( WIN32 )
memcpy( model_view, MODEL_VIEW, 16*sizeof(GLfloat) );
#else
bcopy( MODEL_VIEW, model_view, 16*sizeof(GLfloat) );
#endif
// This is equivalent to doing a glTranslatef(x, y, z);
model_view[12] += (model_view[0]*offset.x() +
model_view[4]*offset.y() +
model_view[8]*offset.z());
model_view[13] += (model_view[1]*offset.x() +
model_view[5]*offset.y() +
model_view[9]*offset.z());
model_view[14] += (model_view[2]*offset.x() +
model_view[6]*offset.y() +
model_view[10]*offset.z() );
// m[15] += (m[3]*x + m[7]*y + m[11]*z);
// m[3] m7[] m[11] are 0.0 see LookAt() in views.cxx
// so m[15] is unchanged
}
inline bool is_unused() const { return state == Unused; }
inline bool is_scheduled_for_use() const {
return state == Scheduled_for_use;

File diff suppressed because it is too large Load diff

View file

@ -37,6 +37,7 @@
#include <simgear/bucket/newbucket.hxx>
#include "hitlist.hxx"
FG_USING_STD(list);
@ -52,6 +53,10 @@ FG_USING_STD(list);
#endif
// forward declaration
class FGTileEntry;
class FGLoadRec {
public:
@ -61,9 +66,6 @@ public:
};
#define MAX_HITS 100
class FGTileMgr {
private:
@ -77,17 +79,58 @@ private:
load_state state;
enum SCROLL_DIRECTION {
SCROLL_INIT = -1,
SCROLL_NONE = 0,
SCROLL_NORTH,
SCROLL_EAST,
SCROLL_SOUTH,
SCROLL_WEST,
};
SCROLL_DIRECTION scroll_direction;
// pending tile load queue
list < FGLoadRec > load_queue;
// initialize the cache
void initialize_queue( void );
FGBucket BucketOffset( int dx, int dy );
// schedule a tile for loading
int sched_tile( const FGBucket& b );
// load a tile
void load_tile( const FGBucket& b, int cache_index );
int hitcount;
sgdVec3 hit_pts [ MAX_HITS ] ;
// schedule a tile row(column) for loading
void scroll( void );
// see comment at prep_ssg_nodes()
void prep_ssg_node( int idx );
// int hitcount;
// sgdVec3 hit_pts [ MAX_HITS ] ;
// ssgEntity *last_hit;
FGHitList hit_list;
FGBucket previous_bucket;
FGBucket current_bucket;
FGBucket pending;
FGTileEntry *current_tile;
// index of current tile in tile cache;
long int tile_index;
int tile_diameter;
// current longitude latitude
double longitude;
double latitude;
double last_longitude;
double last_latitude;
public:
@ -109,13 +152,16 @@ public:
// render the scene, but we'd also like to be able to do this
// explicitely. lat & lon are in radians. abs_view_pos in
// meters. Returns result in meters.
double current_elev( double lon, double lat, const Point3D& abs_view_pos );
void my_ssg_los( string s, ssgBranch *branch, sgdMat4 m,
const sgdVec3 p, const sgdVec3 dir );
bool current_elev_ssg( const Point3D& abs_view_pos,
const Point3D& view_pos );
double current_elev_new( const FGBucket& p );
const sgdVec3 p, const sgdVec3 dir, sgdVec3 normal );
void my_ssg_los( ssgBranch *branch, sgdMat4 m,
const sgdVec3 p, const sgdVec3 dir,
FGHitList *list );
bool current_elev_ssg( const Point3D& abs_view_pos,
const Point3D& view_pos );
// Prepare the ssg nodes ... for each tile, set it's proper
// transform and update it's range selector based on current
// visibilty
@ -128,5 +174,3 @@ extern FGTileMgr global_tile_mgr;
#endif // _TILEMGR_HXX