]> git.mxchange.org Git - flightgear.git/commitdiff
scenery: The tile entries load callback is not needed anymore.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Thu, 15 Mar 2012 18:04:55 +0000 (19:04 +0100)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Thu, 15 Mar 2012 18:39:07 +0000 (19:39 +0100)
The stg loader can do this itself.

src/Main/fgviewer.cxx
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx
utils/fgviewer/fgviewer.cxx

index 99bdd8e65319fac1a692fdd6c8437a0d530b2e00..acf6d9c44510ac1065299d1545e6b757d4c13224 100644 (file)
 #include "globals.hxx"
 #include "options.hxx"
 
-class DummyLoadHelper : public simgear::ModelLoadHelper {
-public:
-    virtual osg::Node *loadTileModel(const string& modelPath, bool)
-    {
-        try {
-            SGSharedPtr<SGPropertyNode> 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);
index e0b59d4fc1efe03c0c77a079509a22589e59c1e8..a61aaaae834779c21c7432a2f74c776007d88f67 100644 (file)
@@ -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.)
index fcc23d3518411f4e3324b13864e4ebb80e515466..2d83486583f9de620b4ece41da612cf90251392f 100644 (file)
@@ -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();
 };
index bb6140fa25c5783ac1410525abb3a45650a4bb96..d90a91cbb9b9332cdc0bee324ebedb149e688b1c 100644 (file)
@@ -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);