dynamically created at run time.
- Further clean ups to the FGTileMgr class interface.
fgReInitSubsystems();
- global_tile_mgr.update( fgGetDouble("/environment/visibility-m") );
+ globals->get_tile_mgr()->update( fgGetDouble("/environment/visibility-m") );
cur_light_params.Update();
globals->get_current_view()->setHeadingOffset_deg(0.0);
globals->get_viewmgr()->next_view();
fix_hud_visibility();
- global_tile_mgr.refresh_view_timestamps();
+ globals->get_tile_mgr()->refresh_view_timestamps();
}
void
globals->get_current_view()->setHeadingOffset_deg(0.0);
globals->get_viewmgr()->prev_view();
fix_hud_visibility();
- global_tile_mgr.refresh_view_timestamps();
+ globals->get_tile_mgr()->refresh_view_timestamps();
}
/**
globals->get_current_view()->setHeadingOffset_deg(0.0);
globals->get_viewmgr()->next_view();
fix_hud_visibility();
- global_tile_mgr.refresh_view_timestamps();
+ globals->get_tile_mgr()->refresh_view_timestamps();
// fgReshape(fgGetInt("/sim/startup/xsize"), fgGetInt("/sim/startup/ysize"));
return true;
}
fgSetBool("/sim/freeze/master", true);
}
// BusyCursor(0);
- if ( global_tile_mgr.init() ) {
+ if ( globals->get_tile_mgr()->init() ) {
// Load the local scenery data
double visibility_meters = fgGetDouble("/environment/visibility-m");
- global_tile_mgr.update( visibility_meters );
+ globals->get_tile_mgr()->update( visibility_meters );
} else {
SG_LOG( SG_GENERAL, SG_ALERT,
"Error in Tile Manager initialization!" );
// BusyCursor(0);
fgReInitSubsystems();
- global_tile_mgr.update( fgGetDouble("/environment/visibility-m") );
+ globals->get_tile_mgr()->update( fgGetDouble("/environment/visibility-m") );
if ( ! fgGetBool("/sim/presets/onground") ) {
fgSetBool( "/sim/freeze/master", true );
// Initialize the scenery management subsystem.
////////////////////////////////////////////////////////////////////
- if ( global_tile_mgr.init() ) {
+ if ( globals->get_tile_mgr()->init() ) {
// Load the local scenery data
double visibility_meters = fgGetDouble("/environment/visibility-m");
- global_tile_mgr.update( visibility_meters );
+ globals->get_tile_mgr()->update( visibility_meters );
} else {
SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
exit(-1);
// cause refresh of viewer scenery timestamps every 15 seconds...
global_events.Register( "FGTileMgr::refresh_view_timestamps()",
- &global_tile_mgr, &FGTileMgr::refresh_view_timestamps,
+ globals->get_tile_mgr(),
+ &FGTileMgr::refresh_view_timestamps,
15000 );
SG_LOG( SG_GENERAL, SG_DEBUG,
class SGEphemeris;
+class SGCommandMgr;
class SGMagVar;
+class SGPropertyNode;
class SGRoute;
class SGTime;
-class SGPropertyNode;
-class SGCommandMgr;
-class FGSubsystemMgr;
-class FGEnvironmentMgr;
-class FGEnvironment;
-class FGControls;
-class FGSteam;
-class FGSoundMgr;
-class FGAutopilot;
-class FGViewMgr;
-class FGViewer;
+class FGAIMgr;
class FGATCMgr;
class FGATCDisplay;
-class FGAIMgr;
-class FGModelLoader;
-class FGTextureLoader;
class FGAircraftModel;
+class FGAutopilot;
+class FGControls;
+class FGEnvironment;
+class FGEnvironmentMgr;
+class FGIO;
+class FGModelLoader;
class FGModelMgr;
class FGScenery;
-class FGIO;
+class FGSoundMgr;
+class FGSteam;
+class FGSubsystemMgr;
+class FGTextureLoader;
+class FGTileMgr;
+class FGViewMgr;
+class FGViewer;
+
/**
* Bucket for subsystem pointers representing the sim's state.
// FlightGear scenery manager
FGScenery *scenery;
+ // Tile manager
+ FGTileMgr *tile_mgr;
+
FGIO* io;
public:
inline FGScenery * get_scenery () const { return scenery; }
inline void set_scenery ( FGScenery *s ) { scenery = s; }
+ inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
+ inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
+
FGIO* get_io() const { return io; }
/**
#include <simgear/compiler.h>
#include <simgear/constants.h>
-#include <simgear/bucket/newbucket.hxx>
#include <simgear/math/point3d.hxx>
#include <plib/sg.h> // plib include
void set_cur_elev_m ( double elev ) { _cur_elev_m = elev; }
inline double get_cur_elev_m () { return _cur_elev_m; }
// Interface to current buckets for use with tilemgr...
- void set_current_bucket ( SGBucket current_bucket ) { _current_bucket = current_bucket; }
- inline SGBucket get_current_bucket () { return _current_bucket; }
- void set_previous_bucket ( SGBucket previous_bucket ) { _previous_bucket = previous_bucket; }
- inline SGBucket get_previous_bucket () { return _previous_bucket; }
void set_tile_center ( Point3D tile_center ) { _tile_center = tile_center; }
inline Point3D get_tile_center () { return _tile_center; }
// elevation of ground under this location...
double _cur_elev_m;
- // current and previous scenery buckets to be saved for use in
- // getting current elevation from tilemgr.
- SGBucket _previous_bucket;
- SGBucket _current_bucket;
Point3D _tile_center;
// surface vector heading south
}
# endif
- // position tile nodes and update range selectors
-
- // this is done in the main loop now...
- // global_tile_mgr.prep_ssg_nodes(visibility_meters);
-
if ( fgGetBool("/sim/rendering/skyblend") ) {
// draw the sky backdrop
// ...only if location is different than the viewer (to avoid duplicating effort)
if( acmodel_location != current_view->getFGLocation() ) {
if( acmodel_location != 0 ) {
- global_tile_mgr.prep_ssg_nodes( acmodel_location, visibility_meters );
- global_tile_mgr.update( acmodel_location, visibility_meters,
- acmodel_location->get_absolute_view_pos(),
- acmodel_location->get_current_bucket(),
- acmodel_location->get_previous_bucket(),
- globals->get_scenery()->get_center()
- );
+ globals->get_tile_mgr()->prep_ssg_nodes( acmodel_location,
+ visibility_meters );
+ globals->get_tile_mgr()->
+ update( acmodel_location, visibility_meters,
+ acmodel_location->get_absolute_view_pos() );
// save results of update in FGLocation for fdm...
if ( globals->get_scenery()->get_cur_elev() > -9990 ) {
- acmodel_location->set_cur_elev_m( globals->get_scenery()->get_cur_elev() );
+ acmodel_location->
+ set_cur_elev_m( globals->get_scenery()->get_cur_elev() );
}
- acmodel_location->set_current_bucket( global_tile_mgr.get_current_bucket() );
- acmodel_location->set_previous_bucket( global_tile_mgr.get_previous_bucket() );
- acmodel_location->set_tile_center( globals->get_scenery()->get_next_center() );
+ acmodel_location->
+ set_tile_center( globals->get_scenery()->get_next_center() );
}
}
- global_tile_mgr.prep_ssg_nodes( current_view->getFGLocation(),
- visibility_meters );
+ globals->get_tile_mgr()->prep_ssg_nodes( current_view->getFGLocation(),
+ visibility_meters );
// update tile manager for view...
// IMPORTANT!!! the tilemgr update for view location _must_ be done last
// after the FDM's until all of Flight Gear code references the viewer's location
// for elevation instead of the "scenery's" current elevation.
FGLocation *view_location = globals->get_current_view()->getFGLocation();
- global_tile_mgr.update( view_location, visibility_meters,
- current_view->get_absolute_view_pos(),
- current_view->getFGLocation()->get_current_bucket(),
- current_view->getFGLocation()->get_previous_bucket(),
- globals->get_scenery()->get_center()
- );
+ globals->get_tile_mgr()->update( view_location, visibility_meters,
+ current_view->get_absolute_view_pos() );
// save results of update in FGLocation for fdm...
if ( globals->get_scenery()->get_cur_elev() > -9990 ) {
current_view->getFGLocation()->set_cur_elev_m( globals->get_scenery()->get_cur_elev() );
}
- current_view->getFGLocation()->set_current_bucket( global_tile_mgr.get_current_bucket() );
- current_view->getFGLocation()->set_previous_bucket( global_tile_mgr.get_previous_bucket() );
current_view->getFGLocation()->set_tile_center( globals->get_scenery()->get_next_center() );
// If fdm location is same as viewer's then we didn't do the update for fdm location
if ( globals->get_scenery()->get_cur_elev() > -9990 ) {
acmodel_location->set_cur_elev_m( globals->get_scenery()->get_cur_elev() );
}
- acmodel_location->set_current_bucket( global_tile_mgr.get_current_bucket() );
- acmodel_location->set_previous_bucket( global_tile_mgr.get_previous_bucket() );
acmodel_location->set_tile_center( globals->get_scenery()->get_next_center() );
}
}
globals->get_scenery()->init();
globals->get_scenery()->bind();
+ // Initialize the global tile manager
+ globals->set_tile_mgr( new FGTileMgr );
+
////////////////////////////////////////////////////////////////////
// Initialize the property-based built-in commands
////////////////////////////////////////////////////////////////////
#define TEST_LAST_HIT_CACHE
-// the tile manager
-FGTileMgr global_tile_mgr;
-
-
#ifdef ENABLE_THREADS
SGLockedQueue<FGTileEntry *> FGTileMgr::attach_queue;
SGLockedQueue<FGDeferredModel *> FGTileMgr::model_queue;
sgdVec3 abs_pos_vector;
sgdCopyVec3( abs_pos_vector,
globals->get_current_view()->get_absolute_view_pos() );
- return update( location, visibility_meters, abs_pos_vector,
- current_bucket, previous_bucket,
- globals->get_scenery()->get_center() );
+ return update( location, visibility_meters, abs_pos_vector );
}
int FGTileMgr::update( FGLocation *location, double visibility_meters,
- sgdVec3 abs_pos_vector, SGBucket p_current,
- SGBucket p_previous, Point3D center )
+ sgdVec3 abs_pos_vector )
{
- // SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
- // << lon << " " << lat );
-
longitude = location->getLongitude_deg();
latitude = location->getLatitude_deg();
- current_bucket = p_current;
- previous_bucket = p_previous;
-
- // SG_LOG( SG_TERRAIN, SG_DEBUG, "lon "<< lonlat[LON] <<
- // " lat " << lonlat[LAT] );
+ // SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
+ // << longitude << " " << latatitude );
- // SG_LOG( SG_TERRAIN, SG_DEBUG, "Updating Tile list for " << current_bucket );
+ current_bucket.set_bucket( longitude, latitude );
+ // SG_LOG( SG_TERRAIN, SG_DEBUG, "Updating tile list for "
+ // << current_bucket );
- setCurrentTile( longitude, latitude);
+ // set global scenery center from current tile center
+ current_tile = tile_cache.get_tile( current_bucket );
+ if ( current_tile != NULL ) {
+ globals->get_scenery()->set_next_center( current_tile->center );
+ } else {
+ SG_LOG( SG_TERRAIN, SG_WARN, "Tile not found (Ok if initializing)" );
+ globals->get_scenery()->set_next_center( Point3D(0.0) );
+ }
// do tile load scheduling.
// Note that we need keep track of both viewer buckets and fdm buckets.
// no reason to update this if we haven't moved...
if ( longitude != last_longitude || latitude != last_latitude ) {
// update current elevation...
- if ( updateCurrentElevAtPos( abs_pos_vector, center ) ) {
+ if ( updateCurrentElevAtPos( abs_pos_vector,
+ globals->get_scenery()->get_center() ) )
+ {
last_longitude = longitude;
last_latitude = latitude;
}
return 1;
}
+
// timer event driven call to scheduler for the purpose of refreshing the tile timestamps
void FGTileMgr::refresh_view_timestamps() {
SG_LOG( SG_TERRAIN, SG_INFO,
}
-// check and set current tile and scenery center...
-void FGTileMgr::setCurrentTile(double longitude, double latitude) {
-
- // check tile cache entry...
- current_bucket.set_bucket( longitude, latitude );
- if ( tile_cache.exists( current_bucket ) ) {
- current_tile = tile_cache.get_tile( current_bucket );
- globals->get_scenery()->set_next_center( current_tile->center );
- } else {
- SG_LOG( SG_TERRAIN, SG_WARN, "Tile not found (Ok if initializing)" );
- globals->get_scenery()->set_next_center( Point3D(0.0) );
- }
-}
-
-
int FGTileMgr::updateCurrentElevAtPos(sgdVec3 abs_pos_vector, Point3D center) {
sgdVec3 sc;
// read it from disk.
int update( double visibility_meters );
int update( FGLocation *location, double visibility_meters,
- sgdVec3 abs_pos_vector, SGBucket p_current,
- SGBucket p_previous, Point3D center );
- void setCurrentTile( double longitude, double latitude );
+ sgdVec3 abs_pos_vector );
+
int updateCurrentElevAtPos(sgdVec3 abs_pos_vector, Point3D center );
// Determine scenery altitude. Normally this just happens when we
};
-// the tile manager
-extern FGTileMgr global_tile_mgr;
-
-
#endif // _TILEMGR_HXX