From 52f39abc6b3462b385602f9d65e44e3e7d837bf7 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 5 Jan 2016 22:04:19 -0600 Subject: [PATCH] Apply /sim/speed-up to general subsystem dt - 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 | 4 ++-- src/FDM/flight.cxx | 20 ++++++------------- src/FDM/flight.hxx | 2 -- .../inst_vertical_speed_indicator.cxx | 11 +--------- .../inst_vertical_speed_indicator.hxx | 1 - .../vertical_speed_indicator.cxx | 4 ---- .../vertical_speed_indicator.hxx | 1 - src/Time/TimeManager.cxx | 3 ++- 8 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/Aircraft/replay.cxx b/src/Aircraft/replay.cxx index c77cea607..621319bec 100644 --- a/src/Aircraft/replay.cxx +++ b/src/Aircraft/replay.cxx @@ -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) { diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index 91a2b1334..bd9be3aa1 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -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 diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index 01ee34ccc..5eebb5799 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -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 diff --git a/src/Instrumentation/inst_vertical_speed_indicator.cxx b/src/Instrumentation/inst_vertical_speed_indicator.cxx index 639b95025..c1b8f90b9 100644 --- a/src/Instrumentation/inst_vertical_speed_indicator.cxx +++ b/src/Instrumentation/inst_vertical_speed_indicator.cxx @@ -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; diff --git a/src/Instrumentation/inst_vertical_speed_indicator.hxx b/src/Instrumentation/inst_vertical_speed_indicator.hxx index 10c9f00c1..dc205a7b9 100644 --- a/src/Instrumentation/inst_vertical_speed_indicator.hxx +++ b/src/Instrumentation/inst_vertical_speed_indicator.hxx @@ -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: diff --git a/src/Instrumentation/vertical_speed_indicator.cxx b/src/Instrumentation/vertical_speed_indicator.cxx index 7aa5337f9..c364a700d 100644 --- a/src/Instrumentation/vertical_speed_indicator.cxx +++ b/src/Instrumentation/vertical_speed_indicator.cxx @@ -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 diff --git a/src/Instrumentation/vertical_speed_indicator.hxx b/src/Instrumentation/vertical_speed_indicator.hxx index 7c16f27d2..e552e536c 100644 --- a/src/Instrumentation/vertical_speed_indicator.hxx +++ b/src/Instrumentation/vertical_speed_indicator.hxx @@ -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; }; diff --git a/src/Time/TimeManager.cxx b/src/Time/TimeManager.cxx index 72b9c8f9e..f3c7d5a3c 100644 --- a/src/Time/TimeManager.cxx +++ b/src/Time/TimeManager.cxx @@ -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; -- 2.39.5