]> git.mxchange.org Git - flightgear.git/commitdiff
Apply /sim/speed-up to general subsystem dt
authorJames Turner <zakalawe@mac.com>
Wed, 6 Jan 2016 04:04:19 +0000 (22:04 -0600)
committerJames Turner <zakalawe@mac.com>
Wed, 6 Jan 2016 05:19:28 +0000 (23:19 -0600)
- consistent with pause (freeze), /sim/speed-up is now applied to the
  dt value for all subsystems, not just the FDM and some instruments.
  For example AI traffic can now be sped-up or slowed down.
- requires both an FGData and Simgear update.

src/Aircraft/replay.cxx
src/FDM/flight.cxx
src/FDM/flight.hxx
src/Instrumentation/inst_vertical_speed_indicator.cxx
src/Instrumentation/inst_vertical_speed_indicator.hxx
src/Instrumentation/vertical_speed_indicator.cxx
src/Instrumentation/vertical_speed_indicator.hxx
src/Time/TimeManager.cxx

index c77cea6076478fd6b6a9f346e946a99b4761cb84..621319becdd55032e7a8545c2f4d48498a555a08 100644 (file)
@@ -451,7 +451,7 @@ FGReplay::update( double dt )
             }
             else
             {
-                current_time += dt * speed_up->getDoubleValue();
+                current_time += dt;
                 was_finished_already = false;
             }
             replay_time->setDoubleValue(current_time);
@@ -478,7 +478,7 @@ FGReplay::update( double dt )
         return;
 
     {
-        double new_sim_time = sim_time + dt * speed_up->getDoubleValue();
+        double new_sim_time = sim_time + dt;
         // don't record multiple records with the same timestamp (or go backwards in time)
         if (new_sim_time <= sim_time)
         {
index 91a2b13342b7c06152a9c0e8f22b6be5040e8fc3..bd9be3aa1b4cf2661730c280f8f718af26b49c65 100644 (file)
@@ -62,19 +62,13 @@ FGInterface::~FGInterface() {
 }
 
 int
-FGInterface::_calc_multiloop (double dt)
+FGInterface::_calc_multiloop (double)
 {
-  // Since some time the simulation time increments we get here are
-  // 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");
-  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;
+    // this method is now obsolete - multiloop is handled by
+    // SGSubsystemGroup; the FDM group operates with a fixed time interval
+    // (defined by /sim/model-hz), so at this level we always want to run
+    // exactly one FDM iteration
+    return 1;
 }
 
 
@@ -122,8 +116,6 @@ FGInterface::_setup ()
     _state.climb_rate=0;
     _state.altitude_agl=0;
     _state.track=0;
-    
-    delta_loops = 0.0;
 }
 
 void
index 01ee34ccc4ec8303f1bdaa28aaac3b2d52fdc1f1..5eebb579958ec203f231fb5068f19e47e634ce8c 100644 (file)
@@ -136,8 +136,6 @@ private:
     // Have we bound to the property system
     bool bound;
 
-    double delta_loops;
-
     // periodic update management variable.  This is a scheme to run
     // the fdm with a fixed delta-t.  We control how many iteration of
     // the fdm to run with the fixed dt based on the elapsed time from
index 639b950255112aa64d07dea180874fee0599305e..c1b8f90b9040649d798302342415debe3531ee20 100644 (file)
@@ -179,8 +179,6 @@ void InstVerticalSpeedIndicator::init ()
         fgGetNode("/environment/pressure-inhg", true);
     _sea_node =
         fgGetNode("/environment/pressure-sea-level-inhg", true);
-    _speed_up_node =
-        fgGetNode("/sim/speed-up", true);
     _speed_node =
         node->getNode("indicated-speed-fps", true);
     _speed_min_node =
@@ -205,14 +203,7 @@ void InstVerticalSpeedIndicator::update (double dt)
        {
            double pressure_inhg = _pressure_node->getDoubleValue();
            double sea_inhg = _sea_node->getDoubleValue();
-           double speed_up = _speed_up_node->getDoubleValue();
-           
-           // must work by speed up
-           if( speed_up > 1 )
-           {
-               dt *= speed_up;
-           }
-             
+
            // limit effect of external environment
            double rate_sea_inhg_per_s = ( sea_inhg - _internal_sea_inhg ) / dt;
            
index 10c9f00c18e954408a9b2e82852f8559e8bbd559..dc205a7b936545411afd47a2ccaf0debd1d11993 100644 (file)
@@ -41,7 +41,6 @@ class SGInterpTable;
  * /instrumentation/inst-vertical-speed-indicator/serviceable
  * /environment/pressure-inhg
  * /environment/pressure-sea-level-inhg
- * /sim/speed-up
  * /sim/freeze/master
  *
  * Output properties:
index 7aa5337f9f5cd314da3084d42bbe2592e6f6ffd3..c364a700de91cc2831131bfb254b8f22342628aa 100644 (file)
@@ -50,7 +50,6 @@ VerticalSpeedIndicator::init ()
     _speed_fpm_node = node->getChild("indicated-speed-fpm", 0, true);
     _speed_mps_node = node->getChild("indicated-speed-mps", 0, true);
     _speed_kts_node = node->getChild("indicated-speed-kts", 0, true);
-    _speed_up_node = fgGetNode("/sim/speed-up", true);
 
     reinit();
 }
@@ -74,11 +73,8 @@ VerticalSpeedIndicator::update (double dt)
     if (_serviceable_node->getBoolValue()) {
         double pressure_inHg = _pressure_node->getDoubleValue() ;
         double pressure_Pa = pressure_inHg * SG_INHG_TO_PA;
-        double speed_up = _speed_up_node->getDoubleValue();
         double Fsign = 0.;
         double orifice_mach = 0.0;
-        if( speed_up > 1 )
-            dt *= speed_up;
 
 // This is a thermodynamically correct model of a mechanical vertical speed indicator:
 // It represents an aneroid in a closed (constant volume) casing with the aneroid internal pressure = static pressure
index 7c16f27d2d124e62904c228e9ed4151f6492f0ec..e552e536c2f43aa93c3706707efafd582249c304 100644 (file)
@@ -61,7 +61,6 @@ private:
     SGPropertyNode_ptr _speed_fpm_node;
     SGPropertyNode_ptr _speed_mps_node;
     SGPropertyNode_ptr _speed_kts_node;
-    SGPropertyNode_ptr _speed_up_node;
     
 };
 
index 72b9c8f9e8740e619340e45ddbf3d9c892ff5837..f3c7d5a3cdcd6f73629b150b12f53bd675905f5d 100644 (file)
@@ -227,7 +227,8 @@ void TimeManager::computeTimeDeltas(double& simDt, double& realDt)
   if (_clockFreeze->getBoolValue() || wait_for_scenery) {
     simDt = 0;
   } else {
-    simDt = dt;
+      // sim time can be scaled
+      simDt = dt * fgGetDouble("/sim/speed-up");
   }
   
   _lastStamp = currentStamp;