Melchior FRANZ:
Wouldn't it be better to prepare the whole list of paths (or two separate ones for Terrain/Objects if necessary) in FGGlobals::set_fg_scenery, and to pass the vector<string>s to FGTileEntry::load? It doesn't seem to make a lot of sense to split the path up, modify it, mount it together to one string again, and then let FGTileEntry::load split it up again. Here we go: Main/globals.cxx ================ As fg_scenery is now a string_list, we don't need initialization. Furthermore, this list is cleared with every set_fg_scenery() call. ctor: create default dir from fg_root if necessary. Otherwise check all paths of --fg-scenery/FG_SCENERY: If the path doesn't exist, ignore it. If it contains a dir Terrain and/or Objects, then only add that to the list. If it contains neither, then use the path as is. Scenery/tileentry.cxx ===================== Trivial: don't split a "base path", but use the given path_list as is. (I considered a variable name "path_list" better suited than "search".) Scenery/FGTileLoader.cxx ======================== No more fiddling with sub-paths. This has to be delivered by get_fg_scenery already.
This commit is contained in:
parent
43df8a9cc0
commit
ff9258528c
6 changed files with 46 additions and 54 deletions
|
@ -46,7 +46,6 @@ FGGlobals::FGGlobals() :
|
||||||
event_mgr( new SGEventMgr ),
|
event_mgr( new SGEventMgr ),
|
||||||
sim_time_sec( 0.0 ),
|
sim_time_sec( 0.0 ),
|
||||||
fg_root( "" ),
|
fg_root( "" ),
|
||||||
fg_scenery( "" ),
|
|
||||||
#if defined(FX) && defined(XMESA)
|
#if defined(FX) && defined(XMESA)
|
||||||
fullscreen( true ),
|
fullscreen( true ),
|
||||||
#endif
|
#endif
|
||||||
|
@ -118,34 +117,42 @@ void FGGlobals::set_fg_root (const string &root) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGGlobals::set_fg_scenery (const string &scenery) {
|
void FGGlobals::set_fg_scenery (const string &scenery) {
|
||||||
if (scenery.empty())
|
SGPath s;
|
||||||
return;
|
if (scenery.empty()) {
|
||||||
|
s.set( fg_root );
|
||||||
|
s.append( "Scenery" );
|
||||||
|
} else
|
||||||
|
s.set( scenery );
|
||||||
|
|
||||||
// TODO: Split the scenery path up into separate
|
string_list path_list = sgPathSplit( s.str() );
|
||||||
// paths (taking into account the search path separator
|
fg_scenery.clear();
|
||||||
// and test them individually.
|
|
||||||
// -EMH-
|
for (unsigned i = 0; i < path_list.size(); i++) {
|
||||||
SGPath pt( scenery ), po( scenery );
|
|
||||||
|
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");
|
pt.append("Terrain");
|
||||||
po.append("Objects");
|
po.append("Objects");
|
||||||
|
|
||||||
ulDir *td = ulOpenDir(pt.c_str());
|
ulDir *td = ulOpenDir( pt.c_str() );
|
||||||
ulDir *od = ulOpenDir(po.c_str());
|
ulDir *od = ulOpenDir( po.c_str() );
|
||||||
|
|
||||||
if (td == NULL) {
|
if (td == NULL && od == NULL)
|
||||||
if (od == NULL) {
|
fg_scenery.push_back( path_list[i] );
|
||||||
fg_scenery = scenery;
|
else {
|
||||||
} else {
|
if (td != NULL) {
|
||||||
fg_scenery = po.str();
|
fg_scenery.push_back( pt.str() );
|
||||||
ulCloseDir(od);
|
ulCloseDir( td );
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (od != NULL) {
|
if (od != NULL) {
|
||||||
pt.add(po.str());
|
fg_scenery.push_back( po.str() );
|
||||||
ulCloseDir(od);
|
ulCloseDir( od );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fg_scenery = pt.str();
|
|
||||||
ulCloseDir(td);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,8 +106,8 @@ private:
|
||||||
// Root of FlightGear data tree
|
// Root of FlightGear data tree
|
||||||
string fg_root;
|
string fg_root;
|
||||||
|
|
||||||
// Root of FlightGear scenery tree
|
// Roots of FlightGear scenery tree
|
||||||
string fg_scenery;
|
string_list fg_scenery;
|
||||||
|
|
||||||
// Fullscreen mode for old 3DFX cards.
|
// Fullscreen mode for old 3DFX cards.
|
||||||
#if defined(FX) && defined(XMESA)
|
#if defined(FX) && defined(XMESA)
|
||||||
|
@ -236,7 +236,7 @@ public:
|
||||||
inline const string &get_fg_root () const { return fg_root; }
|
inline const string &get_fg_root () const { return fg_root; }
|
||||||
void set_fg_root (const string &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);
|
void set_fg_scenery (const string &scenery);
|
||||||
|
|
||||||
#if defined(FX) && defined(XMESA)
|
#if defined(FX) && defined(XMESA)
|
||||||
|
|
|
@ -88,21 +88,11 @@ FGTileLoader::add( FGTileEntry* tile )
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Initialise tile_path here and not in ctor to avoid problems
|
* 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;
|
static bool beenhere = false;
|
||||||
if (!beenhere)
|
if (!beenhere) {
|
||||||
{
|
|
||||||
if ( !globals->get_fg_scenery().empty() ) {
|
|
||||||
tile_path = globals->get_fg_scenery();
|
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;
|
beenhere = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,9 +109,9 @@ private:
|
||||||
#endif
|
#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
|
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -662,29 +662,24 @@ bool FGTileEntry::obj_load( const string& path,
|
||||||
|
|
||||||
|
|
||||||
void
|
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;
|
bool found_tile_base = false;
|
||||||
|
|
||||||
string_list search = sgPathSplit( base_path );
|
|
||||||
|
|
||||||
// obj_load() will generate ground lighting for us ...
|
// obj_load() will generate ground lighting for us ...
|
||||||
ssgVertexArray *light_pts = new ssgVertexArray( 100 );
|
ssgVertexArray *light_pts = new ssgVertexArray( 100 );
|
||||||
|
|
||||||
ssgBranch* new_tile = new ssgBranch;
|
ssgBranch* new_tile = new ssgBranch;
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
while ( i < search.size() ) {
|
while ( i < path_list.size() ) {
|
||||||
|
|
||||||
bool has_base = false;
|
bool has_base = false;
|
||||||
|
|
||||||
// Generate names for later use
|
// Generate names for later use
|
||||||
string index_str = tile_bucket.gen_index_str();
|
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() );
|
tile_path.append( tile_bucket.gen_base_path() );
|
||||||
|
|
||||||
SGPath basename = tile_path;
|
SGPath basename = tile_path;
|
||||||
|
@ -918,7 +913,7 @@ FGTileEntry::load( const string &base_path, bool is_base )
|
||||||
ssgBranch *geometry = new ssgBranch;
|
ssgBranch *geometry = new ssgBranch;
|
||||||
Point3D c;
|
Point3D c;
|
||||||
double br;
|
double br;
|
||||||
if ( sgGenTile( search[0], tile_bucket, &c, &br,
|
if ( sgGenTile( path_list[0], tile_bucket, &c, &br,
|
||||||
globals->get_matlib(), geometry ) )
|
globals->get_matlib(), geometry ) )
|
||||||
{
|
{
|
||||||
center = c;
|
center = c;
|
||||||
|
|
|
@ -227,7 +227,7 @@ public:
|
||||||
* @param base name of directory containing tile data file.
|
* @param base name of directory containing tile data file.
|
||||||
* @param is_base is this a base terrain object for which we should generate
|
* @param is_base is this a base terrain object for which we should generate
|
||||||
* random ground light points */
|
* 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
|
* Return true if the tile entry is loaded, otherwise return false
|
||||||
|
|
Loading…
Add table
Reference in a new issue