diff --git a/src/Scenery/newcache.cxx b/src/Scenery/newcache.cxx index f9c46b20a..4da87508d 100644 --- a/src/Scenery/newcache.cxx +++ b/src/Scenery/newcache.cxx @@ -105,6 +105,7 @@ bool FGNewCache::exists( const SGBucket& b ) const { } +#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" ); @@ -169,6 +170,7 @@ bool FGNewCache::make_space() { "FGNewCache::make_space()." ); return false; } +#endif // Return the index of the oldest tile in the cache, return -1 if @@ -246,18 +248,12 @@ void FGNewCache::clear_cache() { 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; } diff --git a/src/Scenery/newcache.hxx b/src/Scenery/newcache.hxx index 8060a1bec..10686641a 100644 --- a/src/Scenery/newcache.hxx +++ b/src/Scenery/newcache.hxx @@ -82,8 +82,10 @@ public: // 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. diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index 8aae404f7..428facd19 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -698,21 +698,17 @@ static int fgPartialFreeSSGtree( ssgBranch *b, int n ) { 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--; @@ -731,6 +727,8 @@ bool FGTileEntry::free_tile() { 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" ); @@ -792,6 +790,8 @@ bool FGTileEntry::free_tile() { 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; }