27#include <simgear/bucket/newbucket.hxx>
28#include <simgear/debug/logstream.hxx>
29#include <simgear/misc/sg_path.hxx>
35 max_cache_size(100), current_time(0.0)
44 for (; it != tile_cache.end(); ++it) {
53void TileCache::entry_free(
long tile_index ) {
54 SG_LOG( SG_TERRAIN, SG_DEBUG,
"FREEING CACHE ENTRY = " << tile_index );
57 tile_cache.erase( tile_index );
64 SG_LOG( SG_TERRAIN, SG_INFO,
"Initializing the tile cache." );
66 SG_LOG( SG_TERRAIN, SG_INFO,
" max cache size = "
68 SG_LOG( SG_TERRAIN, SG_INFO,
" current cache size = "
69 << tile_cache.size() );
73 SG_LOG( SG_TERRAIN, SG_INFO,
" done with init()" );
79 long tile_index = b.gen_index();
82 return ( it != tile_cache.end() );
87 long tile_index = - b.gen_vpb_index();
90 return ( it != tile_cache.end() );
98 double min_time = DBL_MAX;
99 float priority = FLT_MAX;
104 for ( ; current !=
end; ++current ) {
105 long index = current->first;
116 SG_LOG( SG_TERRAIN, SG_DEBUG,
" dropping an unused and empty tile");
132 SG_LOG( SG_TERRAIN, SG_DEBUG,
" index = " << min_index );
133 SG_LOG( SG_TERRAIN, SG_DEBUG,
" min_time = " << min_time );
143 for ( ; current !=
end; ++current ) {
147 return current->first;
161 for ( ; current !=
end; ++current ) {
175 tile_cache.erase( tile_index );
181 std::vector<long> indexList;
185 for ( ; current !=
end; ++current ) {
186 long index = current->first;
191 indexList.push_back( index);
194 for (
unsigned int it = 0; it < indexList.size(); it++) {
195 entry_free( indexList[ it]);
205 tile_cache[tile_index] = e;
217 tile_cache[tile_index] = e;
227 if ((!current_view)&&(request_time<=0.0))
253 return ((b.gen_index() == t.first) && (t.second->getExtension() == TileEntry::Extension::STG));
255 if ( it != tile_cache.end() ) {
267 return (( - b.gen_vpb_index() == t.first) && (t.second->getExtension() == TileEntry::Extension::VPB));
269 if ( it != tile_cache.end() ) {
tile_map::const_iterator const_tile_map_iterator
STGTileEntry * get_stg_tile(const SGBucket &b) const
void request_tile(TileEntry *t, float priority, bool current_view, double requesttime)
tile_map::iterator tile_map_iterator
void clear_current_view()
long get_first_expired_tile() const
bool exists_stg(const SGBucket &b) const
void clear_entry(long cache_entry)
bool exists_vpb(const SGBucket &b) const
VPBTileEntry * get_vpb_tile(const SGBucket &b) const
bool insert_tile(STGTileEntry *e)
Create a new tile and enqueue it for loading.
A class to encapsulate everything we need to know about a scenery tile.
void set_priority(float priority)
double get_time_expired() const
bool is_expired(double current_time) const
Return false if the tile entry is still needed, otherwise return true indicating that the tile is no ...
float get_priority() const
bool is_current_view() const
const SGBucket & get_tile_bucket() const
Return the "bucket" for this tile.
void set_current_view(bool current_view)
bool is_loaded() const
Return true if the tile entry is loaded, otherwise return false indicating that the loading thread is...
void removeFromSceneGraph()
disconnect terrain mesh and ground lighting nodes from scene graph for this tile.
void update_time_expired(double time_expired)