Initial mode to disable caching of tiles.
This commit is contained in:
parent
ffe6c39a1d
commit
f19da413bb
4 changed files with 58 additions and 14 deletions
|
@ -127,6 +127,22 @@ long TileCache::get_drop_tile() {
|
||||||
return min_index;
|
return min_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long TileCache::get_first_invisible_tile() const
|
||||||
|
{
|
||||||
|
const_tile_map_iterator current = tile_cache.begin();
|
||||||
|
const_tile_map_iterator end = tile_cache.end();
|
||||||
|
|
||||||
|
for ( ; current != end; ++current ) {
|
||||||
|
TileEntry *e = current->second;
|
||||||
|
if (!e->is_current_view())
|
||||||
|
{
|
||||||
|
return current->first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1; // no expired tile found
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Clear all flags indicating tiles belonging to the current view
|
// Clear all flags indicating tiles belonging to the current view
|
||||||
void TileCache::clear_current_view()
|
void TileCache::clear_current_view()
|
||||||
|
|
|
@ -74,6 +74,8 @@ public:
|
||||||
// nothing available to be removed.
|
// nothing available to be removed.
|
||||||
long get_drop_tile();
|
long get_drop_tile();
|
||||||
|
|
||||||
|
long get_first_invisible_tile() const;
|
||||||
|
|
||||||
// Clear all flags indicating tiles belonging to the current view
|
// Clear all flags indicating tiles belonging to the current view
|
||||||
void clear_current_view();
|
void clear_current_view();
|
||||||
|
|
||||||
|
|
|
@ -57,25 +57,35 @@ class FGTileMgr::TileManagerListener : public SGPropertyChangeListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TileManagerListener(FGTileMgr* manager) :
|
TileManagerListener(FGTileMgr* manager) :
|
||||||
_manager(manager)
|
_manager(manager),
|
||||||
|
_useVBOsProp(fgGetNode("/sim/rendering/use-vbos", true)),
|
||||||
|
_enableCacheProp(fgGetNode("/sim/tile-cache/enable", true))
|
||||||
{
|
{
|
||||||
fgGetNode("/sim/rendering/use-vbos", true)->addChangeListener(this, true);
|
_useVBOsProp->addChangeListener(this, true);
|
||||||
|
_enableCacheProp->addChangeListener(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
~TileManagerListener()
|
~TileManagerListener()
|
||||||
{
|
{
|
||||||
fgGetNode("/sim/rendering/use-vbos")->removeChangeListener(this);
|
_useVBOsProp->removeChangeListener(this);
|
||||||
|
_enableCacheProp->removeChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void valueChanged(SGPropertyNode* prop)
|
virtual void valueChanged(SGPropertyNode* prop)
|
||||||
{
|
{
|
||||||
|
if (prop == _useVBOsProp) {
|
||||||
bool useVBOs = prop->getBoolValue();
|
bool useVBOs = prop->getBoolValue();
|
||||||
_manager->_options->setPluginStringData("SimGear::USE_VBOS",
|
_manager->_options->setPluginStringData("SimGear::USE_VBOS",
|
||||||
useVBOs ? "ON" : "OFF");
|
useVBOs ? "ON" : "OFF");
|
||||||
|
} else if (prop == _enableCacheProp) {
|
||||||
|
_manager->_enableCache = prop->getBoolValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FGTileMgr* _manager;
|
FGTileMgr* _manager;
|
||||||
|
SGPropertyNode_ptr _useVBOsProp,
|
||||||
|
_enableCacheProp;
|
||||||
};
|
};
|
||||||
|
|
||||||
FGTileMgr::FGTileMgr():
|
FGTileMgr::FGTileMgr():
|
||||||
|
@ -89,7 +99,8 @@ FGTileMgr::FGTileMgr():
|
||||||
_disableNasalHooks(fgGetNode("/sim/temp/disable-scenery-nasal", true)),
|
_disableNasalHooks(fgGetNode("/sim/temp/disable-scenery-nasal", true)),
|
||||||
_scenery_loaded(fgGetNode("/sim/sceneryloaded", true)),
|
_scenery_loaded(fgGetNode("/sim/sceneryloaded", true)),
|
||||||
_scenery_override(fgGetNode("/sim/sceneryloaded-override", true)),
|
_scenery_override(fgGetNode("/sim/sceneryloaded-override", true)),
|
||||||
_pager(FGScenery::getPagerSingleton())
|
_pager(FGScenery::getPagerSingleton()),
|
||||||
|
_enableCache(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,14 +340,24 @@ void FGTileMgr::update_queues(bool& isDownloadingScenery)
|
||||||
}
|
}
|
||||||
|
|
||||||
int drop_count = sz - tile_cache.get_max_cache_size();
|
int drop_count = sz - tile_cache.get_max_cache_size();
|
||||||
if (( drop_count > 0 )&&
|
bool dropTiles = false;
|
||||||
((loading==0)||(drop_count > 10)))
|
if (_enableCache) {
|
||||||
|
dropTiles = ( drop_count > 0 ) && ((loading==0)||(drop_count > 10));
|
||||||
|
} else {
|
||||||
|
dropTiles = true;
|
||||||
|
drop_count = sz; // no limit on tiles to drop
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropTiles)
|
||||||
{
|
{
|
||||||
long drop_index = tile_cache.get_drop_tile();
|
long drop_index = _enableCache ? tile_cache.get_drop_tile() :
|
||||||
|
tile_cache.get_first_invisible_tile();
|
||||||
while ( drop_index > -1 )
|
while ( drop_index > -1 )
|
||||||
{
|
{
|
||||||
// schedule tile for deletion with osg pager
|
// schedule tile for deletion with osg pager
|
||||||
TileEntry* old = tile_cache.get_tile(drop_index);
|
TileEntry* old = tile_cache.get_tile(drop_index);
|
||||||
|
SG_LOG(SG_TERRAIN, SG_ALERT, "Dropping:" << old->get_tile_bucket());
|
||||||
|
|
||||||
tile_cache.clear_entry(drop_index);
|
tile_cache.clear_entry(drop_index);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Object> subgraph = old->getNode();
|
osg::ref_ptr<osg::Object> subgraph = old->getNode();
|
||||||
|
@ -346,12 +367,15 @@ void FGTileMgr::update_queues(bool& isDownloadingScenery)
|
||||||
// the pager and will be deleted in the pager thread.
|
// the pager and will be deleted in the pager thread.
|
||||||
_pager->queueDeleteRequest(subgraph);
|
_pager->queueDeleteRequest(subgraph);
|
||||||
|
|
||||||
if (--drop_count > 0)
|
if (!_enableCache)
|
||||||
|
drop_index = tile_cache.get_first_invisible_tile();
|
||||||
|
// limit tiles dropped to drop_count
|
||||||
|
else if (--drop_count > 0)
|
||||||
drop_index = tile_cache.get_drop_tile();
|
drop_index = tile_cache.get_drop_tile();
|
||||||
else
|
else
|
||||||
drop_index = -1;
|
drop_index = -1;
|
||||||
}
|
}
|
||||||
}
|
} // of dropping tiles loop
|
||||||
}
|
}
|
||||||
|
|
||||||
// given the current lon/lat (in degrees), fill in the array of local
|
// given the current lon/lat (in degrees), fill in the array of local
|
||||||
|
|
|
@ -92,6 +92,8 @@ private:
|
||||||
|
|
||||||
osg::ref_ptr<flightgear::SceneryPager> _pager;
|
osg::ref_ptr<flightgear::SceneryPager> _pager;
|
||||||
|
|
||||||
|
/// is caching of expired tiles enabled or not?
|
||||||
|
bool _enableCache;
|
||||||
public:
|
public:
|
||||||
FGTileMgr();
|
FGTileMgr();
|
||||||
~FGTileMgr();
|
~FGTileMgr();
|
||||||
|
|
Loading…
Reference in a new issue