]> git.mxchange.org Git - flightgear.git/commitdiff
Major overhaul:
authordavid <david>
Sat, 11 May 2002 16:28:50 +0000 (16:28 +0000)
committerdavid <david>
Sat, 11 May 2002 16:28:50 +0000 (16:28 +0000)
- changed FGSubsystem::update(int) to
  FGSubsystem::update(delta_time_sec); the argument is now delta time
  in seconds rather than milliseconds

- added FGSubsystem::suspend(), FGSubsystem::suspend(bool),
  FGSubsystem::resume(), and FGSubsystem::is_suspended(), all with
  default implementations; is_suspended takes account of the master
  freeze as well as the subsystem's individual suspended state

- the FDMs now use the delta time argument the same as the rest of
  FlightGear; formerly, main.cxx made a special case and passed a
  multiloop argument

- FDMs now calculate multiloop internally instead of relying on
  main.cxx

There are probably some problems -- I've done basic testing with the
major FDMs and subsystems, but we'll probably need a few weeks to
sniff out bugs.

70 files changed:
src/ATC/ATCdisplay.cxx
src/ATC/ATCdisplay.hxx
src/ATC/ATCmgr.cxx
src/ATC/ATCmgr.hxx
src/Autopilot/newauto.cxx
src/Autopilot/newauto.hxx
src/Cockpit/panel.cxx
src/Cockpit/panel.hxx
src/Cockpit/radiostack.cxx
src/Cockpit/radiostack.hxx
src/Cockpit/steam.cxx
src/Cockpit/steam.hxx
src/Controls/controls.cxx
src/Controls/controls.hxx
src/Environment/environment_ctrl.cxx
src/Environment/environment_ctrl.hxx
src/Environment/environment_mgr.cxx
src/Environment/environment_mgr.hxx
src/FDM/ADA.cxx
src/FDM/ADA.hxx
src/FDM/Balloon.cxx
src/FDM/Balloon.h
src/FDM/External.cxx
src/FDM/External.hxx
src/FDM/ExternalNet.cxx
src/FDM/ExternalNet.hxx
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/JSBSim.hxx
src/FDM/LaRCsim.cxx
src/FDM/LaRCsim.hxx
src/FDM/MagicCarpet.cxx
src/FDM/MagicCarpet.hxx
src/FDM/NullFDM.cxx
src/FDM/NullFDM.hxx
src/FDM/UFO.cxx
src/FDM/UFO.hxx
src/FDM/YASim/YASim.cxx
src/FDM/YASim/YASim.hxx
src/FDM/flight.cxx
src/FDM/flight.hxx
src/Input/input.cxx
src/Input/input.hxx
src/Main/fg_props.cxx
src/Main/fgfs.cxx
src/Main/fgfs.hxx
src/Main/globals.cxx
src/Main/globals.hxx
src/Main/logger.cxx
src/Main/logger.hxx
src/Main/main.cxx
src/Main/viewer.cxx
src/Main/viewer.hxx
src/Main/viewmgr.cxx
src/Main/viewmgr.hxx
src/Model/acmodel.cxx
src/Model/acmodel.hxx
src/Model/model.cxx
src/Model/model.hxx
src/Model/modelmgr.cxx
src/Model/modelmgr.hxx
src/Scenery/scenery.cxx
src/Scenery/scenery.hxx
src/Sound/fg_fx.cxx
src/Sound/fg_fx.hxx
src/Sound/fg_sound.cxx
src/Sound/fg_sound.hxx
src/Sound/soundmgr.cxx
src/Sound/soundmgr.hxx
src/Time/FGEventMgr.cxx
src/Time/FGEventMgr.hxx

index 0bfce155daea81e5ce2563fb4acd83a5e3e7b4bc..287b845b3f0956eb11df6448bbd0ca3f2e852eda 100644 (file)
@@ -54,7 +54,7 @@ void FGATCDisplay::unbind() {
 }
 
 // update - this actually draws the visuals and should be called from the main Flightgear rendering loop.
-void FGATCDisplay::update(int dt) {
+void FGATCDisplay::update(double dt) {
 
     // These strings are used for temporary storage of the transmission string in order
     // that the string we view only changes when the next repetition starts scrolling
index 9c2c9805f1cd4eb0431c433ef9029b68339cdf13..c17d36c0659f60007e5f20bab50af672663cf879 100644 (file)
@@ -71,7 +71,7 @@ public:
     void unbind();
 
     // Display any registered messages
-    void update(int dt);
+    void update(double dt);
 
     // Register a single message for display after a delay of delay seconds
     // Will automatically stop displaying after a suitable interval.
index 5a7e1b8ea4b0938f14eeb55acbb1af1b4ec5f552..eb6441de854ef79a889a8a82a80af14d88c1be19 100644 (file)
@@ -88,7 +88,7 @@ void FGATCMgr::init() {
     airport_atc_map[(string)"KEMT"] = a;
 }
 
-void FGATCMgr::update(int dt) {
+void FGATCMgr::update(double dt) {
     //Traverse the list of active stations.
     //Only update one class per update step to avoid the whole ATC system having to calculate between frames.
     //Eventually we should only update every so many steps.
index 03ac392e6c426d961aa5a770485e16e95dbee1fa..30e06294ff6c00c0f83608c856c9f3ac57920d64 100644 (file)
@@ -154,7 +154,7 @@ public:
 
     void unbind();
 
-    void update(int dt);
+    void update(double dt);
 
     // Returns true if the airport is found in the map
     bool GetAirportATCDetails(string icao, AirportATC* a);
index a2d188a6adbbd5e4d20df4bc87690877a8f36b40..7e12850c0fc59e97209765480449baee4eabff49 100644 (file)
@@ -421,7 +421,7 @@ static double LinearExtrapolate( double x, double x1, double y1, double x2, doub
 
 
 void
-FGAutopilot::update (int dt)
+FGAutopilot::update (double dt)
 {
     // Remove the following lines when the calling funcitons start
     // passing in the data pointer
index 2c1124d12ca01a565f5bc0a9ef9b5ecd17f4a9d4..c16125e032c5b2920d5d476bc3dd1f8fc42f746c 100644 (file)
@@ -152,7 +152,7 @@ public:
     void init ();
     void bind ();
     void unbind ();
-    void update (int dt);
+    void update (double dt);
 
     // Reset the autopilot system
     void reset(void);
index 6e78219c80bc7d6cdc36c4353882eccf81182d6d..bee42a477766ecd75ba3cf9e3eaccf26fa62c670 100644 (file)
@@ -269,7 +269,7 @@ FGPanel::unbind ()
  * Update the panel.
  */
 void
-FGPanel::update (int dt)
+FGPanel::update (double dt)
 {
                                // TODO: cache the nodes
     _visibility = fgGetBool("/sim/panel/visibility");
index 70fb1a1227722bdd092046b904dd7121f27a2f23..c17b897357dc0ba5c1d97d8f4be0e9c03b96ca1a 100644 (file)
@@ -141,7 +141,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
   virtual void update (GLfloat winx, GLfloat winw, GLfloat winy, GLfloat winh);
 
                                // transfer pointer ownership!!!
index 62669ae93fc45db63b7a029c9a1bdc7def8c8013..3215f00963081011c2aaee2a385ac0787d0320e7 100644 (file)
@@ -143,7 +143,7 @@ FGRadioStack::init ()
     blink.stamp();
 
     search();
-    update(1);                 // FIXME: use dt
+    update(0);                 // FIXME: use dt
 
     // Search radio database once per second
     global_events.Register( "fgRadioSearch()",
@@ -404,7 +404,7 @@ double FGRadioStack::adjustILSRange( double stationElev, double aircraftElev,
 
 // Update the various nav values based on position and valid tuned in navs
 void 
-FGRadioStack::update(int dt) 
+FGRadioStack::update(double dt) 
 {
     double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
     double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
index 331d97c8d5cde6e987e05ef0aa2c549c7791d443..9b5f136e861f061569b7f5d8c489c7fa1e7c83ff 100644 (file)
@@ -212,7 +212,7 @@ public:
     void init ();
     void bind ();
     void unbind ();
-    void update (int dt);
+    void update (double dt);
 
     // Update nav/adf radios based on current postition
     void search ();
index cd78bf303259ab843f2575299c14f3eb0854a6c0..22ed726b3bec2fd60dff6e3976ff2fda5dcc840d 100644 (file)
@@ -98,8 +98,9 @@ int FGSteam::_UpdatesPending = 1000000;  /* Forces filter to reset */
                                // FIXME: no need to use static
                                // functions any longer.
 
-void FGSteam::update ( int timesteps )
+void FGSteam::update (double dt)
 {
+    int timesteps = int(dt * 1000);
     if (!isTied) {
         isTied = true;
         fgTie("/steam/airspeed-kt", FGSteam::get_ASI_kias);
index 862433ffa5af67a13133e4beffa4c0d224104f43..cb3e0c5a3aea9444ff970395f478b87ae5c1071b 100644 (file)
@@ -53,7 +53,7 @@ class FGSteam
 {
 public:
 
-  static void update ( int timesteps );
+  static void update ( double dt );
 
                                // Position
   static double get_ALT_ft ();
index a3fc7df782c52a657441b3c65f934105facd30b0..8c2ab506689e0d9e7e71642a4c92c7d2c75f4b7e 100644 (file)
@@ -206,7 +206,7 @@ FGControls::unbind ()
 
 
 void
-FGControls::update (int dt)
+FGControls::update (double dt)
 {
 }
 
index 208ad8c36e4b2ab2db69c7786490c8bfe4a1126f..e865a59753b0580c6a3e9e289fc724baa19f0521 100644 (file)
@@ -83,7 +83,7 @@ public:
     void init ();
     void bind ();
     void unbind ();
-    void update (int dt);
+    void update (double dt);
 
     // Reset function
     void reset_all(void);
index 0d57267f6afa6046489c69dfc1477e2ff7ad3cca..ae28932b7f1ec45f1dfa028c73047a736169a1fb 100644 (file)
@@ -116,7 +116,7 @@ FGUserDefEnvironmentCtrl::init ()
 }
 
 void
-FGUserDefEnvironmentCtrl::update (int dt)
+FGUserDefEnvironmentCtrl::update (double dt)
 {
   double base_wind_speed = _base_wind_speed_node->getDoubleValue();
   double gust_wind_speed = _gust_wind_speed_node->getDoubleValue();
index d50dba79ed562d2d6007c431ae96729cb19ae73d..17ed581d79a131b4154ba248797304c5c0c0cda5 100644 (file)
@@ -62,7 +62,7 @@ public:
   virtual double getElevationFt () const { return _elev_ft; }
 
   virtual void init () = 0;
-  virtual void update (int dt) = 0;
+  virtual void update (double dt) = 0;
 
 protected:
 
@@ -85,7 +85,7 @@ public:
   virtual ~FGUserDefEnvironmentCtrl ();
 
   virtual void init ();
-  virtual void update (int dt);
+  virtual void update (double dt);
 
 private:
 
index 4f338895478ab5f406b6c5c595de38b0db2fbd0a..8a4e8d4957a8d65963163cd12bb7b46684fee51c 100644 (file)
@@ -95,7 +95,7 @@ FGEnvironmentMgr::unbind ()
 }
 
 void
-FGEnvironmentMgr::update (int dt)
+FGEnvironmentMgr::update (double dt)
 {
   _controller->update(dt);
                                // FIXME: the FDMs should update themselves
index d8757900bb33b237d1ad4a9ccded515643275fec..63d3f725a9b551d59e7fd0923fa534cdd2fe1b9e 100644 (file)
@@ -51,7 +51,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
 
   /**
    * Get the environment information for the plane's current position.
index 0fc0aeee813ac1db4e9614565a494dfb7184b4a3..65de055990ba928144fb24a84d1dc9b566c2d98f 100644 (file)
@@ -156,7 +156,7 @@ struct {
 
 
 FGADA::FGADA( double dt ) {
-    set_delta_t( dt );
+//     set_delta_t( dt );
 }
 
 
@@ -198,9 +198,12 @@ void FGADA::init() {
 // Run an iteration of the EOM.  This is essentially a NOP here
 // because these values are getting filled in elsewhere based on
 // external input.
-void FGADA::update( int multiloop ) {
+void FGADA::update( double dt ) {
     // cout << "FGADA::update()" << endl;
 
+    if (is_suspended())
+      return;
+
     char Buffer[numberofbytes];
     char OutBuffer[nbytes];
 
index bef66d88b4d3d1c66f26c116d385b46c2e027d56..7374c479d79f55427ee7ecb994715d3780911a6f 100644 (file)
@@ -79,7 +79,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    void update(int dt);
+    void update(double dt);
 
 };
 
index dd5bc016d8f8580432532adc857e9bcbb6daa138..1bd64a8716c22dc810b6b0f7ece714528705d2a3 100644 (file)
@@ -113,9 +113,14 @@ void FGBalloonSim::init() {
 
 
 // Run an iteration of the EOM (equations of motion)
-void FGBalloonSim::update( int multiloop ) {
+void FGBalloonSim::update( double dt ) {
     double save_alt = 0.0;
 
+    if (is_suspended())
+      return;
+
+    int multiloop = _calc_multiloop(dt);
+
     // lets try to avoid really screwing up the BalloonSim model
     if ( get_Altitude() < -9000 ) {
        save_alt = get_Altitude();
index b180a3a535f05bfb48b8e290f6e2dd37a6aa7e34..84ff1ce6b21ce972ab0032672dd42110e0cfc60a 100644 (file)
@@ -75,7 +75,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    void update( int multiloop );
+    void update( double dt );
 };
 
 
index cc6c1a2f923881af28c586f4b7988dea2d0010e6..b4794c7ddef3bbae78b13b0b91953fb279db08fe 100644 (file)
@@ -25,7 +25,7 @@
 
 
 FGExternal::FGExternal( double dt ) {
-    set_delta_t( dt );
+//     set_delta_t( dt );
 }
 
 
@@ -47,7 +47,7 @@ void FGExternal::init() {
 // Run an iteration of the EOM.  This is essentially a NOP here
 // because these values are getting filled in elsewhere based on
 // external input.
-void FGExternal::update( int multiloop ) {
+void FGExternal::update( double dt ) {
     // cout << "FGExternal::update()" << endl;
 
     // double time_step = (1.0 / fgGetInt("/sim/model-hz"))
index 2cc20b4250f7ce1b623143652ff0de1a96da2109..61bc9a3abb43c79a79a705e0ca9f4472ed607a34 100644 (file)
@@ -38,7 +38,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    void update( int multiloop );
+    void update( double dt );
 };
 
 
index 62c23edc440945b3abcaaf8c03493f12fd2ae67d..97374d84e761dad46cc3b3e9be7325630c6a21b6 100644 (file)
@@ -234,7 +234,7 @@ static void net2global( FGNetFDM *net ) {
 
 FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
 {
-    set_delta_t( dt );
+//     set_delta_t( dt );
 
     valid = true;
 
@@ -330,10 +330,13 @@ void FGExternalNet::init() {
 // Run an iteration of the EOM.  This is a NOP here because the flight
 // model values are getting filled in elsewhere (most likely from some
 // external source.)
-void FGExternalNet::update( int multiloop ) {
+void FGExternalNet::update( double dt ) {
     int length;
     int result;
 
+    if (is_suspended())
+      return;
+
     // Send control positions to remote fdm
     length = sizeof(ctrls);
     global2raw( &ctrls );
index 1d8c0487ef58a0c2f4488e468fb2a1355fe530a5..2901ca0f927d3fc4581155b7a8014078bfce8b6c 100644 (file)
@@ -87,7 +87,7 @@ public:
     void init();
 
     // update the fdm
-    void update( int multiloop );
+    void update( double dt );
 
 };
 
index 27b40ab83f7acc82d9aa246dfb3fb2153b8ad832..4136e6b324afe66d7f2e45be0b6db467fa5494ea 100644 (file)
@@ -98,7 +98,6 @@ FGJSBsim::FGJSBsim( double dt )
 
     SGPath engine_path( globals->get_fg_root() );
     engine_path.append( "Engine" );
-    set_delta_t( dt );
     State->Setdt( dt );
 
     result = fdmex->LoadModel( aircraft_path.str(),
@@ -261,7 +260,12 @@ void FGJSBsim::init() {
 // Run an iteration of the EOM (equations of motion)
 
 void
-FGJSBsim::update( int multiloop ) {
+FGJSBsim::update( double dt ) {
+
+    if (is_suspended())
+      return;
+
+    int multiloop = _calc_multiloop(dt);
 
     int i;
 
index 2f8b362c89a40a9f0022458d7e2724132eeeef25..e0e66b1192ef1ade37d4e25610c0dfb50c6a21bd 100644 (file)
@@ -207,9 +207,8 @@ public:
 
 
     /** Update the position based on inputs, positions, velocities, etc.
-        @param multiloop number of times to loop through the FDM
-             @return true if successful */
-    void update( int multiloop );
+        @param dt delta time in seconds. */
+    void update(double dt);
     bool ToggleDataLogging(bool state);
     bool ToggleDataLogging(void);
     void do_trim(void);
index a7a2435a0dbcf3504608cabe7ddd4c3bedece7f5..8051ef49f8166ab3799419fb33d7031c64643bae 100644 (file)
@@ -41,7 +41,7 @@
 #include "LaRCsim.hxx"
 
 FGLaRCsim::FGLaRCsim( double dt ) {
-    set_delta_t( dt );
+//     set_delta_t( dt );
 
     speed_up = fgGetNode("/sim/speed-up", true);
     aero = fgGetNode("/sim/aero", true);
@@ -60,10 +60,10 @@ FGLaRCsim::FGLaRCsim( double dt ) {
         I_xz = 0.000000E+00;
     }
 
-    ls_set_model_dt( get_delta_t() );
+    ls_set_model_dt(dt);
 
             // Initialize our little engine that hopefully might
-    eng.init( get_delta_t() );
+    eng.init(dt);
     // dcl - in passing dt to init rather than update I am assuming
     // that the LaRCsim dt is fixed at one value (yes it is 120hz CLO)
 }
@@ -84,7 +84,12 @@ void FGLaRCsim::init() {
 
 
 // Run an iteration of the EOM (equations of motion)
-void FGLaRCsim::update( int multiloop ) {
+void FGLaRCsim::update( double dt ) {
+
+    if (is_suspended())
+      return;
+
+    int multiloop = _calc_multiloop(dt);
 
     if ( !strcmp(aero->getStringValue(), "c172") ) {
        // set control inputs
@@ -142,11 +147,11 @@ void FGLaRCsim::update( int multiloop ) {
            fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
                        fgGetDouble("/consumables/fuel/tank[0]/level-gal_us")
                        - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
-                       * get_delta_t());
+                       * dt);
            fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
                        fgGetDouble("/consumables/fuel/tank[1]/level-gal_us")
                        - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
-                       * get_delta_t());
+                       * dt);
        }
 
         F_X_engine = eng.get_prop_thrust_lbs();
index f5299c974d3bab55489dc45cee94e2407033d847..df2b5389cbfec78c2bda9d60d230ec2b90a077c8 100644 (file)
@@ -58,7 +58,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    void update( int multiloop );
+    void update( double dt );
     
     // Positions
     void set_Latitude(double lat);  //geocentric
index 738e1e5644de2bad81bd3ae93fbfa250dda1064f..3e5a22f5d595068e2e2f63b8d91e52ddaf36fdcb 100644 (file)
@@ -33,7 +33,7 @@
 
 
 FGMagicCarpet::FGMagicCarpet( double dt ) {
-    set_delta_t( dt );
+//     set_delta_t( dt );
 }
 
 
@@ -49,10 +49,15 @@ void FGMagicCarpet::init() {
 
 
 // Run an iteration of the EOM (equations of motion)
-void FGMagicCarpet::update( int multiloop ) {
+void FGMagicCarpet::update( double dt ) {
     // cout << "FGLaRCsim::update()" << endl;
 
-    double time_step = get_delta_t() * multiloop;
+    if (is_suspended())
+      return;
+
+    int multiloop = _calc_multiloop(dt);
+
+    double time_step = dt * multiloop;
 
     // speed and distance traveled
     double speed = globals->get_controls()->get_throttle( 0 ) * 2000; // meters/sec
index 32fa71f241d94ba76b8084ca4ad360485cd224c4..aa35b020da1a35408d5fcd04438fe642db020b04 100644 (file)
@@ -38,7 +38,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    void update( int multiloop );
+    void update( double dt );
 
 };
 
index 7008245785703491e07e3accc95f69f79e456232..e02735893772b56d38129fc0b0da5ab55cb7ae7d 100644 (file)
@@ -25,7 +25,7 @@
 
 
 FGNullFDM::FGNullFDM( double dt ) {
-    set_delta_t( dt );
+//     set_delta_t( dt );
 }
 
 
@@ -43,6 +43,6 @@ void FGNullFDM::init() {
 // Run an iteration of the EOM.  This is a NOP here because the flight
 // model values are getting filled in elsewhere (most likely from some
 // external source.)
-void FGNullFDM::update( int multiloop ) {
+void FGNullFDM::update( double dt ) {
     // cout << "FGNullFDM::update()" << endl;
 }
index 1d2dd2844846c7125f2d2f0db337526661093314..f2e4f1f8ae5b34adb26e532a20378378ac7beb4b 100644 (file)
@@ -39,7 +39,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    void update( int multiloop );
+    void update( double dt );
 };
 
 
index efa296d82af2000e5310e152a1c9c72b432a915d..3223e35f9a2b0f6b8af65f07e8495bcc855e849f 100644 (file)
@@ -40,7 +40,7 @@ FGUFO::FGUFO( double dt )
     Aileron(0.0),
     Elevator(0.0)
 {
-    set_delta_t( dt );
+//     set_delta_t( dt );
 }
 
 
@@ -56,10 +56,15 @@ void FGUFO::init() {
 
 
 // Run an iteration of the EOM (equations of motion)
-void FGUFO::update( int multiloop ) {
+void FGUFO::update( double dt ) {
     // cout << "FGLaRCsim::update()" << endl;
 
-    double time_step = get_delta_t() * multiloop;
+    if (is_suspended())
+      return;
+
+    int multiloop = _calc_multiloop(dt);
+
+    double time_step = dt * multiloop;
 
     // read the throttle
     double th = globals->get_controls()->get_throttle( 0 );
index 8ceecf1357a1d1e63857510d3d6a892ed3714e22..077332c6c09d34ad788203f73e6af8656094ae33 100644 (file)
@@ -40,7 +40,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    void update( int multiloop );
+    void update( double dt );
 
 };
 
index 5c93abad359182e2da45bba6e42440139a3b4d53..faaaf5fe794b8823e7c5aa861af47aedcf24b6d7 100644 (file)
@@ -57,7 +57,7 @@ void YASim::printDEBUG()
 
 YASim::YASim(double dt)
 {
-    set_delta_t(dt);
+//     set_delta_t(dt);
     _fdm = new FGFDM();
 
     _dt = dt;
@@ -194,8 +194,13 @@ void YASim::init()
     set_inited(true);
 }
 
-void YASim::update(int iterations)
+void YASim::update(double dt)
 {
+    if (is_suspended())
+      return;
+
+    int iterations = _calc_multiloop(dt);
+
     // If we're crashed, then we don't care
     if(_fdm->getAirplane()->getModel()->isCrashed())
       return;
index 02f9440bcd1c41cb2ba4896dd79bb1335488deed..1498d5126e133d406bc682bc0848b90c59ec5f5e 100644 (file)
@@ -14,7 +14,7 @@ public:
     virtual void bind();
 
     // Run an iteration
-    virtual void update(int iterations);
+    virtual void update(double dt);
 
  private:
     void report();
index 991e150dd2bd5200ca04945907d3ef92097c1e55..76f93e2a4c46933666ecb3c2568113107d898d91 100644 (file)
@@ -57,8 +57,9 @@ FGInterface::FGInterface() {
 
 FGInterface::FGInterface( double dt ) {
     _setup();
-    delta_t = dt;
-    remainder = elapsed = multi_loop = 0;
+//     delta_t = dt;
+//     remainder = elapsed = multi_loop = 0;
+    remainder = 0;
 }
 
 // Destructor
@@ -67,6 +68,21 @@ FGInterface::~FGInterface() {
 }
 
 
+int
+FGInterface::_calc_multiloop (double dt)
+{
+  int hz = fgGetInt("/sim/model-hz");
+  int speedup = fgGetInt("/sim/speed-up");
+
+  dt += remainder;
+  remainder = 0;
+  double ml = dt * hz;
+  int multiloop = int(floor(ml));
+  remainder = (ml - multiloop) / hz;
+  return (multiloop * speedup);
+}
+
+
 /**
  * Set default values for the state of the FDM.
  *
@@ -163,8 +179,8 @@ FGInterface::common_init ()
 
     set_inited( true );
 
-    stamp();
-    set_remainder( 0 );
+//     stamp();
+//     set_remainder( 0 );
 
     // Set initial position
     SG_LOG( SG_FLIGHT, SG_INFO, "...initializing position..." );
@@ -254,14 +270,14 @@ FGInterface::bind ()
   bound = true;
 
                                 // Time management (read-only)
-  fgTie("/fdm/time/delta_t", this,
-        &FGInterface::get_delta_t); // read-only
-  fgTie("/fdm/time/elapsed", this,
-        &FGInterface::get_elapsed); // read-only
-  fgTie("/fdm/time/remainder", this,
-        &FGInterface::get_remainder); // read-only
-  fgTie("/fdm/time/multi_loop", this,
-        &FGInterface::get_multi_loop); // read-only
+//   fgTie("/fdm/time/delta_t", this,
+//         &FGInterface::get_delta_t); // read-only
+//   fgTie("/fdm/time/elapsed", this,
+//         &FGInterface::get_elapsed); // read-only
+//   fgTie("/fdm/time/remainder", this,
+//         &FGInterface::get_remainder); // read-only
+//   fgTie("/fdm/time/multi_loop", this,
+//         &FGInterface::get_multi_loop); // read-only
 
                        // Aircraft position
   fgTie("/position/latitude-deg", this,
@@ -405,7 +421,7 @@ FGInterface::unbind ()
  * Update the state of the FDM (i.e. run the equations of motion).
  */
 void
-FGInterface::update (int dt)
+FGInterface::update (double dt)
 {
     SG_LOG(SG_FLIGHT, SG_ALERT, "dummy update() ... SHOULDN'T BE CALLED!");
 }
index fe0a11eddba0aac376df3c572e064a1fcc1bf157..afc4ded02b29116002221d46113d02c97349b020 100644 (file)
@@ -90,7 +90,7 @@
 #include <string>
 
 #include <simgear/constants.h>
-#include <simgear/timing/timestamp.hxx>
+// #include <simgear/timing/timestamp.hxx>
 
 #include <Main/fgfs.hxx>
 
@@ -124,11 +124,11 @@ private:
     // next elapsed time.  This yields a small amount of temporal
     // jitter ( < dt ) but in practice seems to work well.
 
-    double delta_t;            // delta "t"
-    SGTimeStamp time_stamp;    // time stamp of last run
-    long elapsed;              // time elapsed since last run
-    long remainder;            // remainder time from last run
-    int multi_loop;            // number of iterations of "delta_t" to run
+//     double delta_t;         // delta "t"
+//     SGTimeStamp time_stamp; // time stamp of last run
+//     long elapsed;           // time elapsed since last run
+    double remainder;          // remainder time from last run
+//     int multi_loop;         // number of iterations of "delta_t" to run
 
     // Pilot location rel to ref pt
     FG_VECTOR_3 d_pilot_rp_body_v;
@@ -224,7 +224,10 @@ private:
     // SGTimeStamp valid_stamp;          // time this record is valid
     // SGTimeStamp next_stamp;           // time this record is valid
 
-// protected:
+protected:
+
+    int _calc_multiloop (double dt);
+
 public:
 
                                // deliberately not virtual so that
@@ -400,7 +403,7 @@ public:
     virtual void init ();
     virtual void bind ();
     virtual void unbind ();
-    virtual void update(int dt);
+    virtual void update(double dt);
     virtual bool ToggleDataLogging(bool state) { return false; }
     virtual bool ToggleDataLogging(void) { return false; }
 
@@ -443,17 +446,17 @@ public:
     void common_init();
 
     // time and update management values
-    inline double get_delta_t() const { return delta_t; }
-    inline void set_delta_t( double dt ) { delta_t = dt; }
-    inline SGTimeStamp get_time_stamp() const { return time_stamp; }
-    inline void set_time_stamp( SGTimeStamp s ) { time_stamp = s; }
-    inline void stamp() { time_stamp.stamp(); }
-    inline long get_elapsed() const { return elapsed; }
-    inline void set_elapsed( long e ) { elapsed = e; }
-    inline long get_remainder() const { return remainder; }
-    inline void set_remainder( long r ) { remainder = r; }
-    inline int get_multi_loop() const { return multi_loop; }
-    inline void set_multi_loop( int ml ) { multi_loop = ml; }
+//     inline double get_delta_t() const { return delta_t; }
+//     inline void set_delta_t( double dt ) { delta_t = dt; }
+//     inline SGTimeStamp get_time_stamp() const { return time_stamp; }
+//     inline void set_time_stamp( SGTimeStamp s ) { time_stamp = s; }
+//     inline void stamp() { time_stamp.stamp(); }
+//     inline long get_elapsed() const { return elapsed; }
+//     inline void set_elapsed( long e ) { elapsed = e; }
+//     inline long get_remainder() const { return remainder; }
+//     inline void set_remainder( long r ) { remainder = r; }
+//     inline int get_multi_loop() const { return multi_loop; }
+//     inline void set_multi_loop( int ml ) { multi_loop = ml; }
 
     // Positions
     virtual void set_Latitude(double lat);       // geocentric
index bf6f446172eb2775c2e5459cbbe942df4231adf4..f7ce15856d5cc0f87aa20c18555817ebbf2d40cd 100644 (file)
@@ -217,7 +217,7 @@ FGInput::unbind ()
 }
 
 void 
-FGInput::update (int dt)
+FGInput::update (double dt)
 {
   _update_keyboard();
   _update_joystick();
index a5ff74dbecfc77aced7bf7fb997dddb53f1c77a2..2ea4217e922a66fc13894244f66b298638120eba 100644 (file)
@@ -191,7 +191,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
 
 
   /**
index 152dbae1ec7dcf6dc6ef597f755164e4e6a77de8..2b55d705dce85c2908b4538dda17ca8214292470 100644 (file)
@@ -265,9 +265,9 @@ setAircraftDir (const char * dir)
  * Return the number of milliseconds elapsed since simulation started.
  */
 static double
-getElapsedTime_ms ()
+getElapsedTime_sec ()
 {
-  return globals->get_sim_time_ms();
+  return globals->get_sim_time_sec();
 }
 
 
@@ -580,7 +580,7 @@ fgInitProps ()
   fgTie("/sim/freeze/master", getFreeze, setFreeze);
   fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
 
-  fgTie("/sim/time/elapsed-ms", getElapsedTime_ms);
+  fgTie("/sim/time/elapsed-sec", getElapsedTime_sec);
   fgTie("/sim/time/gmt", getDateString, setDateString);
   fgSetArchivable("/sim/time/gmt");
   fgTie("/sim/time/gmt-string", getGMTString);
index 33e281f6a208f9f086f3d780e8c25d785264a9c8..77c8dd5f52f6b99b39da663d0b150684cdfb9f29 100644 (file)
@@ -3,6 +3,7 @@
 #include <simgear/debug/logstream.hxx>
 
 #include "globals.hxx"
+#include "fg_props.hxx"
 
 
 \f
 ////////////////////////////////////////////////////////////////////////
 
 
+FGSubsystem::FGSubsystem ()
+  : _suspended(false)
+{
+}
+
 FGSubsystem::~FGSubsystem ()
 {
-  // NO-OP
 }
 
+void
+FGSubsystem::suspend ()
+{
+  _suspended = true;
+}
+
+void
+FGSubsystem::suspend (bool suspended)
+{
+  _suspended = suspended;
+}
+
+void
+FGSubsystem::resume ()
+{
+  _suspended = false;
+}
+
+bool
+FGSubsystem::is_suspended () const
+{
+  if (!_freeze_master_node.valid())
+    _freeze_master_node = fgGetNode("/sim/freeze/master", true);
+  return _suspended || _freeze_master_node->getBoolValue();
+}
 
 // end of fgfs.cxx
index f7aa373e1b7fea49f443aa67f745d59e53c57c3a..8f1270219831dba39d58331e1190e9cb7df792be 100644 (file)
@@ -38,6 +38,8 @@
 #  include <float.h>                    
 #endif
 
+#include <simgear/misc/props.hxx>
+
 
 \f
 /**
@@ -91,7 +93,7 @@
  *   _errorNode = fgGetNode("/display/error-margin-pct", true);
  * }
  *
- * void MySubsystem::update ()
+ * void MySubsystem::update (double delta_time_sec)
  * {
  *   do_something(_errorNode.getFloatValue());
  * }
  * <p>The node returned will always be a pointer to SGPropertyNode,
  * and the subsystem should <em>not</em> delete it in its destructor
  * (the pointer belongs to the property tree, not the subsystem).</p>
+ *
+ * <p>The program may ask the subsystem to suspend or resume
+ * sim-time-dependent operations; by default, the suspend() and
+ * resume() methods set the protected variable <var>_suspended</var>,
+ * which the subsystem can reference in its update() method, but
+ * subsystems may also override the suspend() and resume() methods to
+ * take different actions.</p>
  */
 class FGSubsystem
 {
 public:
 
+  /**
+   * Default constructor.
+   */
+  FGSubsystem ();
+
   /**
    * Virtual destructor to ensure that subclass destructors are called.
    */
@@ -147,10 +161,61 @@ public:
    * Update the subsystem.
    *
    * <p>FlightGear invokes this method every time the subsystem should
-   * update its state.  If the subsystem requires delta time information,
-   * it should track it itself.</p>
+   * update its state.</p>
+   *
+   * @param delta_time_sec The delta time, in seconds, since the last
+   * update.  On first update, delta time will be 0.
+   */
+  virtual void update (double delta_time_sec) = 0;
+
+
+  /**
+   * Suspend operation of this subsystem.
+   *
+   * <p>This method instructs the subsystem to suspend
+   * sim-time-dependent operations until asked to resume.  The update
+   * method will still be invoked so that the subsystem can take any
+   * non-time-dependent actions, such as updating the display.</p>
+   *
+   * <p>It is not an error for the suspend method to be invoked when
+   * the subsystem is already suspended; the invocation should simply
+   * be ignored.</p>
+   */
+  virtual void suspend ();
+
+
+  /**
+   * Suspend or resum operation of this subsystem.
+   *
+   * @param suspended true if the subsystem should be suspended, false
+   * otherwise.
+   */
+  virtual void suspend (bool suspended);
+
+
+  /**
+   * Resume operation of this subsystem.
+   *
+   * <p>This method instructs the subsystem to resume
+   * sim-time-depended operations.  It is not an error for the resume
+   * method to be invoked when the subsystem is not suspended; the
+   * invocation should simply be ignored.</p>
    */
-  virtual void update (int dt) = 0;
+  virtual void resume ();
+
+
+  /**
+   * Test whether this subsystem is suspended.
+   *
+   * @return true if the subsystem is suspended, false if it is not.
+   */
+  virtual bool is_suspended () const;
+
+
+protected:
+
+  mutable SGPropertyNode_ptr _freeze_master_node;
+  bool _suspended;
 
 };
 
index 44ba968c4b386d5d33ece7c6d6261b1efb113548..4394485eb2ef7908bc4c0ed5a59367ae9679d039 100644 (file)
@@ -42,7 +42,7 @@ FGGlobals *globals;
 
 // Constructor
 FGGlobals::FGGlobals() :
-    sim_time_ms(0.0),
+    sim_time_sec(0.0),
 #if defined(FX) && defined(XMESA)
     fullscreen( true ),
 #endif
index ee8036c88f32adda22f098499244ed4ed220957a..5a02dbd10c6b6485a7b4a78e5f5ed4affc7480e3 100644 (file)
@@ -80,7 +80,7 @@ class FGGlobals
 private:
 
     // Number of milliseconds elapsed since the start of the program.
-    double sim_time_ms;
+    double sim_time_sec;
 
     // Root of FlightGear data tree
     string fg_root;
@@ -174,9 +174,9 @@ public:
     FGGlobals();
     ~FGGlobals();
 
-    inline double get_sim_time_ms () const { return sim_time_ms; }
-    inline void inc_sim_time_ms (double dt) { sim_time_ms += dt; }
-    inline void set_sim_time_ms (double t) { sim_time_ms = t; }
+    inline double get_sim_time_sec () const { return sim_time_sec; }
+    inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
+    inline void set_sim_time_sec (double t) { sim_time_sec = t; }
 
     inline const string &get_fg_root () const { return fg_root; }
     inline void set_fg_root (const string &root) { fg_root = root; }
index 250b4b05393ee9398dd6b66d3621dafa90a4a1d6..afd32db2cfa8422471cb2f41827ee79b026d3188 100644 (file)
@@ -77,13 +77,13 @@ FGLogger::unbind ()
 }
 
 void
-FGLogger::update (int dt)
+FGLogger::update (double dt)
 {
-  double sim_time_ms = globals->get_sim_time_ms();
+  double sim_time_ms = globals->get_sim_time_sec() * 1000;
   for (unsigned int i = 0; i < _logs.size(); i++) {
     if ((sim_time_ms - _logs[i].last_time_ms) >= _logs[i].interval_ms) {
       _logs[i].last_time_ms = sim_time_ms;
-      (*_logs[i].output) << globals->get_sim_time_ms();
+      (*_logs[i].output) << sim_time_ms;
       for (unsigned int j = 0; j < _logs[i].nodes.size(); j++) {
        (*_logs[i].output) << _logs[i].delimiter
                           << _logs[i].nodes[j]->getStringValue();
index 2929c421c6a15a9ff4394219b04edff67303cfd3..b585210d9033fc3531524444e0456029a1f1706c 100644 (file)
@@ -44,7 +44,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
 
 private:
 
index d7c12fe53521d159fe9f90752f99c95ee636811c..9d1c8d9032f6014b5860835796026ab9d38b9036 100644 (file)
@@ -148,6 +148,8 @@ sgVec3 rway_ols;
 float scene_nearplane = 0.5f;
 float scene_farplane = 120000.0f;
 
+static double delta_time_sec = 0;
+
 
 #ifndef FG_NEW_ENVIRONMENT
 #  include <WeatherCM/FGLocalWeatherDatabase.h>
@@ -391,16 +393,10 @@ void trRenderFrame( void ) {
 
 
 // Update all Visuals (redraws anything graphics related)
-void fgRenderFrame( void ) {
+void fgRenderFrame() {
   
-    // Update the elapsed time.
-    current_time_stamp.stamp();
-    int dt_ms = (current_time_stamp - last_time_stamp) / 1000L;
-    globals->inc_sim_time_ms( dt_ms );
-    last_time_stamp = current_time_stamp;
-
     // Process/manage pending events
-    global_events.update( dt_ms );
+    global_events.update( delta_time_sec );
 
     static const SGPropertyNode *longitude
        = fgGetNode("/position/longitude-deg");
@@ -442,7 +438,7 @@ void fgRenderFrame( void ) {
            fgSplashUpdate(0.0);
        }
         // Keep resetting sim time while the sim is initializing
-       globals->set_sim_time_ms( 0.0 );
+       globals->set_sim_time_sec( 0.0 );
     } else {
        // idle_state is now 1000 meaning we've finished all our
        // initializations and are running the main loop, so this will
@@ -722,21 +718,21 @@ void fgRenderFrame( void ) {
        // glDisable( GL_TEXTURE_2D );
 
        // update the input subsystem
-       current_input.update(dt_ms);
+       current_input.update(delta_time_sec);
 
        // update the controls subsystem
-       globals->get_controls()->update(dt_ms);
+       globals->get_controls()->update(delta_time_sec);
 
        hud_and_panel->apply();
        fgCockpitUpdate();
 
        // Use the hud_and_panel ssgSimpleState for rendering the ATC output
        // This only works properly if called before the panel call
-       globals->get_ATC_display()->update(dt_ms);
+       globals->get_ATC_display()->update(delta_time_sec);
 
        // update the panel subsystem
        if ( current_panel != NULL ) {
-           current_panel->update(dt_ms);
+           current_panel->update(delta_time_sec);
        }
 
        // We can do translucent menus, so why not. :-)
@@ -747,7 +743,7 @@ void fgRenderFrame( void ) {
 
        // glEnable( GL_FOG );
 
-       globals->get_logger()->update(dt_ms);
+       globals->get_logger()->update(delta_time_sec);
     }
 
     glutSwapBuffers();
@@ -787,51 +783,45 @@ void fgUpdateTimeDepCalcs() {
     // instance ...
     if ( !cur_fdm_state->get_inited() ) {
        // do nothing, fdm isn't inited yet
-    } else if ( master_freeze->getBoolValue() ) {
-       // we are frozen, run the fdm's with 0 time slices in case
-       // they want to do something with that.
-
-       cur_fdm_state->update( 0 );
-       FGSteam::update( 0 );
     } else {
-       // we have been inited, and we are not frozen, we are good to go ...
+       // we have been inited, and  we are good to go ...
 
        if ( !inited ) {
-           cur_fdm_state->stamp();
+//         cur_fdm_state->stamp();
            inited = true;
        }
 
-       SGTimeStamp current;
-       current.stamp();
-       long elapsed = current - cur_fdm_state->get_time_stamp();
-       cur_fdm_state->set_time_stamp( current );
-       elapsed += cur_fdm_state->get_remainder();
-       // cout << "elapsed = " << elapsed << endl;
-       // cout << "dt = " << cur_fdm_state->get_delta_t() << endl;
-       multi_loop = (long)(((double)elapsed * 0.000001) /
-                              cur_fdm_state->get_delta_t() );
-       cur_fdm_state->set_multi_loop( multi_loop );
-       long remainder = elapsed - (long)( (multi_loop*1000000) *
-                                    cur_fdm_state->get_delta_t() );
-       cur_fdm_state->set_remainder( remainder );
-       // cout << "remainder = " << remainder << endl;
-
-       // chop max interations to something reasonable if the sim was
-       // delayed for an excesive amount of time
-       if ( multi_loop > 2.0 / cur_fdm_state->get_delta_t() ) {
-           multi_loop = (int)(2.0 / cur_fdm_state->get_delta_t());
-           cur_fdm_state->set_remainder( 0 );
-       }
-
-       // cout << "multi_loop = " << multi_loop << endl;
-       for ( i = 0; i < multi_loop * fgGetInt("/sim/speed-up"); ++i ) {
-           // run Autopilot system
-           globals->get_autopilot()->update(0); // FIXME: use real dt
+//     SGTimeStamp current;
+//     current.stamp();
+//     long elapsed = current - cur_fdm_state->get_time_stamp();
+//     cur_fdm_state->set_time_stamp( current );
+//     elapsed += cur_fdm_state->get_remainder();
+//     // cout << "elapsed = " << elapsed << endl;
+//     // cout << "dt = " << cur_fdm_state->get_delta_t() << endl;
+//     multi_loop = (long)(((double)elapsed * 0.000001) /
+//                            cur_fdm_state->get_delta_t() );
+//     cur_fdm_state->set_multi_loop( multi_loop );
+//     long remainder = elapsed - (long)( (multi_loop*1000000) *
+//                                  cur_fdm_state->get_delta_t() );
+//     cur_fdm_state->set_remainder( remainder );
+//     // cout << "remainder = " << remainder << endl;
+
+//     // chop max interations to something reasonable if the sim was
+//     // delayed for an excesive amount of time
+//     if ( multi_loop > 2.0 / cur_fdm_state->get_delta_t() ) {
+//         multi_loop = (int)(2.0 / cur_fdm_state->get_delta_t());
+//         cur_fdm_state->set_remainder( 0 );
+//     }
+
+//     // cout << "multi_loop = " << multi_loop << endl;
+//     for ( i = 0; i < multi_loop * fgGetInt("/sim/speed-up"); ++i ) {
+//         // run Autopilot system
+           globals->get_autopilot()->update(delta_time_sec);
 
            // update FDM
-           cur_fdm_state->update( 1 );
-       }
-       FGSteam::update( multi_loop * fgGetInt("/sim/speed-up") );
+           cur_fdm_state->update(delta_time_sec);
+//     }
+       FGSteam::update(delta_time_sec);
     }
 
     if ( !strcmp(fgGetString("/sim/view-mode"), "pilot") ) {
@@ -840,11 +830,11 @@ void fgUpdateTimeDepCalcs() {
     }
 
 
-    globals->get_model_mgr()->update(multi_loop);
-    globals->get_aircraft_model()->update(multi_loop);
+    globals->get_model_mgr()->update(delta_time_sec);
+    globals->get_aircraft_model()->update(delta_time_sec);
 
     // update the view angle
-    globals->get_viewmgr()->update(multi_loop);
+    globals->get_viewmgr()->update(delta_time_sec);
 
     l->UpdateAdjFog();
 
@@ -854,7 +844,7 @@ void fgUpdateTimeDepCalcs() {
                                  cur_fdm_state->get_Latitude() );
 
     // Update radio stack model
-    current_radiostack->update(multi_loop);
+    current_radiostack->update(delta_time_sec);
 }
 
 
@@ -870,6 +860,13 @@ static const double alt_adjust_m = alt_adjust_ft * SG_FEET_TO_METER;
 // What should we do when we have nothing else to do?  Let's get ready
 // for the next move and update the display?
 static void fgMainLoop( void ) {
+
+    // Update the elapsed time.
+    current_time_stamp.stamp();
+    delta_time_sec = double(current_time_stamp - last_time_stamp) / 1000000.0;
+    last_time_stamp = current_time_stamp;
+    globals->inc_sim_time_sec( delta_time_sec );
+
     static const SGPropertyNode *longitude
        = fgGetNode("/position/longitude-deg");
     static const SGPropertyNode *latitude
@@ -1035,10 +1032,10 @@ static void fgMainLoop( void ) {
 #endif
 
     // Run ATC subsystem
-    globals->get_ATC_mgr()->update(1); // FIXME - use real dt.
+    globals->get_ATC_mgr()->update(delta_time_sec);
 
     // Run the AI subsystem
-    // globals->get_AI_mgr()->update(1);       // FIXME - use real dt.
+    // globals->get_AI_mgr()->update(delta_time_sec);
 
     // Run flight model
 
index f9e62dbcf763c6c8d57a70fa1062ef7469375514..c099de9fab67549fff11b075c3594acf191da72f 100644 (file)
@@ -722,10 +722,11 @@ FGViewer::get_v_fov()
 }
 
 void
-FGViewer::update (int dt)
+FGViewer::update (double dt)
 {
   int i;
-  for ( i = 0; i < dt; i++ ) {
+  int dt_ms = int(dt * 1000);
+  for ( i = 0; i < dt_ms; i++ ) {
     if ( fabs( _goal_heading_offset_deg - _heading_offset_deg) < 1 ) {
       setHeadingOffset_deg( _goal_heading_offset_deg );
       break;
@@ -754,7 +755,7 @@ FGViewer::update (int dt)
     }
   }
 
-  for ( i = 0; i < dt; i++ ) {
+  for ( i = 0; i < dt_ms; i++ ) {
     if ( fabs( _goal_pitch_offset_deg - _pitch_offset_deg ) < 1 ) {
       setPitchOffset_deg( _goal_pitch_offset_deg );
       break;
index 0fc7125d98e7e51678826e56606d45e47bba2615..bb0eae4ef96c788984ddf6034a450617084a2f13 100644 (file)
@@ -76,7 +76,7 @@ public:
     virtual void init ();
     virtual void bind ();
     virtual void unbind ();
-    void update (int dt);
+    void update (double dt);
 
 
     //////////////////////////////////////////////////////////////////////
index ded790ebad14acc27fab8195c7ac1de33728a3f5..7dbb9a1596dc068f2606e0f8af70e09d37061161 100644 (file)
@@ -172,7 +172,7 @@ FGViewMgr::unbind ()
 }
 
 void
-FGViewMgr::update (int dt)
+FGViewMgr::update (double dt)
 {
   char stridx [20];
   double lon_deg, lat_deg, alt_ft, roll_deg, pitch_deg, heading_deg;
index 6c509f9aeeff7c88898c9249fc70537ee1c7f6f7..9cccf8c5f555e27c119eabe883121e7780275e94 100644 (file)
@@ -59,7 +59,7 @@ public:
     virtual void init ();
     virtual void bind ();
     virtual void unbind ();
-    virtual void update (int dt);
+    virtual void update (double dt);
 
     // getters
     inline int size() const { return views.size(); }
index 64ef9e747d5f0fb0c63d96114a5a012863a14f88..b56578a9b0858aeef07414857f439d0e1f51541e 100644 (file)
@@ -70,7 +70,7 @@ FGAircraftModel::unbind ()
 }
 
 void
-FGAircraftModel::update (int dt)
+FGAircraftModel::update (double dt)
 {
   int view_number = globals->get_viewmgr()->get_current();
 
index 2898c2e9313e33169722dbfb2f5ab6872133c11b..4e691ca0a12244ea43895b45ce8e86aa61375edb 100644 (file)
@@ -34,7 +34,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
   virtual void draw ();
   virtual FG3DModel * get3DModel() { return _aircraft; }
 
index 1baf886735dd4e9760aaeaddc94ca080fd010fde..f13c8e13a575e39586cdf8adb9146f3830c08e16 100644 (file)
@@ -242,7 +242,7 @@ FG3DModel::init (const string &path)
 }
 
 void
-FG3DModel::update (int dt)
+FG3DModel::update (double dt)
 {
   unsigned int i;
 
@@ -412,7 +412,7 @@ FG3DModel::NullAnimation::init (ssgEntity * object,
 }
 
 void
-FG3DModel::NullAnimation::update (int dt)
+FG3DModel::NullAnimation::update (double dt)
 {
 }
 
@@ -445,7 +445,7 @@ FG3DModel::RangeAnimation::init (ssgEntity * object,
 }
 
 void
-FG3DModel::RangeAnimation::update (int dt)
+FG3DModel::RangeAnimation::update (double dt)
 {
 }
 
@@ -477,7 +477,7 @@ FG3DModel::BillboardAnimation::init (ssgEntity * object,
 }
 
 void
-FG3DModel::BillboardAnimation::update (int dt)
+FG3DModel::BillboardAnimation::update (double dt)
 {
 }
 
@@ -512,7 +512,7 @@ FG3DModel::SelectAnimation::init (ssgEntity * object,
 }
 
 void
-FG3DModel::SelectAnimation::update (int dt)
+FG3DModel::SelectAnimation::update (double dt)
 {
   if (_condition != 0 && _condition->test()) 
     _selector->select(0xffff);
@@ -559,9 +559,9 @@ FG3DModel::SpinAnimation::init (ssgEntity * object,
 }
 
 void
-FG3DModel::SpinAnimation::update (int dt)
+FG3DModel::SpinAnimation::update (double dt)
 {
-  float velocity_rpms = (_prop->getDoubleValue() * _factor / 60000.0);
+  float velocity_rpms = (_prop->getDoubleValue() * _factor / 60.0);
   _position_deg += (dt * velocity_rpms * 360);
   while (_position_deg < 0)
     _position_deg += 360.0;
@@ -627,7 +627,7 @@ FG3DModel::RotateAnimation::init (ssgEntity * object,
 }
 
 void
-FG3DModel::RotateAnimation::update (int dt)
+FG3DModel::RotateAnimation::update (double dt)
 {
   if (_table == 0) {
     _position_deg = (_prop->getDoubleValue() + _offset_deg) * _factor;
@@ -695,7 +695,7 @@ FG3DModel::TranslateAnimation::init (ssgEntity * object,
 }
 
 void
-FG3DModel::TranslateAnimation::update (int dt)
+FG3DModel::TranslateAnimation::update (double dt)
 {
   if (_table == 0) {
     _position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
index 266702622179e83f79820ad104c15da5756c54bc..bc48663acd0a16c467ac508496482d5949882ece 100644 (file)
@@ -47,7 +47,7 @@ public:
   virtual ~FG3DModel ();
 
   virtual void init (const string &path);
-  virtual void update (int dt);
+  virtual void update (double dt);
 
   virtual bool getVisible () const;
   virtual void setVisible (bool visible);
@@ -130,9 +130,9 @@ private:
     /**
      * Update the animation.
      *
-     * @param dt The elapsed time in milliseconds since the last call.
+     * @param dt The elapsed time in seconds since the last call.
      */
-    virtual void update (int dt) = 0;
+    virtual void update (double dt) = 0;
 
   };
 
@@ -146,7 +146,7 @@ private:
     NullAnimation ();
     virtual ~NullAnimation ();
     virtual void init (ssgEntity * object, SGPropertyNode * props);
-    virtual void update (int dt);
+    virtual void update (double dt);
   private:
     ssgBranch * _branch;
   };
@@ -161,7 +161,7 @@ private:
     RangeAnimation ();
     virtual ~RangeAnimation ();
     virtual void init (ssgEntity * object, SGPropertyNode * props);
-    virtual void update (int dt);
+    virtual void update (double dt);
   private:
     ssgRangeSelector * _branch;
   };
@@ -176,7 +176,7 @@ private:
     BillboardAnimation ();
     virtual ~BillboardAnimation ();
     virtual void init (ssgEntity * object, SGPropertyNode * props);
-    virtual void update (int dt);
+    virtual void update (double dt);
   private:
     ssgCutout * _branch;
   };
@@ -191,7 +191,7 @@ private:
     SelectAnimation ();
     virtual ~SelectAnimation ();
     virtual void init (ssgEntity * object, SGPropertyNode * props);
-    virtual void update (int dt);
+    virtual void update (double dt);
   private:
     FGCondition * _condition;
     ssgSelector * _selector;
@@ -209,7 +209,7 @@ private:
     SpinAnimation ();
     virtual ~SpinAnimation ();
     virtual void init (ssgEntity * object, SGPropertyNode * props);
-    virtual void update (int dt);
+    virtual void update (double dt);
   private:
     SGPropertyNode * _prop;
     double _factor;
@@ -232,7 +232,7 @@ private:
     RotateAnimation ();
     virtual ~RotateAnimation ();
     virtual void init (ssgEntity * object, SGPropertyNode * props);
-    virtual void update (int dt);
+    virtual void update (double dt);
   private:
     SGPropertyNode * _prop;
     double _offset_deg;
@@ -259,7 +259,7 @@ private:
     TranslateAnimation ();
     virtual ~TranslateAnimation ();
     virtual void init (ssgEntity * object, SGPropertyNode * props);
-    virtual void update (int dt);
+    virtual void update (double dt);
   private:
     SGPropertyNode * _prop;
     double _offset_m;
index 680230897cec7562978e3dd94abb9750212412cc..ead08801c489cb8ac194fce11f2f89f009e609cc 100644 (file)
@@ -97,7 +97,7 @@ FGModelMgr::unbind ()
 }
 
 void
-FGModelMgr::update (int dt)
+FGModelMgr::update (double dt)
 {
   for (int i = 0; i < _instances.size(); i++) {
     Instance * instance = _instances[i];
index 84e25839c9d5bc2eb7fb7d8382ced2bcb3df867f..8f953875a5c0130d27858ce3859f6a1e373a63df 100644 (file)
@@ -36,7 +36,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
 
   virtual void draw ();
 
index 0f78f66ac149ffb9c9c5cfbfa10ed0350c2fbf74..51891c0621826ac6a202564adc8a9df96759e10e 100644 (file)
@@ -61,7 +61,7 @@ FGScenery::~FGScenery() {
 void FGScenery::init() {
 }
 
-void FGScenery::update(int dt) {
+void FGScenery::update(double dt) {
 }
 
 void FGScenery::bind() {
index 4e4531dfe10ddda7dafafab9d84d879aa4c6a100..45ae6a9d73697af9d9f705e2317dd1eb0d775928 100644 (file)
@@ -67,7 +67,7 @@ public:
     void init ();
     void bind ();
     void unbind ();
-    void update (int dt);
+    void update (double dt);
 
     inline double get_cur_elev() const { return cur_elev; }
     inline void set_cur_elev( double e ) { cur_elev = e; }
index 0c31746c0ad0c11ef677389d181794241d6a5d02..f8d05d4c2bf056edf6f20d3f995ec91e04829412 100644 (file)
@@ -95,7 +95,7 @@ FGFX::unbind ()
 }
 
 void
-FGFX::update (int dt)
+FGFX::update (double dt)
 {
    for (unsigned int i = 0; i < _sound.size(); i++ )
       _sound[i]->update(dt);
index 6e59abb67b0b0433e83a0255833550a7b8d2f6ec..aaed5ae064d92cd43dde23327f550782657e2665 100644 (file)
@@ -47,7 +47,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
 
 private:
 
index 51b7ecb72ee5eba4b4ae49eb8fdf189d8a745c98..8890d796e54e10c02ce1b57cfbfa3c6c7a9554f3 100644 (file)
@@ -251,7 +251,7 @@ FGSound::unbind ()
 }
 
 void
-FGSound::update (int dt)
+FGSound::update (double dt)
 {
    double curr_value = 0.0;
 
index 04dda074b9845ccdc33312ec3ecf4149a4b2d81e..8774562b24347a594d23e97ff930e3b7c3a78867 100644 (file)
@@ -48,7 +48,7 @@ public:
   virtual void init (SGPropertyNode *);
   virtual void bind ();
   virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
 
 protected:
 
index fb805428d0037c3b25346ccba52852d4ea6ed65d..2b7e25576c4dee1eb1686c4fe3eb14c3d7f2cfad 100644 (file)
@@ -191,7 +191,8 @@ void FGSoundMgr::unbind ()
 
 
 // run the audio scheduler
-void FGSoundMgr::update(int dt) {
+void FGSoundMgr::update(double dt) {
+                               // FIXME: use dt supplied (seconds)
     SGTimeStamp current;
     current.stamp();
 
index a46f31f533fdcd613ddef8a2fa72f2882b5b31a0..d9e9dd8fb6d4eb5eb3cc90ce7bb0bfb9c9a2b089 100644 (file)
@@ -144,7 +144,7 @@ public:
     /**
      * Run the audio scheduler.
      */
-    void update(int dt);
+    void update(double dt);
 
 
     /**
index 0dfb7f260afe457abcaf516e5bc57a28ced1d395..f9cc429a10095b49e220fbd794dfe0277cfc1f91 100644 (file)
@@ -142,9 +142,11 @@ FGEventMgr::unbind()
 }
 
 void
-FGEventMgr::update( int dt )
+FGEventMgr::update( double dt )
 {
-    if (dt < 0)
+    int dt_ms = int(dt * 1000);
+
+    if (dt_ms < 0)
     {
        SG_LOG( SG_GENERAL, SG_ALERT,
                "FGEventMgr::update() called with negative delta T" );
@@ -159,7 +161,7 @@ FGEventMgr::update( int dt )
     // Scan all events.  Run one whose interval has expired.
     while (first != last)
     {
-       if (first->update( dt ))
+       if (first->update( dt_ms ))
        {
            if (first->value() < min_value)
            {
index 49771181060b1c8daacb93aa72f848b7fc6daeba..54ec6ae7b46df3a35c479174dc69f151d2873837 100644 (file)
@@ -129,9 +129,9 @@ public:
 
     /*
      * Update the elapsed time for all events.
-     * @param dt elapsed time in milliseconds.
+     * @param dt elapsed time in seconds.
      */
-    void update( int dt );
+    void update( double dt );
 
     /**
      * Register a free standing function to be executed some time in the future.