// Free a tile cache entry
-void TileCache::entry_free( long cache_index ) {
- SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING CACHE ENTRY = " << cache_index );
- TileEntry *tile = tile_cache[cache_index];
+void TileCache::entry_free( long tile_index ) {
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING CACHE ENTRY = " << tile_index );
+ TileEntry *tile = tile_cache[tile_index];
tile->removeFromSceneGraph();
- tile_cache.erase( cache_index );
-
+ tile_cache.erase( tile_index );
delete tile;
}
SG_LOG( SG_TERRAIN, SG_INFO, " current cache size = "
<< tile_cache.size() );
-#if 0 // don't clear the cache
clear_cache();
-#endif
SG_LOG( SG_TERRAIN, SG_INFO, " done with init()" );
}
// Clear a cache entry, note that the cache only holds pointers
// and this does not free the object which is pointed to.
-void TileCache::clear_entry( long cache_index ) {
- tile_cache.erase( cache_index );
+void TileCache::clear_entry( long tile_index ) {
+ tile_cache.erase( tile_index );
}
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)
{
if ((!current_view)&&(request_time<=0.0))
return;
- // update priority when hire - or old has expired
+ // update priority when higher - or old request has expired
if ((t->is_expired(current_time))||
(priority > t->get_priority()))
{