Minor tile manager clean-up.
The tilemgr schedules scenery, so it should also trigger the "sceneryloaded" signals once it's done.
This commit is contained in:
parent
fd99e9fdfb
commit
a2cfef95fb
3 changed files with 31 additions and 44 deletions
|
@ -80,31 +80,6 @@ using std::vector;
|
||||||
// is initialized.
|
// is initialized.
|
||||||
extern int _bootstrap_OSInit;
|
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
|
// What should we do when we have nothing else to do? Let's get ready
|
||||||
// for the next move and update the display?
|
// for the next move and update the display?
|
||||||
static void fgMainLoop( void )
|
static void fgMainLoop( void )
|
||||||
|
@ -126,9 +101,6 @@ static void fgMainLoop( void )
|
||||||
// update all subsystems
|
// update all subsystems
|
||||||
globals->get_subsystem_mgr()->update(sim_dt);
|
globals->get_subsystem_mgr()->update(sim_dt);
|
||||||
|
|
||||||
// END Tile Manager updates
|
|
||||||
fgLoadInitialScenery();
|
|
||||||
|
|
||||||
simgear::AtomicChangeListener::fireChangeListeners();
|
simgear::AtomicChangeListener::fireChangeListeners();
|
||||||
|
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "" );
|
SG_LOG( SG_GENERAL, SG_DEBUG, "" );
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <Viewer/renderer.hxx>
|
#include <Viewer/renderer.hxx>
|
||||||
#include <Viewer/viewer.hxx>
|
#include <Viewer/viewer.hxx>
|
||||||
|
#include <Viewer/splash.hxx>
|
||||||
#include <Scripting/NasalSys.hxx>
|
#include <Scripting/NasalSys.hxx>
|
||||||
|
|
||||||
#include "scenery.hxx"
|
#include "scenery.hxx"
|
||||||
|
@ -61,6 +62,8 @@ FGTileMgr::FGTileMgr():
|
||||||
_visibilityMeters(fgGetNode("/environment/visibility-m", true)),
|
_visibilityMeters(fgGetNode("/environment/visibility-m", true)),
|
||||||
_maxTileRangeM(fgGetNode("/sim/rendering/static-lod/bare", true)),
|
_maxTileRangeM(fgGetNode("/sim/rendering/static-lod/bare", true)),
|
||||||
_disableNasalHooks(fgGetNode("/sim/temp/disable-scenery-nasal", 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())
|
_pager(FGScenery::getPagerSingleton())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -316,17 +319,33 @@ void FGTileMgr::update(double)
|
||||||
schedule_tiles_at(SGGeod::fromCart(viewPos), vis);
|
schedule_tiles_at(SGGeod::fromCart(viewPos), vis);
|
||||||
|
|
||||||
update_queues();
|
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 tiles for the viewer bucket
|
||||||
// "schedule_scenery" instead
|
// (FDM/AI/groundcache/... should use "schedule_scenery" instead)
|
||||||
int FGTileMgr::schedule_tiles_at(const SGGeod& location, double range_m)
|
void FGTileMgr::schedule_tiles_at(const SGGeod& location, double range_m)
|
||||||
{
|
{
|
||||||
longitude = location.getLongitudeDeg();
|
longitude = location.getLongitudeDeg();
|
||||||
latitude = location.getLatitudeDeg();
|
latitude = location.getLatitudeDeg();
|
||||||
|
|
||||||
// SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
|
// SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
|
||||||
// << longitude << " " << latatitude );
|
// << longitude << " " << latitude );
|
||||||
|
|
||||||
current_bucket.set_bucket( location );
|
current_bucket.set_bucket( location );
|
||||||
|
|
||||||
|
@ -364,8 +383,6 @@ int FGTileMgr::schedule_tiles_at(const SGGeod& location, double range_m)
|
||||||
previous_bucket.make_bad();
|
previous_bucket.make_bad();
|
||||||
}
|
}
|
||||||
last_state = state;
|
last_state = state;
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Schedules scenery for given position. Load request remains valid for given duration
|
/** Schedules scenery for given position. Load request remains valid for given duration
|
||||||
|
|
|
@ -78,36 +78,34 @@ private:
|
||||||
TileCache tile_cache;
|
TileCache tile_cache;
|
||||||
simgear::SGTerraSync* _terra_sync;
|
simgear::SGTerraSync* _terra_sync;
|
||||||
|
|
||||||
// Update the various queues maintained by the tilemagr (private
|
// update various queues internal queues
|
||||||
// internal function, do not call directly.)
|
|
||||||
void update_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);
|
static void refresh_tile(void* tileMgr, long tileIndex);
|
||||||
|
|
||||||
SGPropertyNode_ptr _visibilityMeters;
|
SGPropertyNode_ptr _visibilityMeters;
|
||||||
SGPropertyNode_ptr _maxTileRangeM, _disableNasalHooks;
|
SGPropertyNode_ptr _maxTileRangeM, _disableNasalHooks;
|
||||||
|
SGPropertyNode_ptr _scenery_loaded, _scenery_override;
|
||||||
|
|
||||||
osg::ref_ptr<flightgear::SceneryPager> _pager;
|
osg::ref_ptr<flightgear::SceneryPager> _pager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGTileMgr();
|
FGTileMgr();
|
||||||
|
|
||||||
~FGTileMgr();
|
~FGTileMgr();
|
||||||
|
|
||||||
// Initialize the Tile Manager
|
// Initialize the Tile Manager
|
||||||
virtual void init();
|
virtual void init();
|
||||||
virtual void reinit();
|
virtual void reinit();
|
||||||
|
|
||||||
virtual void update(double dt);
|
virtual void update(double dt);
|
||||||
|
|
||||||
int schedule_tiles_at(const SGGeod& location, double rangeM);
|
|
||||||
|
|
||||||
|
|
||||||
const SGBucket& get_current_bucket () const { return current_bucket; }
|
const SGBucket& get_current_bucket () const { return current_bucket; }
|
||||||
|
|
||||||
/// Returns true if scenery is available for the given lat, lon position
|
// Returns true if scenery is available for the given lat, lon position
|
||||||
/// within a range of range_m.
|
// within a range of range_m.
|
||||||
/// lat and lon are expected to be in degrees.
|
// lat and lon are expected to be in degrees.
|
||||||
bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0);
|
bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0);
|
||||||
|
|
||||||
// Returns true if tiles around current view position have been loaded
|
// Returns true if tiles around current view position have been loaded
|
||||||
|
|
Loading…
Add table
Reference in a new issue