#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>
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");
} 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)
// 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 );
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);
flightgear::CameraGroup::buildDefaultGroup(viewer.get());
fgOSResetProperties();
- fgInitConfig(0, NULL, true);
+
// init some things manually
// which do not follow the regular init pattern
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());