]> git.mxchange.org Git - flightgear.git/commitdiff
Minor tile manager clean-up.
authorThorstenB <brehmt@gmail.com>
Mon, 24 Sep 2012 21:42:25 +0000 (23:42 +0200)
committerThorstenB <brehmt@gmail.com>
Mon, 24 Sep 2012 21:42:25 +0000 (23:42 +0200)
The tilemgr schedules scenery, so it should also trigger the
"sceneryloaded" signals once it's done.

src/Main/main.cxx
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx

index 4dc123c27951416415c6f818b47e3c19419dbb37..5fd2137f8bc2c8262887a1420d0afdbb9bf532f5 100644 (file)
@@ -80,31 +80,6 @@ using std::vector;
 // is initialized.
 extern int _bootstrap_OSInit;
 
-
-static void fgLoadInitialScenery()
-{
-    static SGPropertyNode_ptr scenery_loaded
-        = fgGetNode("sim/sceneryloaded", true);
-    static SGPropertyNode_ptr scenery_override
-        = fgGetNode("/sim/sceneryloaded-override", true);
-
-    if (!scenery_loaded->getBoolValue())
-    {
-        if (scenery_override->getBoolValue() ||
-            (globals->get_tile_mgr()->isSceneryLoaded()
-             && fgGetBool("sim/fdm-initialized"))) {
-            fgSetBool("sim/sceneryloaded",true);
-            fgSplashProgress("");
-        }
-        else
-        {
-            fgSplashProgress("loading-scenery");
-            // be nice to loader threads while waiting for initial scenery, reduce to 20fps
-            SGTimeStamp::sleepForMSec(50);
-        }
-    }
-}
-
 // What should we do when we have nothing else to do?  Let's get ready
 // for the next move and update the display?
 static void fgMainLoop( void )
@@ -126,9 +101,6 @@ static void fgMainLoop( void )
     // update all subsystems
     globals->get_subsystem_mgr()->update(sim_dt);
 
-    // END Tile Manager updates
-    fgLoadInitialScenery();
-
     simgear::AtomicChangeListener::fireChangeListeners();
 
     SG_LOG( SG_GENERAL, SG_DEBUG, "" );
index e05133a3eb59b59678dc0f59825bb27c87164606..51f24044bc831a27044a3a03fdebe1739db00728 100644 (file)
@@ -42,6 +42,7 @@
 #include <Main/fg_props.hxx>
 #include <Viewer/renderer.hxx>
 #include <Viewer/viewer.hxx>
+#include <Viewer/splash.hxx>
 #include <Scripting/NasalSys.hxx>
 
 #include "scenery.hxx"
@@ -61,6 +62,8 @@ FGTileMgr::FGTileMgr():
     _visibilityMeters(fgGetNode("/environment/visibility-m", true)),
     _maxTileRangeM(fgGetNode("/sim/rendering/static-lod/bare", true)),
     _disableNasalHooks(fgGetNode("/sim/temp/disable-scenery-nasal", true)),
+    _scenery_loaded(fgGetNode("/sim/sceneryloaded", true)),
+    _scenery_override(fgGetNode("/sim/sceneryloaded-override", true)),
     _pager(FGScenery::getPagerSingleton())
 {
 }
@@ -316,17 +319,33 @@ void FGTileMgr::update(double)
     schedule_tiles_at(SGGeod::fromCart(viewPos), vis);
 
     update_queues();
+
+    // scenery loading check, triggers after each sim (tile manager) reinit
+    if (!_scenery_loaded->getBoolValue())
+    {
+        if (_scenery_override->getBoolValue() || isSceneryLoaded())
+        {
+            _scenery_loaded->setBoolValue(true);
+            fgSplashProgress("");
+        }
+        else
+        {
+            fgSplashProgress("loading-scenery");
+            // be nice to loader threads while waiting for initial scenery, reduce to 20fps
+            SGTimeStamp::sleepForMSec(50);
+        }
+    }
 }
 
-// schedule tiles for the viewer bucket (FDM/AI/groundcache/... use
-// "schedule_scenery" instead
-int FGTileMgr::schedule_tiles_at(const SGGeod& location, double range_m)
+// schedule tiles for the viewer bucket
+// (FDM/AI/groundcache/... should use "schedule_scenery" instead)
+void FGTileMgr::schedule_tiles_at(const SGGeod& location, double range_m)
 {
     longitude = location.getLongitudeDeg();
     latitude = location.getLatitudeDeg();
 
     // SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
-    //         << longitude << " " << latatitude );
+    //         << longitude << " " << latitude );
 
     current_bucket.set_bucket( location );
 
@@ -364,8 +383,6 @@ int FGTileMgr::schedule_tiles_at(const SGGeod& location, double range_m)
         previous_bucket.make_bad();
     }
     last_state = state;
-
-    return 1;
 }
 
 /** Schedules scenery for given position. Load request remains valid for given duration
index 9f9473d1a219154a56f53fa7ad9bc22f2867d999..766513d019053ae7f8b900fa9bbf17eca95b8130 100644 (file)
@@ -78,36 +78,34 @@ private:
     TileCache tile_cache;
     simgear::SGTerraSync* _terra_sync;
 
-    // Update the various queues maintained by the tilemagr (private
-    // internal function, do not call directly.)
+    // update various queues internal queues
     void update_queues();
 
+    // schedule tiles for the viewer bucket
+    void schedule_tiles_at(const SGGeod& location, double rangeM);
+
     static void refresh_tile(void* tileMgr, long tileIndex);
 
     SGPropertyNode_ptr _visibilityMeters;
     SGPropertyNode_ptr _maxTileRangeM, _disableNasalHooks;
+    SGPropertyNode_ptr _scenery_loaded, _scenery_override;
 
     osg::ref_ptr<flightgear::SceneryPager> _pager;
 
 public:
     FGTileMgr();
-
     ~FGTileMgr();
 
     // Initialize the Tile Manager
     virtual void init();
     virtual void reinit();
-
     virtual void update(double dt);
 
-    int schedule_tiles_at(const SGGeod& location, double rangeM);
-
-
     const SGBucket& get_current_bucket () const { return current_bucket; }
 
-    /// Returns true if scenery is available for the given lat, lon position
-    /// within a range of range_m.
-    /// lat and lon are expected to be in degrees.
+    // Returns true if scenery is available for the given lat, lon position
+    // within a range of range_m.
+    // lat and lon are expected to be in degrees.
     bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0);
 
     // Returns true if tiles around current view position have been loaded