}
+#if 0
// Ensure at least one entry is free in the cache
bool FGNewCache::make_space() {
SG_LOG( SG_TERRAIN, SG_DEBUG, "Make space in cache" );
"FGNewCache::make_space()." );
return false;
}
+#endif
// Return the index of the oldest tile in the cache, return -1 if
bool FGNewCache::insert_tile( FGTileEntry *e ) {
// set time of insertion for tracking age of tiles...
e->set_timestamp(globals->get_sim_time_sec());
- // clear out a distant entry in the cache if needed.
- if ( make_space() ) {
- // register it in the cache
- long tile_index = e->get_tile_bucket().gen_index();
- tile_cache[tile_index] = e;
- return true;
- } else {
- // failed to find cache space
+ // register it in the cache
+ long tile_index = e->get_tile_bucket().gen_index();
+ tile_cache[tile_index] = e;
- return false;
- }
+ return true;
}
// Check if the specified "bucket" exists in the cache
bool exists( const SGBucket& b ) const;
+#if 0
// Ensure at least one entry is free in the cache
bool make_space();
+#endif
// Return the index of the oldest tile in the cache, return -1 if
// nothing available to be removed.
int result = fgPartialFreeSSGtree( (ssgBranch *)kid, n );
num_deletes += result;
n -= result;
- if ( kid->getNumKids() == 0 ) {
- b->removeKid(i);
- num_deletes++;
- n--;
- }
if ( n < 0 ) {
break;
}
} else {
b->removeKid(i);
num_deletes++;
+ n--;
}
}
// remove the parent if it is empty
- if ( b->getNumKids() < 0 ) {
+ if ( b->getNumKids() == 0 ) {
ssgDeRefDelete( b );
num_deletes++;
n--;
SG_LOG( SG_TERRAIN, SG_DEBUG,
"FREEING TILE = (" << tile_bucket << ")" );
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "(start) free_tracker = " << free_tracker );
+
if ( !(free_tracker & NODES) ) {
SG_LOG( SG_TERRAIN, SG_DEBUG,
" deleting " << nodes.size() << " nodes" );
return true;
}
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "(end) free_tracker = " << free_tracker );
+
// if we fall down to here, we still have work todo, return false
return false;
}