From 217d612d6a3e2c0d6072edd0a9db55df6c90e55a Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Sun, 24 Oct 2021 14:24:32 +0100 Subject: [PATCH] src/Time/TimeManager.*: fixed bug when transitioning to simple-time. We need to set _firstUpdate when /sim/time/simple-time/enabled changes to true, otherwise there can be a delay before the FDM carries on. --- src/Time/TimeManager.cxx | 7 ++++++- src/Time/TimeManager.hxx | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Time/TimeManager.cxx b/src/Time/TimeManager.cxx index e32827620..bb9c3693d 100644 --- a/src/Time/TimeManager.cxx +++ b/src/Time/TimeManager.cxx @@ -382,7 +382,12 @@ void TimeManager::computeTimeDeltasSimple(double& simDt, double& realDt) void TimeManager::computeTimeDeltas(double& simDt, double& realDt) { - if (_simpleTimeEnabled->getBoolValue()) { + bool simple_time = _simpleTimeEnabled->getBoolValue(); + if (simple_time != _simpleTimeEnabledPrev) { + _simpleTimeEnabledPrev = simple_time; + _firstUpdate = true; + } + if (simple_time) { computeTimeDeltasSimple(simDt, realDt); return; } diff --git a/src/Time/TimeManager.hxx b/src/Time/TimeManager.hxx index 27f6948ec..f173e38bf 100644 --- a/src/Time/TimeManager.hxx +++ b/src/Time/TimeManager.hxx @@ -128,6 +128,7 @@ private: SGPropertyNode_ptr _modelHz; SGPropertyNode_ptr _timeDelta, _simTimeDelta; + bool _simpleTimeEnabledPrev = false; SGPropertyNode_ptr _simpleTimeEnabled; SGPropertyNode_ptr _simpleTimeUtc; SGPropertyNode_ptr _simpleTimeFdm;