1
0
Fork 0

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:
ThorstenB 2012-09-24 23:42:25 +02:00
parent fd99e9fdfb
commit a2cfef95fb
3 changed files with 31 additions and 44 deletions

View 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, "" );

View 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

View 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