From: James Turner Date: Sat, 16 Nov 2013 11:58:55 +0000 (+0000) Subject: Environment manager: use aircraft_pos helper X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0191b597e7c837017d8e7c7c0d576218f47754b0;p=flightgear.git Environment manager: use aircraft_pos helper --- diff --git a/src/Environment/environment_mgr.cxx b/src/Environment/environment_mgr.cxx index 9a46f15d1..9b456a9a4 100644 --- a/src/Environment/environment_mgr.cxx +++ b/src/Environment/environment_mgr.cxx @@ -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 diff --git a/src/Environment/environment_mgr.hxx b/src/Environment/environment_mgr.hxx index cc99ff8c1..edbeb57c9 100644 --- a/src/Environment/environment_mgr.hxx +++ b/src/Environment/environment_mgr.hxx @@ -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; diff --git a/src/Main/positioninit.cxx b/src/Main/positioninit.cxx index 816e99783..ee45af498 100644 --- a/src/Main/positioninit.cxx +++ b/src/Main/positioninit.cxx @@ -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; }