]> git.mxchange.org Git - flightgear.git/commitdiff
More tile memory clean ups.
authorcurt <curt>
Wed, 27 Oct 1999 00:52:25 +0000 (00:52 +0000)
committercurt <curt>
Wed, 27 Oct 1999 00:52:25 +0000 (00:52 +0000)
src/Scenery/tilecache.cxx
src/Scenery/tileentry.cxx
src/Scenery/tileentry.hxx

index e3c5c61b6a8d85959a199103aa00a6b19f812e05..c052b233b15c311afd2d821a6d87a94b9c7ff65f 100644 (file)
@@ -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 );
     }
index 277dff4a57d99bac68994dbd890a12cf8f8f9374..d2248c931e43d1fb3931f7ab5a4c76c55b9c377a 100644 (file)
@@ -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;
-    }
-    FG_LOG( FG_TERRAIN, FG_DEBUG,
-           "    deleting normal array" );
-    if ( vnlist != NULL ) {
-       delete vnlist;
-       vnlist = 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 texture coordinate array" );
-    if ( tclist != NULL ) {
-       delete tclist;
-       tclist = NULL;
+    vec3_ptrs.clear();
+
+    for ( i = 0; i < (int)vec2_ptrs.size(); ++i ) {
+       delete vec2_ptrs[i];
     }
-    for ( int i = 0; i < (int)free_ptrs.size(); ++i ) {
-       delete free_ptrs[i];
+    vec2_ptrs.clear();
+
+    for ( i = 0; i < (int)index_ptrs.size(); ++i ) {
+       delete index_ptrs[i];
     }
-    free_ptrs.clear();
+    index_ptrs.clear();
 
     // delete the ssg branch
 
index 8607591ff2f77cfc6afafb9a81cd3b89eee386dd..49e7931fc1e97763d6209231ebf31c205be21a84 100644 (file)
@@ -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)