1
0
Fork 0

Add some missing bits from Mathias' carrier code.

This commit is contained in:
ehofman 2004-11-20 12:44:42 +00:00
parent 161fb0c770
commit 337d0d1be6
2 changed files with 15 additions and 1 deletions

View file

@ -79,7 +79,9 @@ FGInterface::_calc_multiloop (double dt)
dt += remainder;
remainder = 0;
double ml = dt * hz;
int multiloop = int(floor(ml));
// Avoid roundoff problems by adding the roundoff itself.
// ... ok, two times the roundoff to have enough room.
int multiloop = int(floor(ml * (1.0 + 2.0*DBL_EPSILON)));
remainder = (ml - multiloop) / hz;
return (multiloop * speedup);
}

View file

@ -240,6 +240,18 @@ static void fgMainLoop( void ) {
real_delta_time_sec
= double(current_time_stamp - last_time_stamp) / 1000000.0;
// round the real time down to a multiple of 1/model-hz.
// this way all systems are updated the _same_ amount of dt.
{
static double rem = 0.0;
real_delta_time_sec += rem;
double hz = model_hz;
double nit = floor(real_delta_time_sec*hz);
rem = real_delta_time_sec - nit/hz;
real_delta_time_sec = nit/hz;
}
if ( clock_freeze->getBoolValue() ) {
delta_time_sec = 0;
} else {