]> git.mxchange.org Git - flightgear.git/commitdiff
Environment manager: use aircraft_pos helper
authorJames Turner <zakalawe@mac.com>
Sat, 16 Nov 2013 11:58:55 +0000 (11:58 +0000)
committerJames Turner <zakalawe@mac.com>
Sat, 16 Nov 2013 12:28:51 +0000 (12:28 +0000)
src/Environment/environment_mgr.cxx
src/Environment/environment_mgr.hxx
src/Main/positioninit.cxx

index 9a46f15d12a70a857a8b78007f62365fc6bfa782..9b456a9a413178c8fc27051ccb97a5f7a1d8cc74 100644 (file)
@@ -82,9 +82,6 @@ FGEnvironmentMgr::FGEnvironmentMgr () :
   _environment(new FGEnvironment()),
   fgClouds(new FGClouds()),
   _cloudLayersDirty(true),
-  _altitude_n(fgGetNode("/position/altitude-ft", true)),
-  _longitude_n(fgGetNode( "/position/longitude-deg", true )),
-  _latitude_n( fgGetNode( "/position/latitude-deg", true )),
   _3dCloudsEnableListener(new FG3DCloudsListener(fgClouds) ),
   _sky(globals->get_renderer()->getSky())
 {
@@ -119,15 +116,6 @@ SGSubsystem::InitStatus FGEnvironmentMgr::incrementalInit()
   InitStatus r = SGSubsystemGroup::incrementalInit();
   if (r == INIT_DONE) {
     fgClouds->Init();
-    
-    // FIXME: is this really part of the environment_mgr?
-    // Initialize the longitude, latitude and altitude to the initial position
-    // of the aircraft so that the atmospheric properties (pressure, temperature
-    // and density) can be initialized accordingly.
-    _altitude_n->setDoubleValue(fgGetDouble("/sim/presets/altitude-ft"));
-    _longitude_n->setDoubleValue(fgGetDouble("/sim/presets/longitude-deg"));
-    _latitude_n->setDoubleValue(fgGetDouble("/sim/presets/latitude-deg"));
-    
     globals->get_event_mgr()->addTask("updateClosestAirport", this,
                                       &FGEnvironmentMgr::updateClosestAirport, 30 );
   }
@@ -257,7 +245,8 @@ FGEnvironmentMgr::update (double dt)
 {
   SGSubsystemGroup::update(dt);
 
-  _environment->set_elevation_ft( _altitude_n->getDoubleValue() );
+    SGGeod aircraftPos(globals->get_aircraft_position());
+  _environment->set_elevation_ft( aircraftPos.getElevationFt() );
 
   simgear::Particles::setWindFrom( _environment->get_wind_from_heading_deg(),
                                    _environment->get_wind_speed_kt() );
@@ -268,11 +257,7 @@ FGEnvironmentMgr::update (double dt)
 
 
   fgSetDouble( "/environment/gravitational-acceleration-mps2", 
-    Environment::Gravity::instance()->getGravity(SGGeod::fromDegFt(
-      _longitude_n->getDoubleValue(),
-      _latitude_n->getDoubleValue(),
-      _altitude_n->getDoubleValue()
-  )));
+    Environment::Gravity::instance()->getGravity(aircraftPos));
 }
 
 void
index cc99ff8c194cb2120fe153dc4e686a2d0e524c50..edbeb57c952e9d0de021d76c6d83203d8bff5e67 100644 (file)
@@ -95,9 +95,6 @@ private:
   FGEnvironment * _environment;        // always the same, for now
   FGClouds *fgClouds;
   bool _cloudLayersDirty;
-  SGPropertyNode_ptr _altitude_n;
-  SGPropertyNode_ptr _longitude_n;
-  SGPropertyNode_ptr _latitude_n;
   simgear::TiedPropertyList _tiedProperties;
   SGPropertyChangeListener * _3dCloudsEnableListener;
   SGSky* _sky;
index 816e997831fcaee8cf0fa37668f94c77a36450c2..ee45af4989f1bcdbe1137458e9c415a8a99782d5 100644 (file)
@@ -566,6 +566,11 @@ bool initPosition()
   }
   
   fgSetBool("/sim/position-finalized", false);
+
+// Initialize the longitude, latitude and altitude to the initial position
+    fgSetDouble("/position/altitude-ft", fgGetDouble("/sim/presets/altitude-ft"));
+    fgSetDouble("/position/longitude-deg", fgGetDouble("/sim/presets/longitude-deg"));
+    fgSetDouble("/position/latitude-deg", fgGetDouble("/sim/presets/latitude-deg"));
     
   return true;
 }