}
-TileCache::~TileCache( void ) {
- clear_cache();
+TileCache::~TileCache( void )
+{
+ tile_map_iterator it = tile_cache.begin();
+ for (; it != tile_cache.end(); ++it) {
+ TileEntry* tile = it->second;
+ tile->removeFromSceneGraph();
+ delete tile;
+ }
}
* Allow a 1 second timeout since an empty tiles may just be loaded...
*/
SG_LOG( SG_TERRAIN, SG_DEBUG, " dropping an unused and empty tile");
+ min_index = index;
break;
}
if (( e->get_time_expired() < min_time )||
return min_index;
}
+long TileCache::get_first_expired_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() && e->is_expired(current_time))
+ {
+ return current->first;
+ }
+ }
+
+ return -1; // no expired tile found
+}
+
// Clear all flags indicating tiles belonging to the current view
void TileCache::clear_current_view()
for ( ; current != end; ++current ) {
long index = current->first;
- SG_LOG( SG_TERRAIN, SG_DEBUG, "clearing " << index );
TileEntry *e = current->second;
if ( e->is_loaded() ) {
e->tile_bucket.make_bad();
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 );
-
- if (it->second)
- it->second->refresh();
-}
-
// 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)
{