]> git.mxchange.org Git - flightgear.git/commitdiff
Added loaded flag to FGTileEntry so that the main thread knows when the
authorcurt <curt>
Fri, 6 Apr 2001 18:30:07 +0000 (18:30 +0000)
committercurt <curt>
Fri, 6 Apr 2001 18:30:07 +0000 (18:30 +0000)
tile has been loaded.  Since this flag can be set by another thread I've
declared it "volatile bool".

Also cleaned up delete vs delete[] usage.  Gcc is happy with delete[],
which is the correct usage.

src/Scenery/tileentry.cxx
src/Scenery/tileentry.hxx

index 886f71fec76ecb5ccee9566cb2247efaf60830bc..d6964a24e865a3fbf25dcd58cf30acade2b0b6c2 100644 (file)
@@ -58,7 +58,8 @@ FGTileEntry::FGTileEntry ( const SGBucket& b )
       center( Point3D( 0.0 ) ),
       tile_bucket( b ),
       terra_transform( new ssgTransform ),
-      terra_range( new ssgRangeSelector )
+      terra_range( new ssgRangeSelector ),
+      loaded(false)
 {
     nodes.clear();
 
@@ -114,20 +115,12 @@ void FGTileEntry::free_tile() {
            << " texture coordinate arrays" );
 
     for ( i = 0; i < (int)vec3_ptrs.size(); ++i ) {
-#if defined(macintosh) || defined(_MSC_VER)
        delete [] vec3_ptrs[i];  //that's the correct version
-#else
-       delete vec3_ptrs[i];
-#endif
     }
     vec3_ptrs.clear();
 
     for ( i = 0; i < (int)vec2_ptrs.size(); ++i ) {
-#if defined(macintosh) || defined(_MSC_VER)
        delete [] vec2_ptrs[i];  //that's the correct version
-#else
-       delete vec2_ptrs[i];
-#endif
     }
     vec2_ptrs.clear();
 
@@ -182,6 +175,8 @@ void FGTileEntry::free_tile() {
 // Update the ssg transform node for this tile so it can be
 // properly drawn relative to our (0,0,0) point
 void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
+    if ( !loaded ) return;
+
     SetOffset( p );
 
 // #define USE_UP_AND_COMING_PLIB_FEATURE
@@ -329,7 +324,7 @@ FGTileEntry::obj_load( const std::string& path,
 
 
 void
-FGTileEntry::load( SGPath& tile_path, bool is_base )
+FGTileEntry::load( const SGPath& base, bool is_base )
 {
     // a cheesy hack (to be fixed later)
     extern ssgBranch *terrain;
@@ -337,6 +332,7 @@ FGTileEntry::load( SGPath& tile_path, bool is_base )
 
     string index_str = tile_bucket.gen_index_str();
 
+    SGPath tile_path = base;
     // Generate name of file to load.
     tile_path.append( tile_bucket.gen_base_path() );
     SGPath basename = tile_path;
@@ -417,4 +413,6 @@ FGTileEntry::load( SGPath& tile_path, bool is_base )
        ground->addKid( lights_transform );
     }
     /* end of ground light section */
+
+    loaded = true;
 }
index b0e8746879c1488d5623649364f1ae2761f4e6cf..091110212d15b8c16e26f9795092d881bab93d9e 100644 (file)
@@ -117,6 +117,12 @@ private:
     // want based on lighting conditions.
     ssgSelector *lights_brightness;
 
+    /**
+     * Indicates this tile has been loaded from a file.
+     * Note that this may be set asynchronously by another thread.
+     */
+    volatile bool loaded;
+
     ssgBranch* obj_load( const std::string& path,
                         ssgVertexArray* lights, bool is_base );
 
@@ -153,7 +159,7 @@ public:
      * @param is_base is this a base terrain object for which we should generate
      *        random ground light points
      */
-    void load( SGPath& base, bool is_base );
+    void load( const SGPath& base, bool is_base );
 };