1
0
Fork 0

Added loaded flag to FGTileEntry so that the main thread knows when the

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.
This commit is contained in:
curt 2001-04-06 18:30:07 +00:00
parent 4b6e8102a7
commit 606b8d13d9
2 changed files with 15 additions and 11 deletions

View 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;
}

View 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 );
};