From 1a9e479e2afa215fef7370dd2651f0be6cbf133f Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 28 Sep 2013 14:07:45 +0100 Subject: [PATCH] Terrasync tweaks. - Enable the terrasync persistent cache - Ensure terraysync scenery dirs exist before NavCache init, so the paths are stable - Notify TerraSync on reposition, so we sync the full 3x3 set of tiles. --- src/Main/fg_init.cxx | 7 +++++++ src/Main/main.cxx | 16 ++++++++++++++-- src/Main/options.cxx | 16 ++++++++++++---- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 76e14cd67..82bf86f95 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -53,6 +53,7 @@ #include #include +#include #include #include @@ -853,6 +854,12 @@ void fgReInitSubsystems() // main-loop flightgear::initPosition(); + simgear::SGTerraSync* terraSync = + static_cast(globals->get_subsystem("terrasync")); + if (terraSync) { + terraSync->reposition(); + } + // Force reupdating the positions of the ai 3d models. They are used for // initializing ground level for the FDM. globals->get_subsystem("ai-model")->reinit(); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 77893a013..175058073 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -130,6 +130,19 @@ static void fgIdleFunction ( void ) { } } else if ( idle_state == 2 ) { + + // start TerraSync up now, so it can be synchronizing shared models + // and airports data in parallel with a nav-cahce rebuild. + SGPath tsyncCache(globals->get_fg_home()); + tsyncCache.append("terrasync-cache.xml"); + fgSetString("/sim/terrasync/cache-path", tsyncCache.c_str()); + + simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(globals->get_props()); + globals->add_subsystem("terrasync", terra_sync); + + terra_sync->bind(); + terra_sync->init(); + idle_state++; fgSplashProgress("loading-nav-dat"); @@ -178,8 +191,7 @@ static void fgIdleFunction ( void ) { //////////////////////////////////////////////////////////////////// // Initialize the TG scenery subsystem. //////////////////////////////////////////////////////////////////// - simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(globals->get_props()); - globals->add_subsystem("terrasync", terra_sync); + globals->set_scenery( new FGScenery ); globals->get_scenery()->init(); globals->get_scenery()->bind(); diff --git a/src/Main/options.cxx b/src/Main/options.cxx index ac5942162..b5230d4e7 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2058,11 +2058,19 @@ void Options::processOptions() } SGPath p(terrasyncDir); - if (!p.exists()) { - simgear::Dir dd(p); - dd.create(0700); + // following is necessary to ensure NavDataCache sees stable scenery paths from + // terrasync. Ensure the Terrain and Objects subdirs exist immediately, rather + // than waiting for the first tiles to be scheduled. + simgear::Dir terrainDir(SGPath(p, "Terrain")), + objectsDir(SGPath(p, "Objects")); + if (!terrainDir.exists()) { + terrainDir.create(0755); } - + + if (!objectsDir.exists()) { + objectsDir.create(0755); + } + const string_list& scenery_paths(globals->get_fg_scenery()); if (std::find(scenery_paths.begin(), scenery_paths.end(), terrasyncDir) == scenery_paths.end()) { // terrasync dir is not in the scenery paths, add it