]> git.mxchange.org Git - flightgear.git/commitdiff
Setup a user definable model hertz.
authorcurt <curt>
Wed, 1 Sep 1999 20:24:54 +0000 (20:24 +0000)
committercurt <curt>
Wed, 1 Sep 1999 20:24:54 +0000 (20:24 +0000)
src/FDM/flight.cxx
src/Include/fg_constants.h
src/Main/fg_init.cxx
src/Main/main.cxx
src/Main/options.cxx
src/Main/options.hxx

index ccc3f908c4f44f3b0aba492f96cb3b27120d2c0f..6bb94eec497e1da231609de1d0e3d4a798911151 100644 (file)
@@ -27,6 +27,7 @@
 #include <FDM/External/external.hxx>
 #include <FDM/LaRCsim/ls_interface.h>
 #include <Include/fg_constants.h>
+#include <Main/options.hxx>
 #include <Math/fg_geodesy.hxx>
 #include <Time/timestamp.hxx>
 
@@ -137,7 +138,7 @@ int fgFDMUpdate(int model, FGInterface& f, int multiloop, int time_offset) {
     // set valid time for this record
     base_fdm_state.stamp_time();
 
-    time_step = (1.0 / DEFAULT_MODEL_HZ) * multiloop;
+    time_step = (1.0 / current_options.get_model_hz()) * multiloop;
     start_elev = base_fdm_state.get_Altitude();
 
     if ( model == FGInterface::FG_SLEW ) {
index c925c7843d732e0c0041533af4ede62023b4882f..ad8ee5dbd902e88a0bc1ad45964d1d82279e3f04 100644 (file)
 
 
 // Timing constants for Flight Model updates
-#define DEFAULT_TIMER_HZ 20
-#define DEFAULT_MULTILOOP 6
-#define DEFAULT_MODEL_HZ (DEFAULT_TIMER_HZ * DEFAULT_MULTILOOP)
+#define NEW_DEFAULT_MODEL_HZ 120
 
 
 // Field of view limits
index 78418ce729e0b8af524f14814889139467b553c2..82842d392ff9b212672914d0b55b9d034fb73f25 100644 (file)
@@ -444,7 +444,7 @@ bool fgInitSubsystems( void ) {
     // above values
 
     fgFDMInit( current_options.get_flight_model(), cur_fdm_state,
-              1.0 / DEFAULT_MODEL_HZ );
+              1.0 / current_options.get_model_hz() );
 
     // I'm just sticking this here for now, it should probably move
     // eventually
@@ -562,7 +562,7 @@ void fgReInitSubsystems( void )
     // v->UpdateWorldToEye(f);
 
     fgFDMInit( current_options.get_flight_model(), cur_fdm_state, 
-              1.0 / DEFAULT_MODEL_HZ );
+              1.0 / current_options.get_model_hz() );
 
     scenery.cur_elev = f->get_Runway_altitude() * FEET_TO_METER;
 
index 8820f7f6d8ceb0701f9118f74cd7b6d1dc2367ef..fae72031ed5973aae7792c21678953a293dbd476 100644 (file)
@@ -463,7 +463,7 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
 
     // update the flight model
     if ( multi_loop < 0 ) {
-       multi_loop = DEFAULT_MULTILOOP;
+       multi_loop = 1;
     }
 
     if ( !t->getPause() ) {
@@ -527,13 +527,16 @@ void fgInitTimeDepCalcs( void ) {
     // initialize timer
 
     // #ifdef HAVE_SETITIMER
-    //   fgTimerInit( 1.0 / DEFAULT_TIMER_HZ, fgUpdateTimeDepCalcs );
+    //   fgTimerInit( 1.0 / current_options.get_model_hz(), 
+    //                fgUpdateTimeDepCalcs );
     // #endif HAVE_SETITIMER
 }
 
+
 static const double alt_adjust_ft = 3.758099;
 static const double alt_adjust_m = alt_adjust_ft * 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 ) {
@@ -646,8 +649,10 @@ static void fgMainLoop( void ) {
        // Calculate model iterations needed for next frame
        elapsed += remainder;
 
-       multi_loop = (int)(((double)elapsed * 0.000001) * DEFAULT_MODEL_HZ);
-       remainder = elapsed - ((multi_loop*1000000) / DEFAULT_MODEL_HZ);
+       multi_loop = (int)(((double)elapsed * 0.000001) * 
+                          current_options.get_model_hz());
+       remainder = elapsed - ( (multi_loop*1000000) / 
+                               current_options.get_model_hz() );
        FG_LOG( FG_ALL, FG_DEBUG, 
                "Model iterations needed = " << multi_loop
                << ", new remainder = " << remainder );
@@ -656,7 +661,8 @@ static void fgMainLoop( void ) {
        if ( multi_loop > 0 ) {
            fgUpdateTimeDepCalcs(multi_loop, remainder);
        } else {
-           FG_LOG( FG_ALL, FG_INFO, "Elapsed time is zero ... we're zinging" );
+           FG_LOG( FG_ALL, FG_DEBUG, 
+                   "Elapsed time is zero ... we're zinging" );
        }
     }
 
index 8e947097380a2061ba67c0f92eb33ee9ea035282..13832655c4d0b94b907b6a9ce5f44c8f43cb0a0d 100644 (file)
@@ -161,6 +161,7 @@ fgOPTIONS::fgOPTIONS() :
 
     // Flight Model options
     flight_model( FGInterface::FG_LARCSIM ),
+    model_hz( NEW_DEFAULT_MODEL_HZ ),
     speed_up( 1 ),
 
     // Rendering options
@@ -639,6 +640,9 @@ int fgOPTIONS::parse_option( const string& arg ) {
        fg_root = arg.substr( 10 );
     } else if ( arg.find( "--fdm=" ) != string::npos ) {
        flight_model = parse_fdm( arg.substr(6) );
+    } else if ( arg.find( "--model-hz=" ) != string::npos ) {
+       model_hz = atoi( arg.substr(11) );
+       cout << "model hz = " << model_hz << endl;
     } else if ( arg.find( "--speed=" ) != string::npos ) {
        speed_up = atoi( arg.substr(8) );
     } else if ( arg == "--fog-disable" ) {
@@ -819,6 +823,7 @@ void fgOPTIONS::usage ( void ) {
  
     printf("Flight Model:\n");
     printf("\t--fdm=abcd:  one of slew, jsb, larcsim, or external\n");
+    printf("\t--model-hz=n:  run the FDM this rate (iterations per second)\n");
     printf("\t--speed=n:  run the FDM this much faster than real time\n");
     printf("\n");
 
index 671d4083747f917d84937e1513909107ff4f1741..919e49ce98db2f16f26051583a05d048b3e9ca06 100644 (file)
@@ -126,6 +126,7 @@ private:
 
     // Flight Model options
     int flight_model;   // Flight Model:  FG_SLEW, FG_LARCSIM, etc.
+    int model_hz;       // number of FDM iterations per second
     int speed_up;       // Sim mechanics run this much faster than normal speed
 
     // Rendering options
@@ -207,6 +208,7 @@ public:
     inline bool get_panel_status() const { return panel_status; }
     inline bool get_sound() const { return sound; }
     inline int get_flight_model() const { return flight_model; }
+    inline int get_model_hz() const { return model_hz; }
     inline int get_speed_up() const { return speed_up; }
     inline void set_speed_up( int speed ) { speed_up = speed; }
     inline bool fog_enabled() const { return fog != FG_FOG_DISABLED; }