-// Free "n" leaf elements of an ssg tree. returns the number of
-// elements freed. An empty branch node is considered a leaf. This
-// is intended to spread the load of freeing a complex tile out over
-// several frames.
-static int fgPartialFreeSSGtree( osg::Group *b, int n ) {
- int num_deletes = b->getNumChildren();
-
- b->removeChildren(0, b->getNumChildren());
-
- return num_deletes;
-}
-
-
-// Clean up the memory used by this tile and delete the arrays used by
-// ssg as well as the whole ssg branch
-bool TileEntry::free_tile() {
- int delete_size = 100;
- 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) ) {
- free_tracker |= NODES;
- } else if ( !(free_tracker & VEC_PTRS) ) {
- free_tracker |= VEC_PTRS;
- } else if ( !(free_tracker & TERRA_NODE) ) {
- // delete the terrain branch (this should already have been
- // disconnected from the scene graph)
- SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING terra_transform" );
- if ( fgPartialFreeSSGtree( _node.get(), delete_size ) == 0 ) {
- _node = 0;
- free_tracker |= TERRA_NODE;
- }
- } else if ( !(free_tracker & LIGHTMAPS) ) {
- free_tracker |= LIGHTMAPS;
- } else {
- 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;
-}
-
-