]> git.mxchange.org Git - flightgear.git/commitdiff
Add some missing bits from Mathias' carrier code.
authorehofman <ehofman>
Sat, 20 Nov 2004 12:44:42 +0000 (12:44 +0000)
committerehofman <ehofman>
Sat, 20 Nov 2004 12:44:42 +0000 (12:44 +0000)
src/FDM/flight.cxx
src/Main/main.cxx

index bd5a61ef94190cd7926cf091de562ccaa7f2b002..a81ed437cd00dbdb44cc57191b709f3e5df479b5 100644 (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);
 }
index 9bb5ff0f7f60261246ff6c15d70bf08100e450db..0d43799a6dc33adee1bc5ed70861ac01c14cdff5 100644 (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 {