]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/Airplane.cpp
FGPUIDialog: fix reading from already free'd memory.
[flightgear.git] / src / FDM / YASim / Airplane.cpp
index 483da426911dcdcd73addc1da6bb6991d6068551..15fd4d683bb1d1acf3096425bf379ff9a59f4a6e 100644 (file)
@@ -1,3 +1,7 @@
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include "Atmosphere.hpp"
 #include "ControlMap.hpp"
 #include "Gear.hpp"
@@ -126,14 +130,17 @@ void Airplane::getPilotAccel(float* out)
     // Gravity
     Glue::geodUp(s->pos, out);
     Math::mul3(-9.8f, out, out);
+    Math::vmul33(s->orient, out, out);
+    out[0] = -out[0];
 
     // The regular acceleration
     float tmp[3];
-    Math::mul3(-1, s->acc, tmp);
-    Math::add3(tmp, out, out);
-
     // Convert to aircraft coordinates
-    Math::vmul33(s->orient, out, out);
+    Math::vmul33(s->orient, s->acc, tmp);
+    tmp[1] = -tmp[1];
+    tmp[2] = -tmp[2];
+
+    Math::add3(tmp, out, out);
 
     // FIXME: rotational & centripetal acceleration needed
 }
@@ -671,8 +678,8 @@ void Airplane::compile()
         t->handle = body->addMass(0, t->pos);
         totalFuel += t->cap;
     }
-    _cruiseWeight = _emptyWeight + totalFuel*0.5f;
-    _approachWeight = _emptyWeight + totalFuel*0.2f;
+    _cruiseWeight = _emptyWeight + totalFuel*_cruiseFuel;
+    _approachWeight = _emptyWeight + totalFuel*_approachFuel;
 
     body->recalc();
 
@@ -795,7 +802,7 @@ void Airplane::setupWeights(bool isApproach)
 
 void Airplane::runCruise()
 {
-    setupState(_cruiseAoA, _cruiseSpeed,_approachGlideAngle, &_cruiseState);
+    setupState(_cruiseAoA, _cruiseSpeed,_cruiseGlideAngle, &_cruiseState);
     _model.setState(&_cruiseState);
     _model.setAir(_cruiseP, _cruiseT,
                   Atmosphere::calcStdDensity(_cruiseP, _cruiseT));