X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FMagicCarpet.cxx;h=8450c45b37380de66d4b26615e8679a728f5edd9;hb=01f846feb21b457fe6cb59871f012cf9ad8d1828;hp=b78d764743ca12d9a8af0518bb47d2b25b0a8159;hpb=96b88e539f769c0e0d70d112d7f98f6843760e10;p=flightgear.git diff --git a/src/FDM/MagicCarpet.cxx b/src/FDM/MagicCarpet.cxx index b78d76474..8450c45b3 100644 --- a/src/FDM/MagicCarpet.cxx +++ b/src/FDM/MagicCarpet.cxx @@ -33,7 +33,7 @@ FGMagicCarpet::FGMagicCarpet( double dt ) { - set_delta_t( dt ); +// set_delta_t( dt ); } @@ -44,20 +44,27 @@ FGMagicCarpet::~FGMagicCarpet() { // Initialize the Magic Carpet flight model, dt is the time increment // for each subsequent iteration through the EOM void FGMagicCarpet::init() { - // explicitly call the superclass's - // init method first - FGInterface::init(); + common_init(); } // Run an iteration of the EOM (equations of motion) -bool 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; // speed and distance traveled double speed = globals->get_controls()->get_throttle( 0 ) * 2000; // meters/sec + if ( globals->get_controls()->get_brake( 0 ) ) { + speed = -speed; + } + double dist = speed * time_step; double kts = speed * SG_METER_TO_NM * 3600.0; _set_V_equiv_kts( kts ); @@ -75,7 +82,7 @@ bool FGMagicCarpet::update( int multiloop ) { // update (lon/lat) position double lat2, lon2, az2; - if ( speed > SG_EPSILON ) { + if ( fabs( speed ) > SG_EPSILON ) { geo_direct_wgs_84 ( get_Altitude(), get_Latitude() * SGD_RADIANS_TO_DEGREES, get_Longitude() * SGD_RADIANS_TO_DEGREES, @@ -104,6 +111,4 @@ bool FGMagicCarpet::update( int multiloop ) { // cout << "(setto) sea level radius (ft) = " << get_Sea_level_radius() << endl; _set_Sea_level_radius( sl_radius * SG_METER_TO_FEET); _set_Altitude( get_Altitude() + climb ); - - return true; }