+void FGTileMgr::reinit()
+{
+ _terra_sync = static_cast<simgear::SGTerraSync*> (globals->get_subsystem("terrasync"));
+ if (_terra_sync)
+ _terra_sync->setTileRefreshCb(&refresh_tile, this);
+
+ // protect against multiple scenery reloads and properly reset flags,
+ // otherwise aircraft fall through the ground while reloading scenery
+ if (!fgGetBool("/sim/sceneryloaded",true))
+ return;
+ fgSetBool("/sim/sceneryloaded",false);
+ fgSetDouble("/sim/startup/splash-alpha", 1.0);
+
+ // Reload the materials definitions
+ _options->setMaterialLib(globals->get_matlib());
+
+ // remove all old scenery nodes from scenegraph and clear cache
+ osg::Group* group = globals->get_scenery()->get_terrain_branch();
+ group->removeChildren(0, group->getNumChildren());
+ tile_cache.init();
+
+ // clear OSG cache, except on initial start-up
+ if (state != Start)
+ {
+ osgDB::Registry::instance()->clearObjectCache();
+ }
+