]> git.mxchange.org Git - flightgear.git/commitdiff
Maik Justus:
authorcurt <curt>
Sat, 9 Dec 2006 20:37:59 +0000 (20:37 +0000)
committercurt <curt>
Sat, 9 Dec 2006 20:37:59 +0000 (20:37 +0000)
I found a small conspicuity  in YASim. The destructor of the fdm was
never called, therefore a modification of the heli fdm (not in cvs) did
not work after reset (I tie some properties and untie them in the
destructor, but the destructor was not called and the tieing failed
after reset. I don't know if any other parts of YASim need their
destructors, at least it wastes memory.

Another small fix I have made to the turbulence.cpp. The code needed,
that (a-floor(a)) is >=0 and <1. This is analytical correct, but
numerical only for "small" values. In normal fg-operation a in this
function is always small, but with unrealistic parameters in the
aircraft config file it is not and then fg crashes (instead a crash of
the aircraft or cataputling it far away).

src/FDM/YASim/Turbulence.cpp
src/FDM/YASim/YASim.cxx
src/FDM/YASim/YASim.hxx

index da9741f7e1dd0132ab654cc0d5a25241dbf09842..4a618368098f69889b156339615fb65d79051e55 100644 (file)
@@ -138,8 +138,8 @@ void Turbulence::getTurbulence(double* loc, float alt, float* up,
     double b = (loc[1] + _off[1]) + _timeOff;
     a -= _sz * Math::floor(a * (1.0/_sz));
     b -= _sz * Math::floor(b * (1.0/_sz));
-    int x = (int)Math::floor(a);
-    int y = (int)Math::floor(b);
+    int x = ((int)Math::floor(a))&(_sz-1);
+    int y = ((int)Math::floor(b))&(_sz-1);
 
     // Convert to fractional interpolation factors
     a -= x;
index 27fcbff6d64672baa49f822b3daa06ef74b7f9d6..165a4b4aaac4cc30be73518dd89be63fd0c7db00 100644 (file)
@@ -54,6 +54,11 @@ YASim::YASim(double dt)
     _fdm->getAirplane()->getModel()->getIntegrator()->setInterval(_dt);
 }
 
+YASim::~YASim()
+{
+    delete _fdm;
+}
+
 void YASim::report()
 {
     Airplane* a = _fdm->getAirplane();
index 00771fd04f6a0f520691fd61bc0debab5165cb8d..86e9e36b356174c90d9c0454b0fc22afcd3ce749 100644 (file)
@@ -8,6 +8,7 @@ namespace yasim { class FGFDM; };
 class YASim : public FGInterface {
 public:
     YASim(double dt);
+    ~YASim();
 
     // Load externally set stuff into the FDM
     virtual void init();