]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Reset: clear effects cache
[flightgear.git] / src / Main / fg_init.cxx
index d131d1e9b1b04d9b166470199f54552a91ed44ad..67a7cb583700f68c497516d4146f4475fe7ba516 100644 (file)
@@ -64,6 +64,7 @@
 
 #include <simgear/scene/model/modellib.hxx>
 #include <simgear/scene/material/matlib.hxx>
+#include <simgear/scene/material/Effect.hxx>
 #include <simgear/scene/model/particles.hxx>
 #include <simgear/scene/tsync/terrasync.hxx>
 
@@ -449,7 +450,7 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
         options->init(argc, argv, dataPath);
     }
     
-    bool loadDefaults = flightgear::Options::sharedInstance()->shouldLoadDefaultConfig();
+    bool loadDefaults = options->shouldLoadDefaultConfig();
     if (loadDefaults) {
       // Read global preferences from $FG_ROOT/preferences.xml
       SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
@@ -469,22 +470,25 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
     } else {
       SG_LOG(SG_GENERAL, SG_INFO, "not reading default configuration files");
     }// of no-default-config selected
-  
-    // Scan user config files and command line for a specified aircraft.
-    options->initAircraft();
+    
+    return flightgear::FG_OPTIONS_OK;
+}
 
+int fgInitAircraft(bool reinit)
+{
+    // Scan user config files and command line for a specified aircraft.
+    if (!reinit) {
+        flightgear::Options::sharedInstance()->initAircraft();
+    }
+    
     FindAndCacheAircraft f(globals->get_props());
     if (!f.loadAircraft()) {
-      return flightgear::FG_OPTIONS_ERROR;
+        return flightgear::FG_OPTIONS_ERROR;
     }
-
-    // parse options after loading aircraft to ensure any user
-    // overrides of defaults are honored.
-    return options->processOptions();
+    
+    return flightgear::FG_OPTIONS_OK;
 }
 
-
-
 /**
  * Initialize vor/ndb/ils/fix list management and query systems (as
  * well as simple airport db list)
@@ -615,13 +619,11 @@ void fgCreateSubsystems(bool duringReset) {
     // Initialize the material property subsystem.
     ////////////////////////////////////////////////////////////////////
 
-    if (!duringReset) {
-        SGPath mpath( globals->get_fg_root() );
-        mpath.append( fgGetString("/sim/rendering/materials-file") );
-        if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str(),
-                globals->get_props()) ) {
-           throw sg_io_exception("Error loading materials file", mpath);
-        }
+    SGPath mpath( globals->get_fg_root() );
+    mpath.append( fgGetString("/sim/rendering/materials-file") );
+    if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str(),
+            globals->get_props()) ) {
+       throw sg_io_exception("Error loading materials file", mpath);
     }
     
     globals->add_subsystem( "http", new FGHTTPClient );
@@ -980,11 +982,22 @@ void fgStartNewReset()
     osg::ref_ptr<flightgear::FGEventHandler> eventHandler = render->getEventHandler();
     
     globals->set_renderer(NULL);
-    simgear::SGModelLib::resetPropertyRoot();
+    globals->set_matlib(NULL);
+    globals->set_chatter_queue(NULL);
     
+    simgear::clearEffectCache();
+    simgear::SGModelLib::resetPropertyRoot();
+        
     globals->resetPropertyRoot();
     globals->restoreInitialState();
     
+    fgInitConfig(0, NULL, true);
+    fgInitGeneral(); // all of this?
+    
+    fgGetNode("/sim")->removeChild("aircraft-dir");    
+    fgInitAircraft(true);
+    flightgear::Options::sharedInstance()->processOptions();
+    
     render = new FGRenderer;
     render->setEventHandler(eventHandler);
     globals->set_renderer(render);
@@ -996,7 +1009,7 @@ void fgStartNewReset()
     flightgear::CameraGroup::buildDefaultGroup(viewer.get());
 
     fgOSResetProperties();
-    fgInitConfig(0, NULL, true);
+
     
 // init some things manually
 // which do not follow the regular init pattern
@@ -1004,6 +1017,8 @@ void fgStartNewReset()
     globals->get_event_mgr()->init();
     globals->get_event_mgr()->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true));
     
+    globals->set_matlib( new SGMaterialLib );
+    
 // terra-sync needs the property tree root, pass it back in
     simgear::SGTerraSync* terra_sync = static_cast<simgear::SGTerraSync*>(subsystemManger->get_subsystem("terrasync"));
     terra_sync->setRoot(globals->get_props());