// we need to free the furthest entry
long min_index = -1;
double timestamp = 0.0;
- double max_time = 0;
+ double min_time = DBL_MAX;
tile_map_iterator current = tile_cache.begin();
tile_map_iterator end = tile_cache.end();
if ( e->is_loaded() ) {
timestamp = e->get_timestamp();
- if ( timestamp > max_time ) {
- max_time = timestamp;
+ if ( timestamp < min_time ) {
+ min_time = timestamp;
+ min_index = index;
}
} else {
}
SG_LOG( SG_TERRAIN, SG_DEBUG, " index = " << min_index );
- SG_LOG( SG_TERRAIN, SG_DEBUG, " max_time = " << max_time );
+ SG_LOG( SG_TERRAIN, SG_DEBUG, " min_time = " << min_time );
return min_index;
}
bool FGNewCache::insert_tile( FGTileEntry *e ) {
// register tile in the cache
long tile_index = e->get_tile_bucket().gen_index();
+ // not needed if timestamps are updated in cull-callback
+ // e->set_timestamp(globals->get_sim_time_sec());
tile_cache[tile_index] = e;
return true;
inline FGTileEntry *get_tile( const long tile_index ) const {
const_tile_map_iterator it = tile_cache.find( tile_index );
if ( it != tile_cache.end() ) {
- it->second->set_timestamp(globals->get_sim_time_sec());
+ // not needed if timestamps are updated in cull-callback
+ // it->second->set_timestamp(globals->get_sim_time_sec());
return it->second;
} else {
return NULL;
class TileCullCallback : public osg::NodeCallback
{
public:
- TileCullCallback() : _timeStamp(DBL_MAX) {}
+ TileCullCallback() : _timeStamp(0) {}
TileCullCallback(const TileCullCallback& tc, const osg::CopyOp& copyOp) :
NodeCallback(tc, copyOp), _timeStamp(tc._timeStamp)
{