]> git.mxchange.org Git - flightgear.git/commitdiff
Separate fuselage drag adjustment from that for landing gear and external weights.
authorColin Douglas Howell <colin.d.howell@gmail.com>
Thu, 8 May 2014 21:40:46 +0000 (14:40 -0700)
committerColin Douglas Howell <colin.d.howell@gmail.com>
Mon, 12 May 2014 21:29:48 +0000 (14:29 -0700)
This commit is in prepartion for the following commit, which is a bug fix for
Issue 1463 (YASim underestimates off-axis forces on fuselages).

Previously the solver would adjust the drag factor for all of an Airplane's
non-Wing Surfaces in one pass, with no attempt to distinguish Fuselage Surfaces
from the Surfaces for Gear and Weights. This makes it difficult to modify how
fuselage drag is calculated while leaving unaffected the drag for landing gear
and external weights.

Now the solver adjusts the drag for an Airplane's fuselages, landing gear, and
external weights in three separate passes. To do this, each Fuselage now has a
list of its Surfaces. The fuselage pass simply iterates through the list of
Fuselages, running through each Fuselage's list of Surfaces.

The Airplane's list of non-Wing Surfaces, "_surfs", is no longer used here, but
there may still be uses of it elsewhere.

src/FDM/YASim/Airplane.cpp
src/FDM/YASim/Airplane.hpp

index 7826fad10543aa3c14048d39e0bbaf5b1a1e89ec..3371fa7dc6c214438636cb3d51427b881928a5ec 100644 (file)
@@ -577,6 +577,7 @@ float Airplane::compileFuselage(Fuselage* f)
         s->setOrientation(o);
 
         _model.addSurface(s);
+        f->surfs.add(s);
         _surfs.add(s);
     }
     return wgt;
@@ -914,9 +915,21 @@ void Airplane::applyDragFactor(float factor)
        Wing* w = (Wing*)_vstabs.get(i);
        w->setDragScale(w->getDragScale() * applied);
     }
-    for(i=0; i<_surfs.size(); i++) {
-       Surface* s = (Surface*)_surfs.get(i);
-       s->setTotalDrag(s->getTotalDrag() * applied);
+    for(i=0; i<_fuselages.size(); i++) {
+       Fuselage* f = (Fuselage*)_fuselages.get(i);
+       int j;
+       for(j=0; j<f->surfs.size(); j++) {
+           Surface* s = (Surface*)f->surfs.get(j);
+           s->setTotalDrag(s->getTotalDrag() * applied);
+       }
+    }
+    for(i=0; i<_weights.size(); i++) {
+       WeightRec* wr = (WeightRec*)_weights.get(i);
+       wr->surf->setTotalDrag(wr->surf->getTotalDrag() * applied);
+    }
+    for(i=0; i<_gears.size(); i++) {
+       GearRec* gr = (GearRec*)_gears.get(i);
+       gr->surf->setTotalDrag(gr->surf->getTotalDrag() * applied);
     }
 }
 
index 7135561c28768ca2d6fc1c06be63b907f29481ed..a280efa8a58f168278be08a272cfe02a7ae0cac6 100644 (file)
@@ -98,7 +98,8 @@ public:
 private:
     struct Tank { float pos[3]; float cap; float fill;
                  float density; int handle; };
-    struct Fuselage { float front[3], back[3], width, taper, mid, _cx, _cy, _cz, _idrag; };
+    struct Fuselage { float front[3], back[3], width, taper, mid, _cx, _cy, _cz, _idrag;
+                     Vector surfs; };
     struct GearRec { Gear* gear; Surface* surf; float wgt; };
     struct ThrustRec { Thruster* thruster;
                       int handle; float cg[3]; float mass; };