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 <Debug/logstream.hxx>
|
||||||
#include <Airports/genapt.hxx>
|
#include <Airports/genapt.hxx>
|
||||||
#include <Bucket/newbucket.hxx>
|
#include <Bucket/newbucket.hxx>
|
||||||
|
#include <Clouds/cloudobj.hxx>
|
||||||
#include <Main/options.hxx>
|
#include <Main/options.hxx>
|
||||||
#include <Main/views.hxx>
|
#include <Main/views.hxx>
|
||||||
#include <Misc/fgpath.hxx>
|
#include <Misc/fgpath.hxx>
|
||||||
|
@ -82,9 +83,9 @@ FGTileCache::init( void )
|
||||||
<< tile_cache.size() );
|
<< tile_cache.size() );
|
||||||
FGTileEntry e;
|
FGTileEntry e;
|
||||||
e.mark_unused();
|
e.mark_unused();
|
||||||
e.vtlist = NULL;
|
e.vec3_ptrs.clear();
|
||||||
e.vnlist = NULL;
|
e.vec2_ptrs.clear();
|
||||||
e.tclist = NULL;
|
e.index_ptrs.clear();
|
||||||
|
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG, " size of tile = "
|
FG_LOG( FG_TERRAIN, FG_DEBUG, " size of tile = "
|
||||||
<< sizeof( e ) );
|
<< sizeof( e ) );
|
||||||
|
@ -151,20 +152,15 @@ FGTileCache::fill_in( int index, const FGBucket& p )
|
||||||
// cout << "FILL IN CACHE ENTRY = " << index << endl;
|
// cout << "FILL IN CACHE ENTRY = " << index << endl;
|
||||||
|
|
||||||
tile_cache[index].center = Point3D( 0.0 );
|
tile_cache[index].center = Point3D( 0.0 );
|
||||||
if ( (tile_cache[index].vtlist != NULL) ||
|
if ( tile_cache[index].vec3_ptrs.size() ||
|
||||||
(tile_cache[index].vnlist != NULL) ||
|
tile_cache[index].vec2_ptrs.size() ||
|
||||||
(tile_cache[index].tclist != NULL) )
|
tile_cache[index].index_ptrs.size() )
|
||||||
{
|
{
|
||||||
FG_LOG( FG_TERRAIN, FG_ALERT,
|
FG_LOG( FG_TERRAIN, FG_ALERT,
|
||||||
"Attempting to overwrite existing or"
|
"Attempting to overwrite existing or"
|
||||||
<< " not properly freed leaf data." );
|
<< " not properly freed leaf data." );
|
||||||
exit(-1);
|
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
|
// Load the appropriate data file and build tile fragment list
|
||||||
FGPath tile_path( current_options.get_fg_root() );
|
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;
|
tile_cache[index].range_ptr = new ssgRangeSelector;
|
||||||
|
|
||||||
ssgBranch *new_tile = fgObjLoad( tile_path.str(), &tile_cache[index] );
|
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 ) {
|
if ( new_tile != NULL ) {
|
||||||
tile_cache[index].range_ptr->addKid( new_tile );
|
tile_cache[index].range_ptr->addKid( new_tile );
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,7 @@ FG_USING_STD(mem_fun_ref);
|
||||||
// Constructor
|
// Constructor
|
||||||
FGTileEntry::FGTileEntry ( void )
|
FGTileEntry::FGTileEntry ( void )
|
||||||
: ncount(0),
|
: ncount(0),
|
||||||
state(Unused),
|
state(Unused)
|
||||||
vtlist(NULL),
|
|
||||||
vnlist(NULL),
|
|
||||||
tclist(NULL)
|
|
||||||
{
|
{
|
||||||
nodes.clear();
|
nodes.clear();
|
||||||
}
|
}
|
||||||
|
@ -79,9 +76,8 @@ static void my_remove_branch( ssgBranch * branch ) {
|
||||||
// Step through the fragment list, deleting the display list, then the
|
// Step through the fragment list, deleting the display list, then the
|
||||||
// fragment, until the list is empty. Also delete the arrays used by
|
// fragment, until the list is empty. Also delete the arrays used by
|
||||||
// ssg as well as the whole ssg branch
|
// ssg as well as the whole ssg branch
|
||||||
void
|
void FGTileEntry::free_tile() {
|
||||||
FGTileEntry::free_tile()
|
int i;
|
||||||
{
|
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
||||||
"FREEING TILE = (" << tile_bucket << ")" );
|
"FREEING TILE = (" << tile_bucket << ")" );
|
||||||
|
|
||||||
|
@ -98,29 +94,23 @@ FGTileEntry::free_tile()
|
||||||
|
|
||||||
// delete the ssg structures
|
// delete the ssg structures
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
||||||
" deleting vertex, normal, and texture coordinate arrays" );
|
" deleting (leaf data) vertex, normal, and "
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
<< " texture coordinate arrays" );
|
||||||
" deleting vertex array" );
|
|
||||||
if ( vtlist != NULL ) {
|
for ( i = 0; i < (int)vec3_ptrs.size(); ++i ) {
|
||||||
delete vtlist;
|
delete vec3_ptrs[i];
|
||||||
vtlist = NULL;
|
|
||||||
}
|
}
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
vec3_ptrs.clear();
|
||||||
" deleting normal array" );
|
|
||||||
if ( vnlist != NULL ) {
|
for ( i = 0; i < (int)vec2_ptrs.size(); ++i ) {
|
||||||
delete vnlist;
|
delete vec2_ptrs[i];
|
||||||
vnlist = NULL;
|
|
||||||
}
|
}
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG,
|
vec2_ptrs.clear();
|
||||||
" deleting texture coordinate array" );
|
|
||||||
if ( tclist != NULL ) {
|
for ( i = 0; i < (int)index_ptrs.size(); ++i ) {
|
||||||
delete tclist;
|
delete index_ptrs[i];
|
||||||
tclist = NULL;
|
|
||||||
}
|
}
|
||||||
for ( int i = 0; i < (int)free_ptrs.size(); ++i ) {
|
index_ptrs.clear();
|
||||||
delete free_ptrs[i];
|
|
||||||
}
|
|
||||||
free_ptrs.clear();
|
|
||||||
|
|
||||||
// delete the ssg branch
|
// delete the ssg branch
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,9 @@ public:
|
||||||
typedef container::iterator FragmentIterator;
|
typedef container::iterator FragmentIterator;
|
||||||
typedef container::const_iterator FragmentConstIterator;
|
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:
|
public:
|
||||||
// node list (the per fragment face lists reference this node list)
|
// node list (the per fragment face lists reference this node list)
|
||||||
|
@ -108,11 +110,15 @@ public:
|
||||||
container fragment_list;
|
container fragment_list;
|
||||||
|
|
||||||
// ssg related structures
|
// ssg related structures
|
||||||
sgVec3 *vtlist;
|
// sgVec3 *vtlist;
|
||||||
sgVec3 *vnlist;
|
// sgVec3 *vnlist;
|
||||||
sgVec2 *tclist;
|
// sgVec2 *tclist;
|
||||||
free_list free_ptrs; // list of pointers to free when tile
|
|
||||||
// entry goes away
|
// 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:
|
// ssg tree structure for this tile is as follows:
|
||||||
// ssgRoot(scene)
|
// ssgRoot(scene)
|
||||||
|
|
Loading…
Add table
Reference in a new issue