diff --git a/src/Environment/environment.cxx b/src/Environment/environment.cxx index 212e51d85..9a5755e3d 100644 --- a/src/Environment/environment.cxx +++ b/src/Environment/environment.cxx @@ -140,6 +140,7 @@ void FGEnvironment::_init() wind_from_down_fps = 0; thermal_lift_fps = 0; ridge_lift_fps= 0; + local_weather_lift_fps=0; altitude_half_to_sun_m = 1000; altitude_tropo_top_m = 10000; #ifdef USING_TABLES @@ -182,6 +183,7 @@ FGEnvironment::copy (const FGEnvironment &env) wind_from_down_fps = env.wind_from_down_fps; thermal_lift_fps = env.thermal_lift_fps; ridge_lift_fps= env.ridge_lift_fps; + local_weather_lift_fps = env.local_weather_lift_fps; turbulence_magnitude_norm = env.turbulence_magnitude_norm; turbulence_rate_hz = env.turbulence_rate_hz; } @@ -238,6 +240,7 @@ FGEnvironment::read (const SGPropertyNode * node) maybe_copy_value(this, node, "turbulence/rate-hz", &FGEnvironment::set_turbulence_rate_hz); + // calculate derived properties here to avoid duplicate expensive computations _recalc_ne(); _recalc_alt_pt(); @@ -369,6 +372,12 @@ FGEnvironment::get_ridge_lift_fps () const return ridge_lift_fps; } +double +FGEnvironment::get_local_weather_lift_fps () const +{ + return local_weather_lift_fps; +} + double FGEnvironment::get_turbulence_magnitude_norm () const { @@ -524,7 +533,16 @@ FGEnvironment::set_ridge_lift_fps (double ri) ridge_lift_fps = ri; if( live_update ) { _recalc_updraft(); + } } + +void +FGEnvironment::set_local_weather_lift_fps (double lwl) +{ + local_weather_lift_fps = lwl; + if( live_update ) { + _recalc_updraft(); + } } void @@ -618,7 +636,7 @@ FGEnvironment::_recalc_ne () void FGEnvironment::_recalc_updraft () { - wind_from_down_fps = thermal_lift_fps + ridge_lift_fps ; + wind_from_down_fps = thermal_lift_fps + ridge_lift_fps + local_weather_lift_fps ; } // Intended to help with the interpretation of METAR data, diff --git a/src/Environment/environment.hxx b/src/Environment/environment.hxx index d9543d5ab..c27013226 100644 --- a/src/Environment/environment.hxx +++ b/src/Environment/environment.hxx @@ -72,6 +72,7 @@ public: virtual double get_wind_from_down_fps () const; virtual double get_thermal_lift_fps () const; virtual double get_ridge_lift_fps () const; + virtual double get_local_weather_lift_fps () const; virtual double get_turbulence_magnitude_norm () const; virtual double get_turbulence_rate_hz () const; @@ -92,6 +93,7 @@ public: virtual void set_wind_from_down_fps (double d); virtual void set_thermal_lift_fps (double th); virtual void set_ridge_lift_fps (double ri); + virtual void set_local_weather_lift_fps (double lwl); virtual void set_turbulence_magnitude_norm (double t); virtual void set_turbulence_rate_hz (double t); @@ -147,6 +149,7 @@ private: double wind_from_down_fps; double thermal_lift_fps; double ridge_lift_fps; + double local_weather_lift_fps; bool live_update; diff --git a/src/Environment/environment_mgr.cxx b/src/Environment/environment_mgr.cxx index e15ecae20..acf20b861 100644 --- a/src/Environment/environment_mgr.cxx +++ b/src/Environment/environment_mgr.cxx @@ -166,9 +166,12 @@ FGEnvironmentMgr::bind () fgSetArchivable("/environment/thermal-lift-fps"); fgTie("/environment/ridge-lift-fps", _environment, &FGEnvironment::get_ridge_lift_fps, - &FGEnvironment::set_ridge_lift_fps); + &FGEnvironment::set_ridge_lift_fps); fgSetArchivable("/environment/ridge-lift-fps"); - + + fgTie("/environment/local-weather-lift", _environment, + &FGEnvironment::get_local_weather_lift_fps); //read-only + fgTie("/environment/turbulence/magnitude-norm", _environment, &FGEnvironment::get_turbulence_magnitude_norm, &FGEnvironment::set_turbulence_magnitude_norm); @@ -255,6 +258,7 @@ FGEnvironmentMgr::unbind () fgUntie("/environment/thermal-lift-fps"); fgUntie("/environment/ridge-lift-fps"); + fgUntie("/environment/local-weather-lift"); fgUntie("/environment/atmosphere/altitude-half-to-sun"); fgUntie("/environment/atmosphere/altitude-troposphere-top"); @@ -293,6 +297,7 @@ FGEnvironmentMgr::update (double dt) _environment->get_wind_from_east_fps(), _environment->get_wind_from_down_fps()); _environment->set_elevation_ft(fgGetDouble("/position/altitude-ft")); + _environment->set_local_weather_lift_fps(fgGetDouble("/local-weather/current/thermal-lift")); osg::Vec3 windVec(-_environment->get_wind_from_north_fps(), -_environment->get_wind_from_east_fps(), _environment->get_wind_from_down_fps());