]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/flight.cxx
Adapt to revised logging API.
[flightgear.git] / src / FDM / flight.cxx
index b4027b14b2867e337505f430ed847e14dbb37d03..c65a009a6aaf80a2542fe16aa96eda8406370ce2 100644 (file)
@@ -29,6 +29,7 @@
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/timing/timestamp.hxx>
+#include <simgear/scene/material/mat.hxx>
 
 #include <Scenery/scenery.hxx>
 #include <Main/globals.hxx>
@@ -63,14 +64,16 @@ int
 FGInterface::_calc_multiloop (double dt)
 {
   // Since some time the simulation time increments we get here are
-  // already a multiple of the basic update freqency.
+  // already a multiple of the basic update frequency.
   // So, there is no need to do our own multiloop rounding with all bad
   // roundoff problems when we already have nearly accurate values.
   // Only the speedup thing must be still handled here
   int hz = fgGetInt("/sim/model-hz");
-  int multiloop = SGMiscd::roundToInt(dt*hz);
-  int speedup = fgGetInt("/sim/speed-up");
-  return multiloop * speedup;
+  double speedup = fgGetDouble("/sim/speed-up");
+  double loops = dt * hz * speedup + delta_loops;
+  int iloops = SGMiscd::roundToInt(loops);
+  delta_loops = loops-iloops; // delta_loops required for speed-ups < 1 (to do one iteration every n-th step)
+  return iloops;
 }
 
 
@@ -118,6 +121,7 @@ FGInterface::_setup ()
     climb_rate=0;
     altitude_agl=0;
     track=0;
+    delta_loops = 0.0;
 }
 
 void
@@ -158,6 +162,8 @@ FGInterface::common_init ()
     double ground_elev_m = get_groundlevel_m(lat, lon, alt_m);
     double ground_elev_ft = ground_elev_m * SG_METER_TO_FEET;
     _set_Runway_altitude ( ground_elev_ft );
+
+    // Set aircraft altitude
     if ( fgGetBool("/sim/presets/onground") || alt_ft < ground_elev_ft ) {
         fgSetDouble("/position/altitude-ft", ground_elev_ft + 0.1);
         set_Altitude( ground_elev_ft + 0.1);
@@ -218,8 +224,11 @@ FGInterface::common_init ()
     if ( fgHasNode("/sim/presets/glideslope-deg") )
         set_Gamma_vert_rad( fgGetDouble("/sim/presets/glideslope-deg")
                               * SGD_DEGREES_TO_RADIANS );
-    else if ( fgHasNode( "/velocities/vertical-speed-fps") )
-        set_Climb_Rate( fgGetDouble("/velocities/vertical-speed-fps") );
+    else if ( fgHasNode("/sim/presets/speed-set") &&
+              fgHasNode( "/sim/presets/vertical-speed-fps") )
+    {
+        set_Climb_Rate( fgGetDouble("/sim/presets/vertical-speed-fps") );
+    }
 
     SG_LOG( SG_FLIGHT, SG_INFO, "End common FDM init" );
 }
@@ -687,7 +696,7 @@ bool
 FGInterface::get_agl_m(double t, const double pt[3], double max_altoff,
                        double contact[3], double normal[3],
                        double linearVel[3], double angularVel[3],
-                       SGMaterial const*& material, simgear::BVHNode::Id& id)
+                       simgear::BVHMaterial const*& material, simgear::BVHNode::Id& id)
 {
   SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
   SGVec3d _contact, _normal, _linearVel, _angularVel;
@@ -710,7 +719,7 @@ bool
 FGInterface::get_agl_ft(double t, const double pt[3], double max_altoff,
                         double contact[3], double normal[3],
                         double linearVel[3], double angularVel[3],
-                        SGMaterial const*& material, simgear::BVHNode::Id& id)
+                        simgear::BVHMaterial const*& material, simgear::BVHNode::Id& id)
 {
   // Convert units and do the real work.
   SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
@@ -736,10 +745,11 @@ bool
 FGInterface::get_nearest_m(double t, const double pt[3], double maxDist,
                            double contact[3], double normal[3],
                            double linearVel[3], double angularVel[3],
-                           SGMaterial const*& material,
+                           simgear::BVHMaterial const*& material,
                            simgear::BVHNode::Id& id)
 {
   SGVec3d _contact, _linearVel, _angularVel;
+  material = 0;
   if (!ground_cache.get_nearest(t, SGVec3d(pt), maxDist, _contact, _linearVel,
                                 _angularVel, id, material))
       return false;
@@ -754,10 +764,11 @@ bool
 FGInterface::get_nearest_ft(double t, const double pt[3], double maxDist,
                             double contact[3], double normal[3],
                             double linearVel[3], double angularVel[3],
-                            SGMaterial const*& material,
+                            simgear::BVHMaterial const*& material,
                             simgear::BVHNode::Id& id)
 {
   SGVec3d _contact, _linearVel, _angularVel;
+  material = 0;
   if (!ground_cache.get_nearest(t, SG_FEET_TO_METER*SGVec3d(pt),
                                 SG_FEET_TO_METER*maxDist, _contact, _linearVel,
                                 _angularVel, id, material))
@@ -819,7 +830,7 @@ FGInterface::get_groundlevel_m(const SGGeod& geod)
   }
   
   double contact[3], normal[3], vel[3], angvel[3];
-  const SGMaterial* material;
+  const simgear::BVHMaterial* material;
   simgear::BVHNode::Id id;
   // Ignore the return value here, since it just tells us if
   // the returns stem from the groundcache or from the coarse