diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 8681a5e4a..aa9f37aa2 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -46,7 +46,6 @@ FGGlobals::FGGlobals() : event_mgr( new SGEventMgr ), sim_time_sec( 0.0 ), fg_root( "" ), - fg_scenery( "" ), #if defined(FX) && defined(XMESA) fullscreen( true ), #endif @@ -118,34 +117,42 @@ void FGGlobals::set_fg_root (const string &root) { } void FGGlobals::set_fg_scenery (const string &scenery) { - if (scenery.empty()) - return; + SGPath s; + if (scenery.empty()) { + s.set( fg_root ); + s.append( "Scenery" ); + } else + s.set( scenery ); - // TODO: Split the scenery path up into separate - // paths (taking into account the search path separator - // and test them individually. - // -EMH- - SGPath pt( scenery ), po( scenery ); - pt.append("Terrain"); - po.append("Objects"); + string_list path_list = sgPathSplit( s.str() ); + fg_scenery.clear(); - ulDir *td = ulOpenDir(pt.c_str()); - ulDir *od = ulOpenDir(po.c_str()); + for (unsigned i = 0; i < path_list.size(); i++) { - if (td == NULL) { - if (od == NULL) { - fg_scenery = scenery; - } else { - fg_scenery = po.str(); - ulCloseDir(od); + ulDir *d = ulOpenDir( path_list[0].c_str() ); + if (d == NULL) + continue; + ulCloseDir( d ); + + SGPath pt( path_list[i] ), po( path_list[i] ); + pt.append("Terrain"); + po.append("Objects"); + + ulDir *td = ulOpenDir( pt.c_str() ); + ulDir *od = ulOpenDir( po.c_str() ); + + if (td == NULL && od == NULL) + fg_scenery.push_back( path_list[i] ); + else { + if (td != NULL) { + fg_scenery.push_back( pt.str() ); + ulCloseDir( td ); + } + if (od != NULL) { + fg_scenery.push_back( po.str() ); + ulCloseDir( od ); + } } - } else { - if (od != NULL) { - pt.add(po.str()); - ulCloseDir(od); - } - fg_scenery = pt.str(); - ulCloseDir(td); } } diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 52ee7deb6..1446e0921 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -106,8 +106,8 @@ private: // Root of FlightGear data tree string fg_root; - // Root of FlightGear scenery tree - string fg_scenery; + // Roots of FlightGear scenery tree + string_list fg_scenery; // Fullscreen mode for old 3DFX cards. #if defined(FX) && defined(XMESA) @@ -236,7 +236,7 @@ public: inline const string &get_fg_root () const { return fg_root; } void set_fg_root (const string &root); - inline const string &get_fg_scenery () const { return fg_scenery; } + inline const string_list &get_fg_scenery () const { return fg_scenery; } void set_fg_scenery (const string &scenery); #if defined(FX) && defined(XMESA) diff --git a/src/Scenery/FGTileLoader.cxx b/src/Scenery/FGTileLoader.cxx index 6d247cb92..255e76b85 100644 --- a/src/Scenery/FGTileLoader.cxx +++ b/src/Scenery/FGTileLoader.cxx @@ -88,22 +88,12 @@ FGTileLoader::add( FGTileEntry* tile ) { /** * Initialise tile_path here and not in ctor to avoid problems - * with the initialastion order of global objects. + * with the initialisation order of global objects. */ static bool beenhere = false; - if (!beenhere) - { - if ( !globals->get_fg_scenery().empty() ) { - tile_path = globals->get_fg_scenery(); - } else { - SGPath tmp; - tmp.set( globals->get_fg_root() ); - tmp.append( "Scenery/Terrain" ); - tmp.add(globals->get_fg_root() ); - tmp.append( "Scenery/Objects" ); - tile_path = tmp.str(); - } - beenhere = true; + if (!beenhere) { + tile_path = globals->get_fg_scenery(); + beenhere = true; } tile_load_queue.push( tile ); diff --git a/src/Scenery/FGTileLoader.hxx b/src/Scenery/FGTileLoader.hxx index 54e8be927..3d912fa75 100644 --- a/src/Scenery/FGTileLoader.hxx +++ b/src/Scenery/FGTileLoader.hxx @@ -109,9 +109,9 @@ private: #endif /** - * Base name of directory containing tile data file. + * Base names of directories containing tile data files. */ - string tile_path; + string_list tile_path; #if defined(ENABLE_THREADS) && ENABLE_THREADS /** diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index 3076b32de..6b132e7ee 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -662,29 +662,24 @@ bool FGTileEntry::obj_load( const string& path, void -FGTileEntry::load( const string &base_path, bool is_base ) +FGTileEntry::load( const string_list &path_list, bool is_base ) { - SG_LOG( SG_TERRAIN, SG_INFO, "load() base search path = " - << base_path ); - bool found_tile_base = false; - string_list search = sgPathSplit( base_path ); - // obj_load() will generate ground lighting for us ... ssgVertexArray *light_pts = new ssgVertexArray( 100 ); ssgBranch* new_tile = new ssgBranch; unsigned int i = 0; - while ( i < search.size() ) { + while ( i < path_list.size() ) { bool has_base = false; // Generate names for later use string index_str = tile_bucket.gen_index_str(); - SGPath tile_path = search[i]; + SGPath tile_path = path_list[i]; tile_path.append( tile_bucket.gen_base_path() ); SGPath basename = tile_path; @@ -918,7 +913,7 @@ FGTileEntry::load( const string &base_path, bool is_base ) ssgBranch *geometry = new ssgBranch; Point3D c; double br; - if ( sgGenTile( search[0], tile_bucket, &c, &br, + if ( sgGenTile( path_list[0], tile_bucket, &c, &br, globals->get_matlib(), geometry ) ) { center = c; diff --git a/src/Scenery/tileentry.hxx b/src/Scenery/tileentry.hxx index 2bf8130b9..dfb16965a 100644 --- a/src/Scenery/tileentry.hxx +++ b/src/Scenery/tileentry.hxx @@ -227,7 +227,7 @@ public: * @param base name of directory containing tile data file. * @param is_base is this a base terrain object for which we should generate * random ground light points */ - void load( const string &base_path, bool is_base ); + void load( const string_list &base_path, bool is_base ); /** * Return true if the tile entry is loaded, otherwise return false