From 5d18c09c08472e35b0e8109cf60fff538dc3b43c Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 9 Dec 2006 20:37:59 +0000 Subject: [PATCH] Maik Justus: 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 | 4 ++-- src/FDM/YASim/YASim.cxx | 5 +++++ src/FDM/YASim/YASim.hxx | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/FDM/YASim/Turbulence.cpp b/src/FDM/YASim/Turbulence.cpp index da9741f7e..4a6183680 100644 --- a/src/FDM/YASim/Turbulence.cpp +++ b/src/FDM/YASim/Turbulence.cpp @@ -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; diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index 27fcbff6d..165a4b4aa 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -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(); diff --git a/src/FDM/YASim/YASim.hxx b/src/FDM/YASim/YASim.hxx index 00771fd04..86e9e36b3 100644 --- a/src/FDM/YASim/YASim.hxx +++ b/src/FDM/YASim/YASim.hxx @@ -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(); -- 2.39.5