]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/MagicCarpet.cxx
- fix two bugs
[flightgear.git] / src / FDM / MagicCarpet.cxx
index b78d764743ca12d9a8af0518bb47d2b25b0a8159..f11573edf7000149c16b4510460be924822375e9 100644 (file)
@@ -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
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
 
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/point3d.hxx>
 #include <simgear/math/polar3d.hxx>
 
-#include <Controls/controls.hxx>
+#include <Aircraft/controls.hxx>
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 
@@ -33,7 +37,7 @@
 
 
 FGMagicCarpet::FGMagicCarpet( double dt ) {
-    set_delta_t( dt );
+//     set_delta_t( dt );
 }
 
 
@@ -44,20 +48,29 @@ 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_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 );
@@ -75,7 +88,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,
@@ -102,8 +115,7 @@ bool FGMagicCarpet::update( int multiloop ) {
                             sl_radius + get_Altitude() + climb );
     // cout << "sea level radius (ft) = " << sl_radius << endl;
     // cout << "(setto) sea level radius (ft) = " << get_Sea_level_radius() << endl;
+    _update_ground_elev_at_pos();
     _set_Sea_level_radius( sl_radius * SG_METER_TO_FEET);
     _set_Altitude( get_Altitude() + climb );
-
-    return true;
 }