From: Mathias Froehlich Date: Thu, 15 Mar 2012 18:04:55 +0000 (+0100) Subject: scenery: The tile entries load callback is not needed anymore. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=44c716bb03a54950f9454b07a4e0656122911d75;p=flightgear.git scenery: The tile entries load callback is not needed anymore. The stg loader can do this itself. --- diff --git a/src/Main/fgviewer.cxx b/src/Main/fgviewer.cxx index 99bdd8e65..acf6d9c44 100644 --- a/src/Main/fgviewer.cxx +++ b/src/Main/fgviewer.cxx @@ -38,21 +38,6 @@ #include "globals.hxx" #include "options.hxx" -class DummyLoadHelper : public simgear::ModelLoadHelper { -public: - virtual osg::Node *loadTileModel(const string& modelPath, bool) - { - try { - SGSharedPtr prop = new SGPropertyNode; - return simgear::SGModelLib::loadModel(modelPath, - globals->get_props()); - } catch (...) { - std::cerr << "Error loading \"" << modelPath << "\"" << std::endl; - return 0; - } - } -}; - class GraphDumpHandler : public osgGA::GUIEventHandler { public: @@ -120,8 +105,6 @@ fgviewerMain(int argc, char** argv) { sgUserDataInit(0); - DummyLoadHelper dummyLoadHelper; - simgear::TileEntry::setModelLoadHelper(&dummyLoadHelper); // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc, argv); diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index e0b59d4fc..a61aaaae8 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -48,9 +48,7 @@ #include "SceneryPager.hxx" #include "tilemgr.hxx" -using std::for_each; using flightgear::SceneryPager; -using simgear::SGModelLib; using simgear::TileEntry; using simgear::TileCache; @@ -89,8 +87,9 @@ void FGTileMgr::init() { const string_list &sc = globals->get_fg_scenery(); fp.clear(); std::copy(sc.begin(), sc.end(), back_inserter(fp)); - - TileEntry::setModelLoadHelper(this); + _options->setPluginStringData("SimGear::FG_ROOT", globals->get_fg_root()); + if (!_disableNasalHooks->getBoolValue()) + _options->setModelData(new FGNasalModelDataProxy); reinit(); } @@ -220,48 +219,6 @@ void FGTileMgr::schedule_needed(const SGBucket& curr_bucket, double vis) } } -osg::Node* -FGTileMgr::loadTileModel(const string& modelPath, bool cacheModel) -{ - SGPath fullPath = modelPath; - if (fullPath.isRelative()) { - string_list sc = globals->get_fg_scenery(); - - for (string_list_iterator it = sc.begin(); it != sc.end(); ++it) { - // fg_senery contains empty strings as "markers" (see FGGlobals::set_fg_scenery) - if (!it->empty()) { - SGPath tmpPath(*it); - tmpPath.append(modelPath); - if (tmpPath.exists()) { - fullPath = tmpPath; - break; - } - } - } - } - osg::Node* result = 0; - try { - if(cacheModel) - result = - SGModelLib::loadModel(fullPath.str(), globals->get_props(), - _disableNasalHooks->getBoolValue() ? NULL : new FGNasalModelDataProxy); - else - { - result= - SGModelLib::loadDeferredModel(fullPath.str(), globals->get_props(), - _disableNasalHooks->getBoolValue() ? NULL : new FGNasalModelDataProxy); - } - } catch (const sg_io_exception& exc) { - string m(exc.getMessage()); - m += " "; - m += exc.getLocation().asString(); - SG_LOG( SG_TERRAIN, SG_ALERT, m ); - } catch (const sg_exception& exc) { // XXX may be redundant - SG_LOG( SG_TERRAIN, SG_ALERT, exc.getMessage()); - } - return result; -} - /** * Update the various queues maintained by the tilemagr (private * internal function, do not call directly.) diff --git a/src/Scenery/tilemgr.hxx b/src/Scenery/tilemgr.hxx index fcc23d351..2d8348658 100644 --- a/src/Scenery/tilemgr.hxx +++ b/src/Scenery/tilemgr.hxx @@ -42,7 +42,7 @@ class SGTerraSync; class SGReaderWriterOptions; } -class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper { +class FGTileMgr : public SGSubsystem { private: @@ -111,9 +111,6 @@ public: /// lat and lon are expected to be in degrees. bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0); - // Load a model for a tile - osg::Node* loadTileModel(const std::string& modelPath, bool cacheModel); - // Returns true if tiles around current view position have been loaded bool isSceneryLoaded(); }; diff --git a/utils/fgviewer/fgviewer.cxx b/utils/fgviewer/fgviewer.cxx index bb6140fa2..d90a91cbb 100644 --- a/utils/fgviewer/fgviewer.cxx +++ b/utils/fgviewer/fgviewer.cxx @@ -55,7 +55,6 @@ main(int argc, char** argv) // pulled in by the linker ... // FIXME: make that more explicit clear and call an initialization function simgear::ModelRegistry::instance(); - simgear::TileEntry::setModelLoadHelper(NULL); // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc, argv);