#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>
// 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 ) {
// 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
// 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
// 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;
// update the flight model
if ( multi_loop < 0 ) {
- multi_loop = DEFAULT_MULTILOOP;
+ multi_loop = 1;
}
if ( !t->getPause() ) {
// 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 ) {
// 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 );
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" );
}
}
// Flight Model options
flight_model( FGInterface::FG_LARCSIM ),
+ model_hz( NEW_DEFAULT_MODEL_HZ ),
speed_up( 1 ),
// Rendering options
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" ) {
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");
// 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
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; }