]> git.mxchange.org Git - flightgear.git/commitdiff
Terrasync tweaks.
authorJames Turner <zakalawe@mac.com>
Sat, 28 Sep 2013 13:07:45 +0000 (14:07 +0100)
committerJames Turner <zakalawe@mac.com>
Sat, 28 Sep 2013 13:07:45 +0000 (14:07 +0100)
- 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
src/Main/main.cxx
src/Main/options.cxx

index 76e14cd67ba15bc0c46c87e2b688005b8804c429..82bf86f95cc69757fb3d6722c9d5af12045e6aee 100644 (file)
@@ -53,6 +53,7 @@
 
 #include <simgear/scene/material/matlib.hxx>
 #include <simgear/scene/model/particles.hxx>
+#include <simgear/scene/tsync/terrasync.hxx>
 
 #include <Aircraft/controls.hxx>
 #include <Aircraft/replay.hxx>
@@ -853,6 +854,12 @@ void fgReInitSubsystems()
     // main-loop
     flightgear::initPosition();
     
+    simgear::SGTerraSync* terraSync =
+        static_cast<simgear::SGTerraSync*>(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();
index 77893a0131806af629bd3ced69c862959917be5c..175058073e191e5519f74c52a6b3f9d91d3c9293 100644 (file)
@@ -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();
index ac594216259f656f13982b96d43af6228c9d2fe6..b5230d4e75b969d3beaa2b6fb2cbb76945953d72 100644 (file)
@@ -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