More tile memory clean ups.
This commit is contained in:
parent
cde20a9fd6
commit
eb02aba5c8
3 changed files with 42 additions and 44 deletions
|
@ -37,6 +37,7 @@
|
|||
#include <Debug/logstream.hxx>
|
||||
#include <Airports/genapt.hxx>
|
||||
#include <Bucket/newbucket.hxx>
|
||||
#include <Clouds/cloudobj.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include <Main/views.hxx>
|
||||
#include <Misc/fgpath.hxx>
|
||||
|
@ -82,9 +83,9 @@ FGTileCache::init( void )
|
|||
<< tile_cache.size() );
|
||||
FGTileEntry e;
|
||||
e.mark_unused();
|
||||
e.vtlist = NULL;
|
||||
e.vnlist = NULL;
|
||||
e.tclist = NULL;
|
||||
e.vec3_ptrs.clear();
|
||||
e.vec2_ptrs.clear();
|
||||
e.index_ptrs.clear();
|
||||
|
||||
FG_LOG( FG_TERRAIN, FG_DEBUG, " size of tile = "
|
||||
<< sizeof( e ) );
|
||||
|
@ -151,20 +152,15 @@ FGTileCache::fill_in( int index, const FGBucket& p )
|
|||
// cout << "FILL IN CACHE ENTRY = " << index << endl;
|
||||
|
||||
tile_cache[index].center = Point3D( 0.0 );
|
||||
if ( (tile_cache[index].vtlist != NULL) ||
|
||||
(tile_cache[index].vnlist != NULL) ||
|
||||
(tile_cache[index].tclist != NULL) )
|
||||
if ( tile_cache[index].vec3_ptrs.size() ||
|
||||
tile_cache[index].vec2_ptrs.size() ||
|
||||
tile_cache[index].index_ptrs.size() )
|
||||
{
|
||||
FG_LOG( FG_TERRAIN, FG_ALERT,
|
||||
"Attempting to overwrite existing or"
|
||||
<< " not properly freed leaf data." );
|
||||
exit(-1);
|
||||
}
|
||||
// Force some values in case the tile fails to load (i.e. fill
|
||||
// doesn't exist)
|
||||
// tile_cache[index].vtlist = NULL;
|
||||
// tile_cache[index].vnlist = NULL;
|
||||
// tile_cache[index].tclist = NULL;
|
||||
|
||||
// Load the appropriate data file and build tile fragment list
|
||||
FGPath tile_path( current_options.get_fg_root() );
|
||||
|
@ -179,6 +175,12 @@ FGTileCache::fill_in( int index, const FGBucket& p )
|
|||
tile_cache[index].range_ptr = new ssgRangeSelector;
|
||||
|
||||
ssgBranch *new_tile = fgObjLoad( tile_path.str(), &tile_cache[index] );
|
||||
if ( current_options.get_clouds() ) {
|
||||
ssgLeaf *cloud_layer = fgGenCloudLayer( &tile_cache[index],
|
||||
current_options.get_clouds_asl() );
|
||||
new_tile -> addKid( cloud_layer );
|
||||
}
|
||||
|
||||
if ( new_tile != NULL ) {
|
||||
tile_cache[index].range_ptr->addKid( new_tile );
|
||||
}
|
||||
|
|
|
@ -42,10 +42,7 @@ FG_USING_STD(mem_fun_ref);
|
|||
// Constructor
|
||||
FGTileEntry::FGTileEntry ( void )
|
||||
: ncount(0),
|
||||
state(Unused),
|
||||
vtlist(NULL),
|
||||
vnlist(NULL),
|
||||
tclist(NULL)
|
||||
state(Unused)
|
||||
{
|
||||
nodes.clear();
|
||||
}
|
||||
|
@ -79,9 +76,8 @@ static void my_remove_branch( ssgBranch * branch ) {
|
|||
// Step through the fragment list, deleting the display list, then the
|
||||
// fragment, until the list is empty. Also delete the arrays used by
|
||||
// ssg as well as the whole ssg branch
|
||||
void
|
||||
FGTileEntry::free_tile()
|
||||
{
|
||||
void FGTileEntry::free_tile() {
|
||||
int i;
|
||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
||||
"FREEING TILE = (" << tile_bucket << ")" );
|
||||
|
||||
|
@ -98,29 +94,23 @@ FGTileEntry::free_tile()
|
|||
|
||||
// delete the ssg structures
|
||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
||||
" deleting vertex, normal, and texture coordinate arrays" );
|
||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
||||
" deleting vertex array" );
|
||||
if ( vtlist != NULL ) {
|
||||
delete vtlist;
|
||||
vtlist = NULL;
|
||||
" deleting (leaf data) vertex, normal, and "
|
||||
<< " texture coordinate arrays" );
|
||||
|
||||
for ( i = 0; i < (int)vec3_ptrs.size(); ++i ) {
|
||||
delete vec3_ptrs[i];
|
||||
}
|
||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
||||
" deleting normal array" );
|
||||
if ( vnlist != NULL ) {
|
||||
delete vnlist;
|
||||
vnlist = NULL;
|
||||
vec3_ptrs.clear();
|
||||
|
||||
for ( i = 0; i < (int)vec2_ptrs.size(); ++i ) {
|
||||
delete vec2_ptrs[i];
|
||||
}
|
||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
||||
" deleting texture coordinate array" );
|
||||
if ( tclist != NULL ) {
|
||||
delete tclist;
|
||||
tclist = NULL;
|
||||
vec2_ptrs.clear();
|
||||
|
||||
for ( i = 0; i < (int)index_ptrs.size(); ++i ) {
|
||||
delete index_ptrs[i];
|
||||
}
|
||||
for ( int i = 0; i < (int)free_ptrs.size(); ++i ) {
|
||||
delete free_ptrs[i];
|
||||
}
|
||||
free_ptrs.clear();
|
||||
index_ptrs.clear();
|
||||
|
||||
// delete the ssg branch
|
||||
|
||||
|
|
|
@ -84,7 +84,9 @@ public:
|
|||
typedef container::iterator FragmentIterator;
|
||||
typedef container::const_iterator FragmentConstIterator;
|
||||
|
||||
typedef vector < unsigned short * > free_list;
|
||||
typedef vector < sgVec3 * > free_vec3_list;
|
||||
typedef vector < sgVec2 * > free_vec2_list;
|
||||
typedef vector < unsigned short * > free_index_list;
|
||||
|
||||
public:
|
||||
// node list (the per fragment face lists reference this node list)
|
||||
|
@ -108,11 +110,15 @@ public:
|
|||
container fragment_list;
|
||||
|
||||
// ssg related structures
|
||||
sgVec3 *vtlist;
|
||||
sgVec3 *vnlist;
|
||||
sgVec2 *tclist;
|
||||
free_list free_ptrs; // list of pointers to free when tile
|
||||
// entry goes away
|
||||
// sgVec3 *vtlist;
|
||||
// sgVec3 *vnlist;
|
||||
// sgVec2 *tclist;
|
||||
|
||||
// list of pointers to memory chunks that need to be freed when
|
||||
// tile entry goes away
|
||||
free_vec3_list vec3_ptrs;
|
||||
free_vec2_list vec2_ptrs;
|
||||
free_index_list index_ptrs;
|
||||
|
||||
// ssg tree structure for this tile is as follows:
|
||||
// ssgRoot(scene)
|
||||
|
|
Loading…
Reference in a new issue