From a2cfef95fb25ffef10cf0625a5151085e2eb3e70 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 24 Sep 2012 23:42:25 +0200 Subject: [PATCH] Minor tile manager clean-up. The tilemgr schedules scenery, so it should also trigger the "sceneryloaded" signals once it's done. --- src/Main/main.cxx | 28 ---------------------------- src/Scenery/tilemgr.cxx | 29 +++++++++++++++++++++++------ src/Scenery/tilemgr.hxx | 18 ++++++++---------- 3 files changed, 31 insertions(+), 44 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 4dc123c27..5fd2137f8 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -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, "" ); diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index e05133a3e..51f24044b 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -42,6 +42,7 @@ #include
#include #include +#include #include #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 diff --git a/src/Scenery/tilemgr.hxx b/src/Scenery/tilemgr.hxx index 9f9473d1a..766513d01 100644 --- a/src/Scenery/tilemgr.hxx +++ b/src/Scenery/tilemgr.hxx @@ -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 _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 -- 2.39.5