]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment_mgr.cxx
Move FGEventMgr and FGSubsystemMgr over to SimGear, add SGEventMgr to FlightGear...
[flightgear.git] / src / Environment / environment_mgr.cxx
index 6edbd6ca5f5e33abefc7fdc794186df1c84fc3c6..08984463a015017c2f6f041a4b7321459836823a 100644 (file)
@@ -23,6 +23,7 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/scene/sky/sky.hxx>
 
+#include <Main/main.hxx>
 #include <Main/fg_props.hxx>
 #include <Aircraft/aircraft.hxx>
 
@@ -30,8 +31,6 @@
 #include "environment_ctrl.hxx"
 #include "environment_mgr.hxx"
 
-extern SGSky *thesky;          // FIXME: from main.cxx
-
 
 FGEnvironmentMgr::FGEnvironmentMgr ()
   : _environment(new FGEnvironment),
@@ -51,7 +50,7 @@ void
 FGEnvironmentMgr::init ()
 {
   SG_LOG( SG_GENERAL, SG_INFO, "Initializing environment subsystem");
-  FGSubsystemGroup::init();
+  SGSubsystemGroup::init();
   _update_fdm();
 }
 
@@ -59,7 +58,7 @@ void
 FGEnvironmentMgr::reinit ()
 {
   SG_LOG( SG_GENERAL, SG_INFO, "Reinitializing environment subsystem");
-  FGSubsystemGroup::reinit();
+  SGSubsystemGroup::reinit();
   _update_fdm();
 }
 
@@ -177,7 +176,7 @@ FGEnvironmentMgr::unbind ()
 void
 FGEnvironmentMgr::update (double dt)
 {
-  FGSubsystemGroup::update(dt);
+  SGSubsystemGroup::update(dt);
 
                                // FIXME: the FDMs should update themselves
   current_aircraft.fdm_state
@@ -248,8 +247,17 @@ FGEnvironmentMgr::get_cloud_layer_elevation_ft (int index) const
 void
 FGEnvironmentMgr::set_cloud_layer_elevation_ft (int index, double elevation_ft)
 {
+  FGEnvironment env = *_environment;
+  env.set_elevation_ft(elevation_ft);
+
   thesky->get_cloud_layer(index)
     ->setElevation_m(elevation_ft * SG_FEET_TO_METER);
+
+  thesky->get_cloud_layer(index)
+    ->setSpeed(env.get_wind_speed_kt() * 0.5151);      // 1 kt = 0.5151 m/s
+
+  thesky->get_cloud_layer(index)
+    ->setDirection(env.get_wind_from_heading_deg());
 }
 
 double