Add method to reload specific scenery tiles.
This commit is contained in:
@@ -47,12 +47,11 @@ TileCache::~TileCache( void ) {
|
|||||||
|
|
||||||
|
|
||||||
// Free a tile cache entry
|
// Free a tile cache entry
|
||||||
void TileCache::entry_free( long cache_index ) {
|
void TileCache::entry_free( long tile_index ) {
|
||||||
SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING CACHE ENTRY = " << cache_index );
|
SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING CACHE ENTRY = " << tile_index );
|
||||||
TileEntry *tile = tile_cache[cache_index];
|
TileEntry *tile = tile_cache[tile_index];
|
||||||
tile->removeFromSceneGraph();
|
tile->removeFromSceneGraph();
|
||||||
tile_cache.erase( cache_index );
|
tile_cache.erase( tile_index );
|
||||||
|
|
||||||
delete tile;
|
delete tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,8 +143,8 @@ void TileCache::clear_current_view()
|
|||||||
|
|
||||||
// Clear a cache entry, note that the cache only holds pointers
|
// Clear a cache entry, note that the cache only holds pointers
|
||||||
// and this does not free the object which is pointed to.
|
// and this does not free the object which is pointed to.
|
||||||
void TileCache::clear_entry( long cache_index ) {
|
void TileCache::clear_entry( long tile_index ) {
|
||||||
tile_cache.erase( cache_index );
|
tile_cache.erase( tile_index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -182,6 +181,26 @@ bool TileCache::insert_tile( TileEntry *e ) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads a tile when it's already in memory.
|
||||||
|
*/
|
||||||
|
void TileCache::refresh_tile(long tile_index)
|
||||||
|
{
|
||||||
|
const_tile_map_iterator it = tile_cache.find( tile_index );
|
||||||
|
if ( it == tile_cache.end() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SG_LOG( SG_TERRAIN, SG_DEBUG, "REFRESHING CACHE ENTRY = " << tile_index );
|
||||||
|
|
||||||
|
TileEntry* e = NULL;
|
||||||
|
if (!it->second->is_expired(current_time))
|
||||||
|
e = new TileEntry(it->second);
|
||||||
|
|
||||||
|
entry_free(tile_index);
|
||||||
|
if (e)
|
||||||
|
tile_cache[tile_index] = e;
|
||||||
|
}
|
||||||
|
|
||||||
// update tile's priority and expiry time according to current request
|
// update tile's priority and expiry time according to current request
|
||||||
void TileCache::request_tile(TileEntry* t,float priority,bool current_view,double request_time)
|
void TileCache::request_tile(TileEntry* t,float priority,bool current_view,double request_time)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ public:
|
|||||||
// and this does not free the object which is pointed to.
|
// and this does not free the object which is pointed to.
|
||||||
void clear_entry( long cache_entry );
|
void clear_entry( long cache_entry );
|
||||||
|
|
||||||
|
// Refresh/reload a tile when it's already in memory.
|
||||||
|
void refresh_tile(long tile_index);
|
||||||
|
|
||||||
// Clear all completely loaded tiles (ignores partially loaded tiles)
|
// Clear all completely loaded tiles (ignores partially loaded tiles)
|
||||||
void clear_cache();
|
void clear_cache();
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,20 @@ TileEntry::TileEntry ( const SGBucket& b )
|
|||||||
_node->setRange(0, 0.0, 10000.0);
|
_node->setRange(0, 0.0, 10000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TileEntry::TileEntry( const TileEntry& t )
|
||||||
|
: tile_bucket( t.tile_bucket ),
|
||||||
|
tileFileName(t.tileFileName),
|
||||||
|
_node( new osg::LOD ),
|
||||||
|
_priority(t._priority),
|
||||||
|
_current_view(t._current_view),
|
||||||
|
_time_expired(t._time_expired)
|
||||||
|
{
|
||||||
|
_node->setName(tileFileName);
|
||||||
|
// Give a default LOD range so that traversals that traverse
|
||||||
|
// active children (like the groundcache lookup) will work before
|
||||||
|
// tile manager has had a chance to update this node.
|
||||||
|
_node->setRange(0, 0.0, 10000.0);
|
||||||
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
TileEntry::~TileEntry ()
|
TileEntry::~TileEntry ()
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ public:
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
TileEntry( const SGBucket& b );
|
TileEntry( const SGBucket& b );
|
||||||
|
TileEntry( const TileEntry& t );
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~TileEntry();
|
~TileEntry();
|
||||||
|
|||||||
@@ -283,6 +283,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
~SGBlockingDeque() {}
|
~SGBlockingDeque() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void clear() {
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> g(mutex);
|
||||||
|
this->queue.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user