1
0
Fork 0

Ssg tweaks.

Better handling of missing tiles.
Added a range selector so we can completely ignore tiles that are beyond
  our visibility range.
Added a routine to prep the ssg nodes before rendering by updating the
  transform and range selector values.
This commit is contained in:
curt 1999-06-30 00:28:20 +00:00
parent 5329ce82c5
commit 39b3602dce
5 changed files with 78 additions and 19 deletions

View file

@ -137,10 +137,13 @@ FGTileCache::fill_in( int index, const FGBucket& p )
tile_cache[index].mark_loaded(); tile_cache[index].mark_loaded();
tile_cache[index].tile_bucket = p; tile_cache[index].tile_bucket = p;
ssgBranch *new_tile = fgObjLoad( tile_path.str(), &tile_cache[index] );
tile_cache[index].branch_ptr = new ssgTransform; tile_cache[index].branch_ptr = new ssgTransform;
tile_cache[index].branch_ptr->addKid( new_tile ); tile_cache[index].range_ptr = new ssgRangeSelector;
// tile_cache[index].branch_ptr->addKid( penguin ); ssgBranch *new_tile = fgObjLoad( tile_path.str(), &tile_cache[index] );
if ( new_tile != NULL ) {
tile_cache[index].range_ptr->addKid( new_tile );
}
tile_cache[index].branch_ptr->addKid( tile_cache[index].range_ptr );
terrain->addKid( tile_cache[index].branch_ptr ); terrain->addKid( tile_cache[index].branch_ptr );
// cout << " ncount before = " << tile_cache[index].ncount << "\n"; // cout << " ncount before = " << tile_cache[index].ncount << "\n";

View file

@ -42,7 +42,10 @@ FG_USING_STD(mem_fun_ref);
// Constructor // Constructor
FGTileEntry::FGTileEntry ( void ) FGTileEntry::FGTileEntry ( void )
: ncount(0), : ncount(0),
state(Unused) state(Unused),
vtlist(NULL),
vnlist(NULL),
tclist(NULL)
{ {
nodes.clear(); nodes.clear();
} }
@ -73,9 +76,15 @@ FGTileEntry::free_tile()
fragment_list.erase( begin(), end() ); fragment_list.erase( begin(), end() );
// delete the ssg used structures // delete the ssg used structures
delete vtlist; if ( vtlist != NULL ) {
delete vnlist; delete vtlist;
delete tclist; }
if ( vnlist != NULL ) {
delete vnlist;
}
if ( tclist != NULL ) {
delete tclist;
}
// delete the ssg branch // delete the ssg branch
@ -105,7 +114,7 @@ FGTileEntry::free_tile()
FG_LOG( FG_TERRAIN, FG_ALERT, FG_LOG( FG_TERRAIN, FG_ALERT,
"Parent count is zero for an ssg tile! Dying" ); "Parent count is zero for an ssg tile! Dying" );
exit(-1); exit(-1);
} }
} }

View file

@ -109,7 +109,21 @@ public:
sgVec3 *vnlist; sgVec3 *vnlist;
sgVec2 *tclist; sgVec2 *tclist;
// pointer to ssg branch; // ssg tree structure for this tile is as follows:
// ssgRoot(scene)
// - ssgBranch(terrain)
// - ssgTransform(tile)
// - ssgRangeSelector(tile)
// - ssgEntity(tile)
// - kid1(fan)
// - kid2(fan)
// ...
// - kidn(fan)
// pointer to ssg range selector for this tile
ssgRangeSelector *range_ptr;
// pointer to ssg transform for this tile
ssgTransform *branch_ptr; ssgTransform *branch_ptr;
public: public:

View file

@ -734,6 +734,42 @@ update_tile_geometry( FGTileEntry *t, GLdouble *MODEL_VIEW)
} }
// Prepare the ssg nodes ... for each tile, set it's proper
// transform and update it's range selector based on current
// visibilty
void FGTileMgr::prep_ssg_nodes( void ) {
FGTileEntry *t;
int tile_diameter = current_options.get_tile_diameter();
float ranges[2];
ranges[0] = 0.0f;
ranges[1] = current_weather.get_visibility();
// traverse the potentially viewable tile list and update range
// selector and transform
for ( int i = 0; i < (tile_diameter * tile_diameter); i++ ) {
int index = tiles[i];
t = global_tile_cache.get_tile(index);
if ( t->is_loaded() ) {
// set range selector (LOD trick)
t->range_ptr->setRanges( ranges, 2 );
// calculate tile offset
t->SetOffset( scenery.center );
// calculate ssg transform
sgCoord sgcoord;
sgSetCoord( &sgcoord,
t->offset.x(), t->offset.y(), t->offset.z(),
0.0, 0.0, 0.0 );
t->branch_ptr->setTransform( &sgcoord );
}
}
}
// Render the local tiles // Render the local tiles
void FGTileMgr::render( void ) { void FGTileMgr::render( void ) {
FGInterface *f; FGInterface *f;
@ -744,7 +780,6 @@ void FGTileMgr::render( void ) {
fgFRAGMENT *frag_ptr; fgFRAGMENT *frag_ptr;
FGMaterialSlot *mtl_ptr; FGMaterialSlot *mtl_ptr;
int i; int i;
int tile_diameter;
int index; int index;
int culled = 0; int culled = 0;
int drawn = 0; int drawn = 0;
@ -753,7 +788,7 @@ void FGTileMgr::render( void ) {
f = current_aircraft.fdm_state; f = current_aircraft.fdm_state;
v = &current_view; v = &current_view;
tile_diameter = current_options.get_tile_diameter(); int tile_diameter = current_options.get_tile_diameter();
// moved to fgTileMgrUpdate, right after we check if we need to // moved to fgTileMgrUpdate, right after we check if we need to
// load additional tiles: // load additional tiles:
@ -775,13 +810,6 @@ void FGTileMgr::render( void ) {
// calculate tile offset // calculate tile offset
t->SetOffset( scenery.center ); t->SetOffset( scenery.center );
// calculate ssg transform
sgCoord sgcoord;
sgSetCoord( &sgcoord,
t->offset.x(), t->offset.y(), t->offset.z(),
0.0, 0.0, 0.0 );
t->branch_ptr->setTransform( &sgcoord );
// Course (tile based) culling // Course (tile based) culling
if ( viewable(t->offset, t->bounding_radius) ) { if ( viewable(t->offset, t->bounding_radius) ) {
// at least a portion of this tile could be viewable // at least a portion of this tile could be viewable
@ -854,6 +882,6 @@ void FGTileMgr::render( void ) {
// traverse the transient per-material fragment lists and render // traverse the transient per-material fragment lists and render
// out all fragments for each material property. // out all fragments for each material property.
xglPushMatrix(); xglPushMatrix();
// material_mgr.render_fragments(); material_mgr.render_fragments();
xglPopMatrix(); xglPopMatrix();
} }

View file

@ -108,6 +108,11 @@ public:
double current_elev_new( const FGBucket& p ); double current_elev_new( const FGBucket& p );
double current_elev( double lon, double lat, const Point3D& abs_view_pos ); double current_elev( double lon, double lat, const Point3D& abs_view_pos );
// Prepare the ssg nodes ... for each tile, set it's proper
// transform and update it's range selector based on current
// visibilty
void prep_ssg_nodes( void );
// Render the local tiles --- hack, hack, hack // Render the local tiles --- hack, hack, hack
void render( void ); void render( void );
}; };