// Initialize the Tile Manager subsystem
-void FGTileMgr::init() {
+void FGTileMgr::init()
+{
+ reinit();
+}
+
+void FGTileMgr::reinit()
+{
SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." );
+ _terra_sync = static_cast<simgear::SGTerraSync*> (globals->get_subsystem("terrasync"));
+ // drops the previous options reference
_options = new simgear::SGReaderWriterOptions;
_listener = new TileManagerListener(this);
materialLibChanged();
_options->setPropertyNode(globals->get_props());
-
+
osgDB::FilePathList &fp = _options->getDatabasePathList();
const string_list &sc = globals->get_fg_scenery();
fp.clear();
std::copy(sc.begin(), sc.end(), back_inserter(fp));
_options->setPluginStringData("SimGear::FG_ROOT", globals->get_fg_root());
- if (globals->get_subsystem("terrasync")) {
- _options->setPluginStringData("SimGear::TERRASYNC_ROOT", fgGetString("/sim/terrasync/scenery-dir"));
+ if (_terra_sync) {
+ _options->setPluginStringData("SimGear::TERRASYNC_ROOT", fgGetString("/sim/terrasync/scenery-dir"));
}
if (!_disableNasalHooks->getBoolValue())
- _options->setModelData(new FGNasalModelDataProxy);
-
- reinit();
-}
-
-void FGTileMgr::reinit()
-{
- _terra_sync = static_cast<simgear::SGTerraSync*> (globals->get_subsystem("terrasync"));
-
- // protect against multiple scenery reloads and properly reset flags,
- // otherwise aircraft fall through the ground while reloading scenery
- if (!fgGetBool("/sim/sceneryloaded",true))
+ _options->setModelData(new FGNasalModelDataProxy);
+
+
+ if (state != Start)
+ {
+ // protect against multiple scenery reloads and properly reset flags,
+ // otherwise aircraft fall through the ground while reloading scenery
+ if (_scenery_loaded->getBoolValue() == false) {
+ SG_LOG( SG_TERRAIN, SG_INFO, "/sim/sceneryloaded already false, avoiding duplicate re-init of tile manager" );
return;
- fgSetBool("/sim/sceneryloaded",false);
+ }
+ }
+
+ _scenery_loaded->setBoolValue(false);
fgSetDouble("/sim/startup/splash-alpha", 1.0);
materialLibChanged();
{
// create a new entry
t = new TileEntry( b );
+ SG_LOG( SG_TERRAIN, SG_INFO, "sched_tile: new tile entry for:" << b );
+
+
// insert the tile into the cache, update will generate load request
if ( tile_cache.insert_tile( t ) )
{
SGBucket bucket(position);
available = sched_tile( bucket, priority, false, duration );
- if ((!available)&&(duration==0.0))
+ if ((!available)&&(duration==0.0)) {
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "schedule_scenery: Scheduling tile at bucket:" << bucket << " return false" );
return false;
+ }
SGVec3d cartPos = SGVec3d::fromGeod(position);