Make the steady clock and MP clock init at modelHz boundary.
This removing any fractional (of a modelHz step) part when initialising. This allow us to sync time in different FG instances, if FPS allow.
This commit is contained in:
parent
bf26817d53
commit
7dfbcf0918
1 changed files with 18 additions and 12 deletions
|
@ -197,13 +197,22 @@ void TimeManager::valueChanged(SGPropertyNode* aProp)
|
|||
|
||||
void TimeManager::computeTimeDeltas(double& simDt, double& realDt)
|
||||
{
|
||||
const double modelHz = _modelHz->getDoubleValue();
|
||||
|
||||
// Update the elapsed time.
|
||||
if (_firstUpdate) {
|
||||
_lastStamp.stamp();
|
||||
|
||||
// we initialise the mp protocol clock with the system clock.
|
||||
// Initialise the mp protocol / steady clock with the system clock.
|
||||
// later, the clock follows steps of 1/modelHz (120 by default),
|
||||
// so the MP clock remains aligned to these boundaries
|
||||
|
||||
_systemStamp.systemClockHoursAndMinutes();
|
||||
_steadyClock = _systemStamp.toSecs();
|
||||
const double systemStamp = _systemStamp.toSecs();
|
||||
_steadyClock = floor(systemStamp * modelHz) / modelHz;
|
||||
|
||||
// initialize the remainder with offset from the system clock
|
||||
_dtRemainder = systemStamp - _steadyClock;
|
||||
|
||||
_firstUpdate = false;
|
||||
_lastClockFreeze = _clockFreeze->getBoolValue();
|
||||
|
@ -212,9 +221,7 @@ void TimeManager::computeTimeDeltas(double& simDt, double& realDt)
|
|||
bool wait_for_scenery = !_sceneryLoaded->getBoolValue();
|
||||
if (!wait_for_scenery) {
|
||||
throttleUpdateRate();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// suppress framerate while initial scenery isn't loaded yet (splash screen still active)
|
||||
_lastFrameTime=0;
|
||||
_frameCount = 0;
|
||||
|
@ -258,7 +265,6 @@ void TimeManager::computeTimeDeltas(double& simDt, double& realDt)
|
|||
|
||||
SGSubsystemGroup* fdmGroup =
|
||||
globals->get_subsystem_mgr()->get_group(SGSubsystemMgr::FDM);
|
||||
double modelHz = _modelHz->getDoubleValue();
|
||||
fdmGroup->set_fixed_update_time(1.0 / modelHz);
|
||||
|
||||
// round the real time down to a multiple of 1/model-hz.
|
||||
|
|
Loading…
Reference in a new issue