X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FMagicCarpet.cxx;h=0402c28a50bcdb190a6310f43b9b595ba032b76d;hb=68f248879cb15562c7b026445f83caf8f2842ae9;hp=8a77931a879f900bae5d8a19b5d1a00871707418;hpb=5ea9c04c644a7e115f651132a6179d4e9d1ef8ce;p=flightgear.git diff --git a/src/FDM/MagicCarpet.cxx b/src/FDM/MagicCarpet.cxx index 8a77931a8..0402c28a5 100644 --- a/src/FDM/MagicCarpet.cxx +++ b/src/FDM/MagicCarpet.cxx @@ -2,7 +2,7 @@ // // Written by Curtis Olson, started October 1999. // -// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org +// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -33,7 +33,7 @@ FGMagicCarpet::FGMagicCarpet( double dt ) { - set_delta_t( dt ); +// set_delta_t( dt ); } @@ -44,17 +44,29 @@ FGMagicCarpet::~FGMagicCarpet() { // Initialize the Magic Carpet flight model, dt is the time increment // for each subsequent iteration through the EOM void FGMagicCarpet::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 = controls.get_throttle( 0 ) * 2000; // meters/sec + double speed = globals->get_controls()->get_throttle( 0 ) * 2000; // meters/sec + if ( globals->get_controls()->get_brake_left() > 0.0 + || globals->get_controls()->get_brake_right() > 0.0 ) + { + speed = -speed; + } + double dist = speed * time_step; double kts = speed * SG_METER_TO_NM * 3600.0; _set_V_equiv_kts( kts ); @@ -62,7 +74,7 @@ bool FGMagicCarpet::update( int multiloop ) { _set_V_ground_speed( kts ); // angle of turn - double turn_rate = controls.get_aileron() * SGD_PI_4; // radians/sec + double turn_rate = globals->get_controls()->get_aileron() * SGD_PI_4; // radians/sec double turn = turn_rate * time_step; // update euler angles @@ -72,7 +84,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, @@ -91,7 +103,7 @@ bool FGMagicCarpet::update( int multiloop ) { sgGeodToGeoc( get_Latitude(), get_Altitude(), &sl_radius, &lat_geoc ); // update altitude - double real_climb_rate = -controls.get_elevator() * 5000; // feet/sec + double real_climb_rate = -globals->get_controls()->get_elevator() * 5000; // feet/sec _set_Climb_Rate( real_climb_rate / 500.0 ); double climb = real_climb_rate * time_step; @@ -101,6 +113,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; }