Major overhaul:
- 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.
This commit is contained in:
parent
1ce573908c
commit
5a849b66e8
70 changed files with 356 additions and 206 deletions
|
@ -54,7 +54,7 @@ void FGATCDisplay::unbind() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update - this actually draws the visuals and should be called from the main Flightgear rendering loop.
|
// 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
|
// 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
|
// that the string we view only changes when the next repetition starts scrolling
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
void unbind();
|
void unbind();
|
||||||
|
|
||||||
// Display any registered messages
|
// Display any registered messages
|
||||||
void update(int dt);
|
void update(double dt);
|
||||||
|
|
||||||
// Register a single message for display after a delay of delay seconds
|
// Register a single message for display after a delay of delay seconds
|
||||||
// Will automatically stop displaying after a suitable interval.
|
// Will automatically stop displaying after a suitable interval.
|
||||||
|
|
|
@ -88,7 +88,7 @@ void FGATCMgr::init() {
|
||||||
airport_atc_map[(string)"KEMT"] = a;
|
airport_atc_map[(string)"KEMT"] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGATCMgr::update(int dt) {
|
void FGATCMgr::update(double dt) {
|
||||||
//Traverse the list of active stations.
|
//Traverse the list of active stations.
|
||||||
//Only update one class per update step to avoid the whole ATC system having to calculate between frames.
|
//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.
|
//Eventually we should only update every so many steps.
|
||||||
|
|
|
@ -154,7 +154,7 @@ public:
|
||||||
|
|
||||||
void unbind();
|
void unbind();
|
||||||
|
|
||||||
void update(int dt);
|
void update(double dt);
|
||||||
|
|
||||||
// Returns true if the airport is found in the map
|
// Returns true if the airport is found in the map
|
||||||
bool GetAirportATCDetails(string icao, AirportATC* a);
|
bool GetAirportATCDetails(string icao, AirportATC* a);
|
||||||
|
|
|
@ -421,7 +421,7 @@ static double LinearExtrapolate( double x, double x1, double y1, double x2, doub
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FGAutopilot::update (int dt)
|
FGAutopilot::update (double dt)
|
||||||
{
|
{
|
||||||
// Remove the following lines when the calling funcitons start
|
// Remove the following lines when the calling funcitons start
|
||||||
// passing in the data pointer
|
// passing in the data pointer
|
||||||
|
|
|
@ -152,7 +152,7 @@ public:
|
||||||
void init ();
|
void init ();
|
||||||
void bind ();
|
void bind ();
|
||||||
void unbind ();
|
void unbind ();
|
||||||
void update (int dt);
|
void update (double dt);
|
||||||
|
|
||||||
// Reset the autopilot system
|
// Reset the autopilot system
|
||||||
void reset(void);
|
void reset(void);
|
||||||
|
|
|
@ -269,7 +269,7 @@ FGPanel::unbind ()
|
||||||
* Update the panel.
|
* Update the panel.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
FGPanel::update (int dt)
|
FGPanel::update (double dt)
|
||||||
{
|
{
|
||||||
// TODO: cache the nodes
|
// TODO: cache the nodes
|
||||||
_visibility = fgGetBool("/sim/panel/visibility");
|
_visibility = fgGetBool("/sim/panel/visibility");
|
||||||
|
|
|
@ -141,7 +141,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
virtual void update (GLfloat winx, GLfloat winw, GLfloat winy, GLfloat winh);
|
virtual void update (GLfloat winx, GLfloat winw, GLfloat winy, GLfloat winh);
|
||||||
|
|
||||||
// transfer pointer ownership!!!
|
// transfer pointer ownership!!!
|
||||||
|
|
|
@ -143,7 +143,7 @@ FGRadioStack::init ()
|
||||||
blink.stamp();
|
blink.stamp();
|
||||||
|
|
||||||
search();
|
search();
|
||||||
update(1); // FIXME: use dt
|
update(0); // FIXME: use dt
|
||||||
|
|
||||||
// Search radio database once per second
|
// Search radio database once per second
|
||||||
global_events.Register( "fgRadioSearch()",
|
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
|
// Update the various nav values based on position and valid tuned in navs
|
||||||
void
|
void
|
||||||
FGRadioStack::update(int dt)
|
FGRadioStack::update(double dt)
|
||||||
{
|
{
|
||||||
double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
||||||
double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
|
||||||
|
|
|
@ -212,7 +212,7 @@ public:
|
||||||
void init ();
|
void init ();
|
||||||
void bind ();
|
void bind ();
|
||||||
void unbind ();
|
void unbind ();
|
||||||
void update (int dt);
|
void update (double dt);
|
||||||
|
|
||||||
// Update nav/adf radios based on current postition
|
// Update nav/adf radios based on current postition
|
||||||
void search ();
|
void search ();
|
||||||
|
|
|
@ -98,8 +98,9 @@ int FGSteam::_UpdatesPending = 1000000; /* Forces filter to reset */
|
||||||
// FIXME: no need to use static
|
// FIXME: no need to use static
|
||||||
// functions any longer.
|
// functions any longer.
|
||||||
|
|
||||||
void FGSteam::update ( int timesteps )
|
void FGSteam::update (double dt)
|
||||||
{
|
{
|
||||||
|
int timesteps = int(dt * 1000);
|
||||||
if (!isTied) {
|
if (!isTied) {
|
||||||
isTied = true;
|
isTied = true;
|
||||||
fgTie("/steam/airspeed-kt", FGSteam::get_ASI_kias);
|
fgTie("/steam/airspeed-kt", FGSteam::get_ASI_kias);
|
||||||
|
|
|
@ -53,7 +53,7 @@ class FGSteam
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void update ( int timesteps );
|
static void update ( double dt );
|
||||||
|
|
||||||
// Position
|
// Position
|
||||||
static double get_ALT_ft ();
|
static double get_ALT_ft ();
|
||||||
|
|
|
@ -206,7 +206,7 @@ FGControls::unbind ()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FGControls::update (int dt)
|
FGControls::update (double dt)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
void init ();
|
void init ();
|
||||||
void bind ();
|
void bind ();
|
||||||
void unbind ();
|
void unbind ();
|
||||||
void update (int dt);
|
void update (double dt);
|
||||||
|
|
||||||
// Reset function
|
// Reset function
|
||||||
void reset_all(void);
|
void reset_all(void);
|
||||||
|
|
|
@ -116,7 +116,7 @@ FGUserDefEnvironmentCtrl::init ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGUserDefEnvironmentCtrl::update (int dt)
|
FGUserDefEnvironmentCtrl::update (double dt)
|
||||||
{
|
{
|
||||||
double base_wind_speed = _base_wind_speed_node->getDoubleValue();
|
double base_wind_speed = _base_wind_speed_node->getDoubleValue();
|
||||||
double gust_wind_speed = _gust_wind_speed_node->getDoubleValue();
|
double gust_wind_speed = _gust_wind_speed_node->getDoubleValue();
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
virtual double getElevationFt () const { return _elev_ft; }
|
virtual double getElevationFt () const { return _elev_ft; }
|
||||||
|
|
||||||
virtual void init () = 0;
|
virtual void init () = 0;
|
||||||
virtual void update (int dt) = 0;
|
virtual void update (double dt) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
virtual ~FGUserDefEnvironmentCtrl ();
|
virtual ~FGUserDefEnvironmentCtrl ();
|
||||||
|
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ FGEnvironmentMgr::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGEnvironmentMgr::update (int dt)
|
FGEnvironmentMgr::update (double dt)
|
||||||
{
|
{
|
||||||
_controller->update(dt);
|
_controller->update(dt);
|
||||||
// FIXME: the FDMs should update themselves
|
// FIXME: the FDMs should update themselves
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the environment information for the plane's current position.
|
* Get the environment information for the plane's current position.
|
||||||
|
|
|
@ -156,7 +156,7 @@ struct {
|
||||||
|
|
||||||
|
|
||||||
FGADA::FGADA( double dt ) {
|
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
|
// Run an iteration of the EOM. This is essentially a NOP here
|
||||||
// because these values are getting filled in elsewhere based on
|
// because these values are getting filled in elsewhere based on
|
||||||
// external input.
|
// external input.
|
||||||
void FGADA::update( int multiloop ) {
|
void FGADA::update( double dt ) {
|
||||||
// cout << "FGADA::update()" << endl;
|
// cout << "FGADA::update()" << endl;
|
||||||
|
|
||||||
|
if (is_suspended())
|
||||||
|
return;
|
||||||
|
|
||||||
char Buffer[numberofbytes];
|
char Buffer[numberofbytes];
|
||||||
char OutBuffer[nbytes];
|
char OutBuffer[nbytes];
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// update position based on inputs, positions, velocities, etc.
|
// update position based on inputs, positions, velocities, etc.
|
||||||
void update(int dt);
|
void update(double dt);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -113,9 +113,14 @@ void FGBalloonSim::init() {
|
||||||
|
|
||||||
|
|
||||||
// Run an iteration of the EOM (equations of motion)
|
// Run an iteration of the EOM (equations of motion)
|
||||||
void FGBalloonSim::update( int multiloop ) {
|
void FGBalloonSim::update( double dt ) {
|
||||||
double save_alt = 0.0;
|
double save_alt = 0.0;
|
||||||
|
|
||||||
|
if (is_suspended())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int multiloop = _calc_multiloop(dt);
|
||||||
|
|
||||||
// lets try to avoid really screwing up the BalloonSim model
|
// lets try to avoid really screwing up the BalloonSim model
|
||||||
if ( get_Altitude() < -9000 ) {
|
if ( get_Altitude() < -9000 ) {
|
||||||
save_alt = get_Altitude();
|
save_alt = get_Altitude();
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// update position based on inputs, positions, velocities, etc.
|
// update position based on inputs, positions, velocities, etc.
|
||||||
void update( int multiloop );
|
void update( double dt );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
|
|
||||||
FGExternal::FGExternal( double dt ) {
|
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
|
// Run an iteration of the EOM. This is essentially a NOP here
|
||||||
// because these values are getting filled in elsewhere based on
|
// because these values are getting filled in elsewhere based on
|
||||||
// external input.
|
// external input.
|
||||||
void FGExternal::update( int multiloop ) {
|
void FGExternal::update( double dt ) {
|
||||||
// cout << "FGExternal::update()" << endl;
|
// cout << "FGExternal::update()" << endl;
|
||||||
|
|
||||||
// double time_step = (1.0 / fgGetInt("/sim/model-hz"))
|
// double time_step = (1.0 / fgGetInt("/sim/model-hz"))
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// update position based on inputs, positions, velocities, etc.
|
// update position based on inputs, positions, velocities, etc.
|
||||||
void update( int multiloop );
|
void update( double dt );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ static void net2global( FGNetFDM *net ) {
|
||||||
|
|
||||||
FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
|
FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
|
||||||
{
|
{
|
||||||
set_delta_t( dt );
|
// set_delta_t( dt );
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
|
@ -330,10 +330,13 @@ void FGExternalNet::init() {
|
||||||
// Run an iteration of the EOM. This is a NOP here because the flight
|
// 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
|
// model values are getting filled in elsewhere (most likely from some
|
||||||
// external source.)
|
// external source.)
|
||||||
void FGExternalNet::update( int multiloop ) {
|
void FGExternalNet::update( double dt ) {
|
||||||
int length;
|
int length;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
if (is_suspended())
|
||||||
|
return;
|
||||||
|
|
||||||
// Send control positions to remote fdm
|
// Send control positions to remote fdm
|
||||||
length = sizeof(ctrls);
|
length = sizeof(ctrls);
|
||||||
global2raw( &ctrls );
|
global2raw( &ctrls );
|
||||||
|
|
|
@ -87,7 +87,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// update the fdm
|
// update the fdm
|
||||||
void update( int multiloop );
|
void update( double dt );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,6 @@ FGJSBsim::FGJSBsim( double dt )
|
||||||
|
|
||||||
SGPath engine_path( globals->get_fg_root() );
|
SGPath engine_path( globals->get_fg_root() );
|
||||||
engine_path.append( "Engine" );
|
engine_path.append( "Engine" );
|
||||||
set_delta_t( dt );
|
|
||||||
State->Setdt( dt );
|
State->Setdt( dt );
|
||||||
|
|
||||||
result = fdmex->LoadModel( aircraft_path.str(),
|
result = fdmex->LoadModel( aircraft_path.str(),
|
||||||
|
@ -261,7 +260,12 @@ void FGJSBsim::init() {
|
||||||
// Run an iteration of the EOM (equations of motion)
|
// Run an iteration of the EOM (equations of motion)
|
||||||
|
|
||||||
void
|
void
|
||||||
FGJSBsim::update( int multiloop ) {
|
FGJSBsim::update( double dt ) {
|
||||||
|
|
||||||
|
if (is_suspended())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int multiloop = _calc_multiloop(dt);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -207,9 +207,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/** Update the position based on inputs, positions, velocities, etc.
|
/** Update the position based on inputs, positions, velocities, etc.
|
||||||
@param multiloop number of times to loop through the FDM
|
@param dt delta time in seconds. */
|
||||||
@return true if successful */
|
void update(double dt);
|
||||||
void update( int multiloop );
|
|
||||||
bool ToggleDataLogging(bool state);
|
bool ToggleDataLogging(bool state);
|
||||||
bool ToggleDataLogging(void);
|
bool ToggleDataLogging(void);
|
||||||
void do_trim(void);
|
void do_trim(void);
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include "LaRCsim.hxx"
|
#include "LaRCsim.hxx"
|
||||||
|
|
||||||
FGLaRCsim::FGLaRCsim( double dt ) {
|
FGLaRCsim::FGLaRCsim( double dt ) {
|
||||||
set_delta_t( dt );
|
// set_delta_t( dt );
|
||||||
|
|
||||||
speed_up = fgGetNode("/sim/speed-up", true);
|
speed_up = fgGetNode("/sim/speed-up", true);
|
||||||
aero = fgGetNode("/sim/aero", true);
|
aero = fgGetNode("/sim/aero", true);
|
||||||
|
@ -60,10 +60,10 @@ FGLaRCsim::FGLaRCsim( double dt ) {
|
||||||
I_xz = 0.000000E+00;
|
I_xz = 0.000000E+00;
|
||||||
}
|
}
|
||||||
|
|
||||||
ls_set_model_dt( get_delta_t() );
|
ls_set_model_dt(dt);
|
||||||
|
|
||||||
// Initialize our little engine that hopefully might
|
// 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
|
// 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)
|
// 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)
|
// 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") ) {
|
if ( !strcmp(aero->getStringValue(), "c172") ) {
|
||||||
// set control inputs
|
// set control inputs
|
||||||
|
@ -142,11 +147,11 @@ void FGLaRCsim::update( int multiloop ) {
|
||||||
fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
|
fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
|
||||||
fgGetDouble("/consumables/fuel/tank[0]/level-gal_us")
|
fgGetDouble("/consumables/fuel/tank[0]/level-gal_us")
|
||||||
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
|
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
|
||||||
* get_delta_t());
|
* dt);
|
||||||
fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
|
fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
|
||||||
fgGetDouble("/consumables/fuel/tank[1]/level-gal_us")
|
fgGetDouble("/consumables/fuel/tank[1]/level-gal_us")
|
||||||
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
|
- (eng.get_fuel_flow_gals_hr() / (2 * 3600))
|
||||||
* get_delta_t());
|
* dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
F_X_engine = eng.get_prop_thrust_lbs();
|
F_X_engine = eng.get_prop_thrust_lbs();
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// update position based on inputs, positions, velocities, etc.
|
// update position based on inputs, positions, velocities, etc.
|
||||||
void update( int multiloop );
|
void update( double dt );
|
||||||
|
|
||||||
// Positions
|
// Positions
|
||||||
void set_Latitude(double lat); //geocentric
|
void set_Latitude(double lat); //geocentric
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
|
|
||||||
FGMagicCarpet::FGMagicCarpet( double dt ) {
|
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)
|
// Run an iteration of the EOM (equations of motion)
|
||||||
void FGMagicCarpet::update( int multiloop ) {
|
void FGMagicCarpet::update( double dt ) {
|
||||||
// cout << "FGLaRCsim::update()" << endl;
|
// 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
|
// speed and distance traveled
|
||||||
double speed = globals->get_controls()->get_throttle( 0 ) * 2000; // meters/sec
|
double speed = globals->get_controls()->get_throttle( 0 ) * 2000; // meters/sec
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// update position based on inputs, positions, velocities, etc.
|
// update position based on inputs, positions, velocities, etc.
|
||||||
void update( int multiloop );
|
void update( double dt );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
|
|
||||||
FGNullFDM::FGNullFDM( double dt ) {
|
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
|
// 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
|
// model values are getting filled in elsewhere (most likely from some
|
||||||
// external source.)
|
// external source.)
|
||||||
void FGNullFDM::update( int multiloop ) {
|
void FGNullFDM::update( double dt ) {
|
||||||
// cout << "FGNullFDM::update()" << endl;
|
// cout << "FGNullFDM::update()" << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// update position based on inputs, positions, velocities, etc.
|
// update position based on inputs, positions, velocities, etc.
|
||||||
void update( int multiloop );
|
void update( double dt );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ FGUFO::FGUFO( double dt )
|
||||||
Aileron(0.0),
|
Aileron(0.0),
|
||||||
Elevator(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)
|
// Run an iteration of the EOM (equations of motion)
|
||||||
void FGUFO::update( int multiloop ) {
|
void FGUFO::update( double dt ) {
|
||||||
// cout << "FGLaRCsim::update()" << endl;
|
// 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
|
// read the throttle
|
||||||
double th = globals->get_controls()->get_throttle( 0 );
|
double th = globals->get_controls()->get_throttle( 0 );
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// update position based on inputs, positions, velocities, etc.
|
// update position based on inputs, positions, velocities, etc.
|
||||||
void update( int multiloop );
|
void update( double dt );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ void YASim::printDEBUG()
|
||||||
|
|
||||||
YASim::YASim(double dt)
|
YASim::YASim(double dt)
|
||||||
{
|
{
|
||||||
set_delta_t(dt);
|
// set_delta_t(dt);
|
||||||
_fdm = new FGFDM();
|
_fdm = new FGFDM();
|
||||||
|
|
||||||
_dt = dt;
|
_dt = dt;
|
||||||
|
@ -194,8 +194,13 @@ void YASim::init()
|
||||||
set_inited(true);
|
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 we're crashed, then we don't care
|
||||||
if(_fdm->getAirplane()->getModel()->isCrashed())
|
if(_fdm->getAirplane()->getModel()->isCrashed())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
virtual void bind();
|
virtual void bind();
|
||||||
|
|
||||||
// Run an iteration
|
// Run an iteration
|
||||||
virtual void update(int iterations);
|
virtual void update(double dt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void report();
|
void report();
|
||||||
|
|
|
@ -57,8 +57,9 @@ FGInterface::FGInterface() {
|
||||||
|
|
||||||
FGInterface::FGInterface( double dt ) {
|
FGInterface::FGInterface( double dt ) {
|
||||||
_setup();
|
_setup();
|
||||||
delta_t = dt;
|
// delta_t = dt;
|
||||||
remainder = elapsed = multi_loop = 0;
|
// remainder = elapsed = multi_loop = 0;
|
||||||
|
remainder = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// 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.
|
* Set default values for the state of the FDM.
|
||||||
*
|
*
|
||||||
|
@ -163,8 +179,8 @@ FGInterface::common_init ()
|
||||||
|
|
||||||
set_inited( true );
|
set_inited( true );
|
||||||
|
|
||||||
stamp();
|
// stamp();
|
||||||
set_remainder( 0 );
|
// set_remainder( 0 );
|
||||||
|
|
||||||
// Set initial position
|
// Set initial position
|
||||||
SG_LOG( SG_FLIGHT, SG_INFO, "...initializing position..." );
|
SG_LOG( SG_FLIGHT, SG_INFO, "...initializing position..." );
|
||||||
|
@ -254,14 +270,14 @@ FGInterface::bind ()
|
||||||
bound = true;
|
bound = true;
|
||||||
|
|
||||||
// Time management (read-only)
|
// Time management (read-only)
|
||||||
fgTie("/fdm/time/delta_t", this,
|
// fgTie("/fdm/time/delta_t", this,
|
||||||
&FGInterface::get_delta_t); // read-only
|
// &FGInterface::get_delta_t); // read-only
|
||||||
fgTie("/fdm/time/elapsed", this,
|
// fgTie("/fdm/time/elapsed", this,
|
||||||
&FGInterface::get_elapsed); // read-only
|
// &FGInterface::get_elapsed); // read-only
|
||||||
fgTie("/fdm/time/remainder", this,
|
// fgTie("/fdm/time/remainder", this,
|
||||||
&FGInterface::get_remainder); // read-only
|
// &FGInterface::get_remainder); // read-only
|
||||||
fgTie("/fdm/time/multi_loop", this,
|
// fgTie("/fdm/time/multi_loop", this,
|
||||||
&FGInterface::get_multi_loop); // read-only
|
// &FGInterface::get_multi_loop); // read-only
|
||||||
|
|
||||||
// Aircraft position
|
// Aircraft position
|
||||||
fgTie("/position/latitude-deg", this,
|
fgTie("/position/latitude-deg", this,
|
||||||
|
@ -405,7 +421,7 @@ FGInterface::unbind ()
|
||||||
* Update the state of the FDM (i.e. run the equations of motion).
|
* Update the state of the FDM (i.e. run the equations of motion).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
FGInterface::update (int dt)
|
FGInterface::update (double dt)
|
||||||
{
|
{
|
||||||
SG_LOG(SG_FLIGHT, SG_ALERT, "dummy update() ... SHOULDN'T BE CALLED!");
|
SG_LOG(SG_FLIGHT, SG_ALERT, "dummy update() ... SHOULDN'T BE CALLED!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/timing/timestamp.hxx>
|
// #include <simgear/timing/timestamp.hxx>
|
||||||
|
|
||||||
#include <Main/fgfs.hxx>
|
#include <Main/fgfs.hxx>
|
||||||
|
|
||||||
|
@ -124,11 +124,11 @@ private:
|
||||||
// next elapsed time. This yields a small amount of temporal
|
// next elapsed time. This yields a small amount of temporal
|
||||||
// jitter ( < dt ) but in practice seems to work well.
|
// jitter ( < dt ) but in practice seems to work well.
|
||||||
|
|
||||||
double delta_t; // delta "t"
|
// double delta_t; // delta "t"
|
||||||
SGTimeStamp time_stamp; // time stamp of last run
|
// SGTimeStamp time_stamp; // time stamp of last run
|
||||||
long elapsed; // time elapsed since last run
|
// long elapsed; // time elapsed since last run
|
||||||
long remainder; // remainder time from last run
|
double remainder; // remainder time from last run
|
||||||
int multi_loop; // number of iterations of "delta_t" to run
|
// int multi_loop; // number of iterations of "delta_t" to run
|
||||||
|
|
||||||
// Pilot location rel to ref pt
|
// Pilot location rel to ref pt
|
||||||
FG_VECTOR_3 d_pilot_rp_body_v;
|
FG_VECTOR_3 d_pilot_rp_body_v;
|
||||||
|
@ -224,7 +224,10 @@ private:
|
||||||
// SGTimeStamp valid_stamp; // time this record is valid
|
// SGTimeStamp valid_stamp; // time this record is valid
|
||||||
// SGTimeStamp next_stamp; // time this record is valid
|
// SGTimeStamp next_stamp; // time this record is valid
|
||||||
|
|
||||||
// protected:
|
protected:
|
||||||
|
|
||||||
|
int _calc_multiloop (double dt);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// deliberately not virtual so that
|
// deliberately not virtual so that
|
||||||
|
@ -400,7 +403,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update(int dt);
|
virtual void update(double dt);
|
||||||
virtual bool ToggleDataLogging(bool state) { return false; }
|
virtual bool ToggleDataLogging(bool state) { return false; }
|
||||||
virtual bool ToggleDataLogging(void) { return false; }
|
virtual bool ToggleDataLogging(void) { return false; }
|
||||||
|
|
||||||
|
@ -443,17 +446,17 @@ public:
|
||||||
void common_init();
|
void common_init();
|
||||||
|
|
||||||
// time and update management values
|
// time and update management values
|
||||||
inline double get_delta_t() const { return delta_t; }
|
// inline double get_delta_t() const { return delta_t; }
|
||||||
inline void set_delta_t( double dt ) { delta_t = dt; }
|
// inline void set_delta_t( double dt ) { delta_t = dt; }
|
||||||
inline SGTimeStamp get_time_stamp() const { return time_stamp; }
|
// inline SGTimeStamp get_time_stamp() const { return time_stamp; }
|
||||||
inline void set_time_stamp( SGTimeStamp s ) { time_stamp = s; }
|
// inline void set_time_stamp( SGTimeStamp s ) { time_stamp = s; }
|
||||||
inline void stamp() { time_stamp.stamp(); }
|
// inline void stamp() { time_stamp.stamp(); }
|
||||||
inline long get_elapsed() const { return elapsed; }
|
// inline long get_elapsed() const { return elapsed; }
|
||||||
inline void set_elapsed( long e ) { elapsed = e; }
|
// inline void set_elapsed( long e ) { elapsed = e; }
|
||||||
inline long get_remainder() const { return remainder; }
|
// inline long get_remainder() const { return remainder; }
|
||||||
inline void set_remainder( long r ) { remainder = r; }
|
// inline void set_remainder( long r ) { remainder = r; }
|
||||||
inline int get_multi_loop() const { return multi_loop; }
|
// inline int get_multi_loop() const { return multi_loop; }
|
||||||
inline void set_multi_loop( int ml ) { multi_loop = ml; }
|
// inline void set_multi_loop( int ml ) { multi_loop = ml; }
|
||||||
|
|
||||||
// Positions
|
// Positions
|
||||||
virtual void set_Latitude(double lat); // geocentric
|
virtual void set_Latitude(double lat); // geocentric
|
||||||
|
|
|
@ -217,7 +217,7 @@ FGInput::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGInput::update (int dt)
|
FGInput::update (double dt)
|
||||||
{
|
{
|
||||||
_update_keyboard();
|
_update_keyboard();
|
||||||
_update_joystick();
|
_update_joystick();
|
||||||
|
|
|
@ -191,7 +191,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -265,9 +265,9 @@ setAircraftDir (const char * dir)
|
||||||
* Return the number of milliseconds elapsed since simulation started.
|
* Return the number of milliseconds elapsed since simulation started.
|
||||||
*/
|
*/
|
||||||
static double
|
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/freeze/master", getFreeze, setFreeze);
|
||||||
fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
|
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);
|
fgTie("/sim/time/gmt", getDateString, setDateString);
|
||||||
fgSetArchivable("/sim/time/gmt");
|
fgSetArchivable("/sim/time/gmt");
|
||||||
fgTie("/sim/time/gmt-string", getGMTString);
|
fgTie("/sim/time/gmt-string", getGMTString);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
|
||||||
#include "globals.hxx"
|
#include "globals.hxx"
|
||||||
|
#include "fg_props.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,10 +12,39 @@
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
FGSubsystem::~FGSubsystem ()
|
FGSubsystem::FGSubsystem ()
|
||||||
|
: _suspended(false)
|
||||||
{
|
{
|
||||||
// NO-OP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FGSubsystem::~FGSubsystem ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
// end of fgfs.cxx
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
# include <float.h>
|
# include <float.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <simgear/misc/props.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +93,7 @@
|
||||||
* _errorNode = fgGetNode("/display/error-margin-pct", true);
|
* _errorNode = fgGetNode("/display/error-margin-pct", true);
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* void MySubsystem::update ()
|
* void MySubsystem::update (double delta_time_sec)
|
||||||
* {
|
* {
|
||||||
* do_something(_errorNode.getFloatValue());
|
* do_something(_errorNode.getFloatValue());
|
||||||
* }
|
* }
|
||||||
|
@ -100,11 +102,23 @@
|
||||||
* <p>The node returned will always be a pointer to SGPropertyNode,
|
* <p>The node returned will always be a pointer to SGPropertyNode,
|
||||||
* and the subsystem should <em>not</em> delete it in its destructor
|
* and the subsystem should <em>not</em> delete it in its destructor
|
||||||
* (the pointer belongs to the property tree, not the subsystem).</p>
|
* (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
|
class FGSubsystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
FGSubsystem ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual destructor to ensure that subclass destructors are called.
|
* Virtual destructor to ensure that subclass destructors are called.
|
||||||
*/
|
*/
|
||||||
|
@ -147,10 +161,61 @@ public:
|
||||||
* Update the subsystem.
|
* Update the subsystem.
|
||||||
*
|
*
|
||||||
* <p>FlightGear invokes this method every time the subsystem should
|
* <p>FlightGear invokes this method every time the subsystem should
|
||||||
* update its state. If the subsystem requires delta time information,
|
* update its state.</p>
|
||||||
* it should track it itself.</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 (int dt) = 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 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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ FGGlobals *globals;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FGGlobals::FGGlobals() :
|
FGGlobals::FGGlobals() :
|
||||||
sim_time_ms(0.0),
|
sim_time_sec(0.0),
|
||||||
#if defined(FX) && defined(XMESA)
|
#if defined(FX) && defined(XMESA)
|
||||||
fullscreen( true ),
|
fullscreen( true ),
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -80,7 +80,7 @@ class FGGlobals
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Number of milliseconds elapsed since the start of the program.
|
// Number of milliseconds elapsed since the start of the program.
|
||||||
double sim_time_ms;
|
double sim_time_sec;
|
||||||
|
|
||||||
// Root of FlightGear data tree
|
// Root of FlightGear data tree
|
||||||
string fg_root;
|
string fg_root;
|
||||||
|
@ -174,9 +174,9 @@ public:
|
||||||
FGGlobals();
|
FGGlobals();
|
||||||
~FGGlobals();
|
~FGGlobals();
|
||||||
|
|
||||||
inline double get_sim_time_ms () const { return sim_time_ms; }
|
inline double get_sim_time_sec () const { return sim_time_sec; }
|
||||||
inline void inc_sim_time_ms (double dt) { sim_time_ms += dt; }
|
inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
|
||||||
inline void set_sim_time_ms (double t) { sim_time_ms = t; }
|
inline void set_sim_time_sec (double t) { sim_time_sec = t; }
|
||||||
|
|
||||||
inline const string &get_fg_root () const { return fg_root; }
|
inline const string &get_fg_root () const { return fg_root; }
|
||||||
inline void set_fg_root (const string &root) { fg_root = root; }
|
inline void set_fg_root (const string &root) { fg_root = root; }
|
||||||
|
|
|
@ -77,13 +77,13 @@ FGLogger::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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++) {
|
for (unsigned int i = 0; i < _logs.size(); i++) {
|
||||||
if ((sim_time_ms - _logs[i].last_time_ms) >= _logs[i].interval_ms) {
|
if ((sim_time_ms - _logs[i].last_time_ms) >= _logs[i].interval_ms) {
|
||||||
_logs[i].last_time_ms = sim_time_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++) {
|
for (unsigned int j = 0; j < _logs[i].nodes.size(); j++) {
|
||||||
(*_logs[i].output) << _logs[i].delimiter
|
(*_logs[i].output) << _logs[i].delimiter
|
||||||
<< _logs[i].nodes[j]->getStringValue();
|
<< _logs[i].nodes[j]->getStringValue();
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,8 @@ sgVec3 rway_ols;
|
||||||
float scene_nearplane = 0.5f;
|
float scene_nearplane = 0.5f;
|
||||||
float scene_farplane = 120000.0f;
|
float scene_farplane = 120000.0f;
|
||||||
|
|
||||||
|
static double delta_time_sec = 0;
|
||||||
|
|
||||||
|
|
||||||
#ifndef FG_NEW_ENVIRONMENT
|
#ifndef FG_NEW_ENVIRONMENT
|
||||||
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||||
|
@ -391,16 +393,10 @@ void trRenderFrame( void ) {
|
||||||
|
|
||||||
|
|
||||||
// Update all Visuals (redraws anything graphics related)
|
// 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
|
// Process/manage pending events
|
||||||
global_events.update( dt_ms );
|
global_events.update( delta_time_sec );
|
||||||
|
|
||||||
static const SGPropertyNode *longitude
|
static const SGPropertyNode *longitude
|
||||||
= fgGetNode("/position/longitude-deg");
|
= fgGetNode("/position/longitude-deg");
|
||||||
|
@ -442,7 +438,7 @@ void fgRenderFrame( void ) {
|
||||||
fgSplashUpdate(0.0);
|
fgSplashUpdate(0.0);
|
||||||
}
|
}
|
||||||
// Keep resetting sim time while the sim is initializing
|
// Keep resetting sim time while the sim is initializing
|
||||||
globals->set_sim_time_ms( 0.0 );
|
globals->set_sim_time_sec( 0.0 );
|
||||||
} else {
|
} else {
|
||||||
// idle_state is now 1000 meaning we've finished all our
|
// idle_state is now 1000 meaning we've finished all our
|
||||||
// initializations and are running the main loop, so this will
|
// initializations and are running the main loop, so this will
|
||||||
|
@ -722,21 +718,21 @@ void fgRenderFrame( void ) {
|
||||||
// glDisable( GL_TEXTURE_2D );
|
// glDisable( GL_TEXTURE_2D );
|
||||||
|
|
||||||
// update the input subsystem
|
// update the input subsystem
|
||||||
current_input.update(dt_ms);
|
current_input.update(delta_time_sec);
|
||||||
|
|
||||||
// update the controls subsystem
|
// update the controls subsystem
|
||||||
globals->get_controls()->update(dt_ms);
|
globals->get_controls()->update(delta_time_sec);
|
||||||
|
|
||||||
hud_and_panel->apply();
|
hud_and_panel->apply();
|
||||||
fgCockpitUpdate();
|
fgCockpitUpdate();
|
||||||
|
|
||||||
// Use the hud_and_panel ssgSimpleState for rendering the ATC output
|
// Use the hud_and_panel ssgSimpleState for rendering the ATC output
|
||||||
// This only works properly if called before the panel call
|
// 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
|
// update the panel subsystem
|
||||||
if ( current_panel != NULL ) {
|
if ( current_panel != NULL ) {
|
||||||
current_panel->update(dt_ms);
|
current_panel->update(delta_time_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can do translucent menus, so why not. :-)
|
// We can do translucent menus, so why not. :-)
|
||||||
|
@ -747,7 +743,7 @@ void fgRenderFrame( void ) {
|
||||||
|
|
||||||
// glEnable( GL_FOG );
|
// glEnable( GL_FOG );
|
||||||
|
|
||||||
globals->get_logger()->update(dt_ms);
|
globals->get_logger()->update(delta_time_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
|
@ -787,51 +783,45 @@ void fgUpdateTimeDepCalcs() {
|
||||||
// instance ...
|
// instance ...
|
||||||
if ( !cur_fdm_state->get_inited() ) {
|
if ( !cur_fdm_state->get_inited() ) {
|
||||||
// do nothing, fdm isn't inited yet
|
// 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 {
|
} 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 ) {
|
if ( !inited ) {
|
||||||
cur_fdm_state->stamp();
|
// cur_fdm_state->stamp();
|
||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGTimeStamp current;
|
// SGTimeStamp current;
|
||||||
current.stamp();
|
// current.stamp();
|
||||||
long elapsed = current - cur_fdm_state->get_time_stamp();
|
// long elapsed = current - cur_fdm_state->get_time_stamp();
|
||||||
cur_fdm_state->set_time_stamp( current );
|
// cur_fdm_state->set_time_stamp( current );
|
||||||
elapsed += cur_fdm_state->get_remainder();
|
// elapsed += cur_fdm_state->get_remainder();
|
||||||
// cout << "elapsed = " << elapsed << endl;
|
// // cout << "elapsed = " << elapsed << endl;
|
||||||
// cout << "dt = " << cur_fdm_state->get_delta_t() << endl;
|
// // cout << "dt = " << cur_fdm_state->get_delta_t() << endl;
|
||||||
multi_loop = (long)(((double)elapsed * 0.000001) /
|
// multi_loop = (long)(((double)elapsed * 0.000001) /
|
||||||
cur_fdm_state->get_delta_t() );
|
// cur_fdm_state->get_delta_t() );
|
||||||
cur_fdm_state->set_multi_loop( multi_loop );
|
// cur_fdm_state->set_multi_loop( multi_loop );
|
||||||
long remainder = elapsed - (long)( (multi_loop*1000000) *
|
// long remainder = elapsed - (long)( (multi_loop*1000000) *
|
||||||
cur_fdm_state->get_delta_t() );
|
// cur_fdm_state->get_delta_t() );
|
||||||
cur_fdm_state->set_remainder( remainder );
|
// cur_fdm_state->set_remainder( remainder );
|
||||||
// cout << "remainder = " << remainder << endl;
|
// // cout << "remainder = " << remainder << endl;
|
||||||
|
|
||||||
// chop max interations to something reasonable if the sim was
|
// // chop max interations to something reasonable if the sim was
|
||||||
// delayed for an excesive amount of time
|
// // delayed for an excesive amount of time
|
||||||
if ( multi_loop > 2.0 / cur_fdm_state->get_delta_t() ) {
|
// if ( multi_loop > 2.0 / cur_fdm_state->get_delta_t() ) {
|
||||||
multi_loop = (int)(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 );
|
// cur_fdm_state->set_remainder( 0 );
|
||||||
}
|
// }
|
||||||
|
|
||||||
// cout << "multi_loop = " << multi_loop << endl;
|
// // cout << "multi_loop = " << multi_loop << endl;
|
||||||
for ( i = 0; i < multi_loop * fgGetInt("/sim/speed-up"); ++i ) {
|
// for ( i = 0; i < multi_loop * fgGetInt("/sim/speed-up"); ++i ) {
|
||||||
// run Autopilot system
|
// // run Autopilot system
|
||||||
globals->get_autopilot()->update(0); // FIXME: use real dt
|
globals->get_autopilot()->update(delta_time_sec);
|
||||||
|
|
||||||
// update FDM
|
// update FDM
|
||||||
cur_fdm_state->update( 1 );
|
cur_fdm_state->update(delta_time_sec);
|
||||||
}
|
// }
|
||||||
FGSteam::update( multi_loop * fgGetInt("/sim/speed-up") );
|
FGSteam::update(delta_time_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !strcmp(fgGetString("/sim/view-mode"), "pilot") ) {
|
if ( !strcmp(fgGetString("/sim/view-mode"), "pilot") ) {
|
||||||
|
@ -840,11 +830,11 @@ void fgUpdateTimeDepCalcs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
globals->get_model_mgr()->update(multi_loop);
|
globals->get_model_mgr()->update(delta_time_sec);
|
||||||
globals->get_aircraft_model()->update(multi_loop);
|
globals->get_aircraft_model()->update(delta_time_sec);
|
||||||
|
|
||||||
// update the view angle
|
// update the view angle
|
||||||
globals->get_viewmgr()->update(multi_loop);
|
globals->get_viewmgr()->update(delta_time_sec);
|
||||||
|
|
||||||
l->UpdateAdjFog();
|
l->UpdateAdjFog();
|
||||||
|
|
||||||
|
@ -854,7 +844,7 @@ void fgUpdateTimeDepCalcs() {
|
||||||
cur_fdm_state->get_Latitude() );
|
cur_fdm_state->get_Latitude() );
|
||||||
|
|
||||||
// Update radio stack model
|
// 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
|
// What should we do when we have nothing else to do? Let's get ready
|
||||||
// for the next move and update the display?
|
// for the next move and update the display?
|
||||||
static void fgMainLoop( void ) {
|
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
|
static const SGPropertyNode *longitude
|
||||||
= fgGetNode("/position/longitude-deg");
|
= fgGetNode("/position/longitude-deg");
|
||||||
static const SGPropertyNode *latitude
|
static const SGPropertyNode *latitude
|
||||||
|
@ -1035,10 +1032,10 @@ static void fgMainLoop( void ) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Run ATC subsystem
|
// 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
|
// 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
|
// Run flight model
|
||||||
|
|
||||||
|
|
|
@ -722,10 +722,11 @@ FGViewer::get_v_fov()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGViewer::update (int dt)
|
FGViewer::update (double dt)
|
||||||
{
|
{
|
||||||
int i;
|
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 ) {
|
if ( fabs( _goal_heading_offset_deg - _heading_offset_deg) < 1 ) {
|
||||||
setHeadingOffset_deg( _goal_heading_offset_deg );
|
setHeadingOffset_deg( _goal_heading_offset_deg );
|
||||||
break;
|
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 ) {
|
if ( fabs( _goal_pitch_offset_deg - _pitch_offset_deg ) < 1 ) {
|
||||||
setPitchOffset_deg( _goal_pitch_offset_deg );
|
setPitchOffset_deg( _goal_pitch_offset_deg );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
void update (int dt);
|
void update (double dt);
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -172,7 +172,7 @@ FGViewMgr::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGViewMgr::update (int dt)
|
FGViewMgr::update (double dt)
|
||||||
{
|
{
|
||||||
char stridx [20];
|
char stridx [20];
|
||||||
double lon_deg, lat_deg, alt_ft, roll_deg, pitch_deg, heading_deg;
|
double lon_deg, lat_deg, alt_ft, roll_deg, pitch_deg, heading_deg;
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
inline int size() const { return views.size(); }
|
inline int size() const { return views.size(); }
|
||||||
|
|
|
@ -70,7 +70,7 @@ FGAircraftModel::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGAircraftModel::update (int dt)
|
FGAircraftModel::update (double dt)
|
||||||
{
|
{
|
||||||
int view_number = globals->get_viewmgr()->get_current();
|
int view_number = globals->get_viewmgr()->get_current();
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
virtual void draw ();
|
virtual void draw ();
|
||||||
virtual FG3DModel * get3DModel() { return _aircraft; }
|
virtual FG3DModel * get3DModel() { return _aircraft; }
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ FG3DModel::init (const string &path)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FG3DModel::update (int dt)
|
FG3DModel::update (double dt)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ FG3DModel::NullAnimation::init (ssgEntity * object,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FG3DModel::NullAnimation::update (int dt)
|
FG3DModel::NullAnimation::update (double dt)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ FG3DModel::RangeAnimation::init (ssgEntity * object,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FG3DModel::RangeAnimation::update (int dt)
|
FG3DModel::RangeAnimation::update (double dt)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ FG3DModel::BillboardAnimation::init (ssgEntity * object,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FG3DModel::BillboardAnimation::update (int dt)
|
FG3DModel::BillboardAnimation::update (double dt)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ FG3DModel::SelectAnimation::init (ssgEntity * object,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FG3DModel::SelectAnimation::update (int dt)
|
FG3DModel::SelectAnimation::update (double dt)
|
||||||
{
|
{
|
||||||
if (_condition != 0 && _condition->test())
|
if (_condition != 0 && _condition->test())
|
||||||
_selector->select(0xffff);
|
_selector->select(0xffff);
|
||||||
|
@ -559,9 +559,9 @@ FG3DModel::SpinAnimation::init (ssgEntity * object,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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);
|
_position_deg += (dt * velocity_rpms * 360);
|
||||||
while (_position_deg < 0)
|
while (_position_deg < 0)
|
||||||
_position_deg += 360.0;
|
_position_deg += 360.0;
|
||||||
|
@ -627,7 +627,7 @@ FG3DModel::RotateAnimation::init (ssgEntity * object,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FG3DModel::RotateAnimation::update (int dt)
|
FG3DModel::RotateAnimation::update (double dt)
|
||||||
{
|
{
|
||||||
if (_table == 0) {
|
if (_table == 0) {
|
||||||
_position_deg = (_prop->getDoubleValue() + _offset_deg) * _factor;
|
_position_deg = (_prop->getDoubleValue() + _offset_deg) * _factor;
|
||||||
|
@ -695,7 +695,7 @@ FG3DModel::TranslateAnimation::init (ssgEntity * object,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FG3DModel::TranslateAnimation::update (int dt)
|
FG3DModel::TranslateAnimation::update (double dt)
|
||||||
{
|
{
|
||||||
if (_table == 0) {
|
if (_table == 0) {
|
||||||
_position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
|
_position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
virtual ~FG3DModel ();
|
virtual ~FG3DModel ();
|
||||||
|
|
||||||
virtual void init (const string &path);
|
virtual void init (const string &path);
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
virtual bool getVisible () const;
|
virtual bool getVisible () const;
|
||||||
virtual void setVisible (bool visible);
|
virtual void setVisible (bool visible);
|
||||||
|
@ -130,9 +130,9 @@ private:
|
||||||
/**
|
/**
|
||||||
* Update the animation.
|
* 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 ();
|
NullAnimation ();
|
||||||
virtual ~NullAnimation ();
|
virtual ~NullAnimation ();
|
||||||
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
private:
|
private:
|
||||||
ssgBranch * _branch;
|
ssgBranch * _branch;
|
||||||
};
|
};
|
||||||
|
@ -161,7 +161,7 @@ private:
|
||||||
RangeAnimation ();
|
RangeAnimation ();
|
||||||
virtual ~RangeAnimation ();
|
virtual ~RangeAnimation ();
|
||||||
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
private:
|
private:
|
||||||
ssgRangeSelector * _branch;
|
ssgRangeSelector * _branch;
|
||||||
};
|
};
|
||||||
|
@ -176,7 +176,7 @@ private:
|
||||||
BillboardAnimation ();
|
BillboardAnimation ();
|
||||||
virtual ~BillboardAnimation ();
|
virtual ~BillboardAnimation ();
|
||||||
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
private:
|
private:
|
||||||
ssgCutout * _branch;
|
ssgCutout * _branch;
|
||||||
};
|
};
|
||||||
|
@ -191,7 +191,7 @@ private:
|
||||||
SelectAnimation ();
|
SelectAnimation ();
|
||||||
virtual ~SelectAnimation ();
|
virtual ~SelectAnimation ();
|
||||||
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
private:
|
private:
|
||||||
FGCondition * _condition;
|
FGCondition * _condition;
|
||||||
ssgSelector * _selector;
|
ssgSelector * _selector;
|
||||||
|
@ -209,7 +209,7 @@ private:
|
||||||
SpinAnimation ();
|
SpinAnimation ();
|
||||||
virtual ~SpinAnimation ();
|
virtual ~SpinAnimation ();
|
||||||
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
private:
|
private:
|
||||||
SGPropertyNode * _prop;
|
SGPropertyNode * _prop;
|
||||||
double _factor;
|
double _factor;
|
||||||
|
@ -232,7 +232,7 @@ private:
|
||||||
RotateAnimation ();
|
RotateAnimation ();
|
||||||
virtual ~RotateAnimation ();
|
virtual ~RotateAnimation ();
|
||||||
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
private:
|
private:
|
||||||
SGPropertyNode * _prop;
|
SGPropertyNode * _prop;
|
||||||
double _offset_deg;
|
double _offset_deg;
|
||||||
|
@ -259,7 +259,7 @@ private:
|
||||||
TranslateAnimation ();
|
TranslateAnimation ();
|
||||||
virtual ~TranslateAnimation ();
|
virtual ~TranslateAnimation ();
|
||||||
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
virtual void init (ssgEntity * object, SGPropertyNode * props);
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
private:
|
private:
|
||||||
SGPropertyNode * _prop;
|
SGPropertyNode * _prop;
|
||||||
double _offset_m;
|
double _offset_m;
|
||||||
|
|
|
@ -97,7 +97,7 @@ FGModelMgr::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGModelMgr::update (int dt)
|
FGModelMgr::update (double dt)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _instances.size(); i++) {
|
for (int i = 0; i < _instances.size(); i++) {
|
||||||
Instance * instance = _instances[i];
|
Instance * instance = _instances[i];
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
virtual void draw ();
|
virtual void draw ();
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ FGScenery::~FGScenery() {
|
||||||
void FGScenery::init() {
|
void FGScenery::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGScenery::update(int dt) {
|
void FGScenery::update(double dt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGScenery::bind() {
|
void FGScenery::bind() {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
void init ();
|
void init ();
|
||||||
void bind ();
|
void bind ();
|
||||||
void unbind ();
|
void unbind ();
|
||||||
void update (int dt);
|
void update (double dt);
|
||||||
|
|
||||||
inline double get_cur_elev() const { return cur_elev; }
|
inline double get_cur_elev() const { return cur_elev; }
|
||||||
inline void set_cur_elev( double e ) { cur_elev = e; }
|
inline void set_cur_elev( double e ) { cur_elev = e; }
|
||||||
|
|
|
@ -95,7 +95,7 @@ FGFX::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGFX::update (int dt)
|
FGFX::update (double dt)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < _sound.size(); i++ )
|
for (unsigned int i = 0; i < _sound.size(); i++ )
|
||||||
_sound[i]->update(dt);
|
_sound[i]->update(dt);
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
virtual void init ();
|
virtual void init ();
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,7 @@ FGSound::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGSound::update (int dt)
|
FGSound::update (double dt)
|
||||||
{
|
{
|
||||||
double curr_value = 0.0;
|
double curr_value = 0.0;
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
virtual void init (SGPropertyNode *);
|
virtual void init (SGPropertyNode *);
|
||||||
virtual void bind ();
|
virtual void bind ();
|
||||||
virtual void unbind ();
|
virtual void unbind ();
|
||||||
virtual void update (int dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,8 @@ void FGSoundMgr::unbind ()
|
||||||
|
|
||||||
|
|
||||||
// run the audio scheduler
|
// run the audio scheduler
|
||||||
void FGSoundMgr::update(int dt) {
|
void FGSoundMgr::update(double dt) {
|
||||||
|
// FIXME: use dt supplied (seconds)
|
||||||
SGTimeStamp current;
|
SGTimeStamp current;
|
||||||
current.stamp();
|
current.stamp();
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Run the audio scheduler.
|
* Run the audio scheduler.
|
||||||
*/
|
*/
|
||||||
void update(int dt);
|
void update(double dt);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -142,9 +142,11 @@ FGEventMgr::unbind()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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,
|
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||||
"FGEventMgr::update() called with negative delta T" );
|
"FGEventMgr::update() called with negative delta T" );
|
||||||
|
@ -159,7 +161,7 @@ FGEventMgr::update( int dt )
|
||||||
// Scan all events. Run one whose interval has expired.
|
// Scan all events. Run one whose interval has expired.
|
||||||
while (first != last)
|
while (first != last)
|
||||||
{
|
{
|
||||||
if (first->update( dt ))
|
if (first->update( dt_ms ))
|
||||||
{
|
{
|
||||||
if (first->value() < min_value)
|
if (first->value() < min_value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,9 +129,9 @@ public:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the elapsed time for all events.
|
* 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.
|
* Register a free standing function to be executed some time in the future.
|
||||||
|
|
Loading…
Reference in a new issue