TimeManager::TimeManager() :
_inited(false),
- _impl(NULL)
+ _impl(NULL),
+ _sceneryLoaded("sim/sceneryloaded"),
+ _sceneryLoadOverride("sim/sceneryloaded-override"),
+ _modelHz("sim/model-hz"),
+ _timeDelta("sim/time/delta-realtime-sec"),
+ _simTimeDelta("sim/time/delta-sec")
{
SGCommandMgr::instance()->addCommand("timeofday", do_timeofday);
}
_lastClockFreeze = _clockFreeze->getBoolValue();
}
- bool scenery_loaded = fgGetBool("sim/sceneryloaded");
- bool wait_for_scenery = !(scenery_loaded || fgGetBool("sim/sceneryloaded-override"));
-
+ bool wait_for_scenery = !(_sceneryLoaded || _sceneryLoadOverride);
if (!wait_for_scenery) {
throttleUpdateRate();
}
if (0 < dtMax && dtMax < dt) {
dt = dtMax;
}
-
- int model_hz = fgGetInt("/sim/model-hz");
-
+
SGSubsystemGroup* fdmGroup =
globals->get_subsystem_mgr()->get_group(SGSubsystemMgr::FDM);
- fdmGroup->set_fixed_update_time(1.0 / model_hz);
+ fdmGroup->set_fixed_update_time(1.0 / _modelHz);
// round the real time down to a multiple of 1/model-hz.
// this way all systems are updated the _same_ amount of dt.
dt += _dtRemainder;
- int multiLoop = long(floor(dt * model_hz));
+ int multiLoop = long(floor(dt * _modelHz));
multiLoop = SGMisc<long>::max(0, multiLoop);
- _dtRemainder = dt - double(multiLoop)/double(model_hz);
- dt = double(multiLoop)/double(model_hz);
+ _dtRemainder = dt - double(multiLoop)/double(_modelHz);
+ dt = double(multiLoop)/double(_modelHz);
realDt = dt;
if (_clockFreeze->getBoolValue() || wait_for_scenery) {
globals->inc_sim_time_sec(simDt);
// These are useful, especially for Nasal scripts.
- fgSetDouble("/sim/time/delta-realtime-sec", realDt);
- fgSetDouble("/sim/time/delta-sec", simDt);
+ _timeDelta = realDt;
+ _simTimeDelta = simDt;
}
void TimeManager::update(double dt)
#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/props/props.hxx>
+#include <simgear/props/propertyObject.hxx>
// forward decls
class SGTime;
time_t _lastFrameTime;
double _frameLatencyMax;
int _frameCount;
+
+ SGPropObjBool _sceneryLoaded,
+ _sceneryLoadOverride;
+ SGPropObjInt _modelHz;
+ SGPropObjDouble _timeDelta, _simTimeDelta;
};
#endif // of FG_TIME_TIMEMANAGER_HXX