]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Main / fg_init.cxx
index 22977d0a7640c7d312735ef42e3ee95950a7fc0a..9949478d420f7f723d797a650bff8be2cd616cb7 100644 (file)
@@ -63,6 +63,7 @@
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/scene/material/matlib.hxx>
 #ifdef FG_USE_CLOUDS_3D
 #  include <simgear/sky/clouds3d/SkySceneLoader.hpp>
 #  include <simgear/sky/clouds3d/SkyUtil.hpp>
@@ -97,8 +98,6 @@
 #include <Include/general.hxx>
 #include <Input/input.hxx>
 #include <Instrumentation/instrument_mgr.hxx>
-// #include <Joystick/joystick.hxx>
-#include <Objects/matlib.hxx>
 #include <Model/acmodel.hxx>
 #include <Navaids/fixlist.hxx>
 #include <Navaids/ilslist.hxx>
@@ -981,14 +980,21 @@ fgInitNav ()
 bool fgInitPosition() {
     bool set_pos = false;
 
-    // Default to starting on the ground unless one of the other
-    // conditions implies an in-air start.
-    fgSetBool("/sim/presets/onground", true);
-
     // If glideslope is specified, then calculate offset-distance or
     // altitude relative to glide slope if either of those was not
     // specified.
-    fgSetDistOrAltFromGlideSlope();
+    if ( fgGetDouble("/sim/presets/glideslope-deg") > 0.1 ) {
+        fgSetDistOrAltFromGlideSlope();
+    }
+
+    // Select ground or air start depending on if an altitude is
+    // specified (this choice can be refined later based on other
+    // input.)
+    if ( fgGetDouble("/sim/presets/altitude-ft") > -9990.0 ) {
+        fgSetBool("/sim/presets/onground", false);
+    } else {
+        fgSetBool("/sim/presets/onground", true);
+    }
 
     // If we have an explicit, in-range lon/lat, don't change it, just use it.
     // If not, check for an airport-id and use that.
@@ -1042,33 +1048,18 @@ bool fgInitPosition() {
     if ( !set_pos && !vor.empty() ) {
         // a VOR is requested
         if ( fgSetPosFromNAV( vor, vor_freq ) ) {
-            if ( fgGetDouble("/sim/presets/altitude-ft") > -9990.0 ) {
-                fgSetBool("/sim/presets/onground", false);
-            } else {
-                fgSetBool("/sim/presets/onground", true);
-            }
             set_pos = true;
         }
     }
     if ( !set_pos && !ndb.empty() ) {
         // an NDB is requested
         if ( fgSetPosFromNAV( ndb, ndb_freq ) ) {
-            if ( fgGetDouble("/sim/presets/altitude-ft") > -9990.0 ) {
-                fgSetBool("/sim/presets/onground", false);
-            } else {
-                fgSetBool("/sim/presets/onground", true);
-            }
             set_pos = true;
         }
     }
     if ( !set_pos && !fix.empty() ) {
         // a Fix is requested
         if ( fgSetPosFromFix( fix ) ) {
-            if ( fgGetDouble("/sim/presets/altitude-ft") > -9990.0 ) {
-                fgSetBool("/sim/presets/onground", false);
-            } else {
-                fgSetBool("/sim/presets/onground", true);
-            }
             set_pos = true;
         }
     }
@@ -1323,7 +1314,7 @@ bool fgInitSubsystems() {
 
     SGPath mpath( globals->get_fg_root() );
     mpath.append( "materials.xml" );
-    if ( ! material_lib.load( mpath.str() ) ) {
+    if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str()) ) {
         SG_LOG( SG_GENERAL, SG_ALERT, "Error loading material lib!" );
         exit(-1);
     }
@@ -1539,7 +1530,7 @@ bool fgInitSubsystems() {
     // Initialize the sound subsystem.
     ////////////////////////////////////////////////////////////////////
 
-    globals->set_soundmgr(new SoundMgr);
+    globals->set_soundmgr(new SGSoundMgr);
     globals->get_soundmgr()->init();
     globals->get_soundmgr()->bind();