]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment.cxx
Fix line endings
[flightgear.git] / src / Environment / environment.cxx
index 47e4d061f58959d27868c5e4c0fadd92454c8888..bd0f8039b680589e14c99970022d924d466addbf 100644 (file)
@@ -36,6 +36,7 @@
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/interpolater.hxx>
+#include <simgear/environment/visual_enviro.hxx>
 
 #include <Main/fg_props.hxx>
 #include "environment.hxx"
@@ -234,6 +235,12 @@ FGEnvironment::get_temperature_degc () const
   return temperature_degc;
 }
 
+double
+FGEnvironment::get_temperature_degf () const
+{
+  return (temperature_degc * 9.0 / 5.0) + 32.0;
+}
+
 double
 FGEnvironment::get_dewpoint_sea_level_degc () const
 {
@@ -297,6 +304,9 @@ FGEnvironment::get_wind_from_down_fps () const
 double
 FGEnvironment::get_turbulence_magnitude_norm () const
 {
+  if( sgEnviro.get_turbulence_enable_state() )
+    if (fgGetBool("/environment/params/real-world-weather-fetch") == true)
+      return sgEnviro.get_cloud_turbulence();
   return turbulence_magnitude_norm;
 }
 
@@ -433,7 +443,7 @@ FGEnvironment::_recalc_hdgspd ()
   double angle_rad;
 
   if (wind_from_east_fps == 0) {
-    angle_rad = (wind_from_north_fps >= 0 ? SGD_PI/2 : -SGD_PI/2);
+    angle_rad = (wind_from_north_fps >= 0 ? SGD_PI_2 : -SGD_PI_2);
   } else {
     angle_rad = atan(wind_from_north_fps/wind_from_east_fps);
   }
@@ -442,12 +452,22 @@ FGEnvironment::_recalc_hdgspd ()
     wind_from_heading_deg = 90 - wind_from_heading_deg;
   else
     wind_from_heading_deg = 270 - wind_from_heading_deg;
+
+#if 0
+  // FIXME: Windspeed can become negative with these formulas.
+  //        which can cause problems for animations that rely
+  //        on the windspeed property.
   if (angle_rad == 0)
     wind_speed_kt = fabs(wind_from_east_fps
                         * SG_METER_TO_NM * SG_FEET_TO_METER * 3600);
   else
     wind_speed_kt = (wind_from_north_fps / sin(angle_rad))
       * SG_METER_TO_NM * SG_FEET_TO_METER * 3600;
+#else
+  wind_speed_kt = sqrt(wind_from_north_fps * wind_from_north_fps +
+                       wind_from_east_fps * wind_from_east_fps) 
+                  * SG_METER_TO_NM * SG_FEET_TO_METER * 3600;
+#endif
 }
 
 void