diff --git a/src/FDM/YASim/Airplane.cpp b/src/FDM/YASim/Airplane.cpp index c5adde2f5..8941ef145 100644 --- a/src/FDM/YASim/Airplane.cpp +++ b/src/FDM/YASim/Airplane.cpp @@ -787,35 +787,35 @@ void Airplane::applyDragFactor(float factor) float applied = Math::pow(factor, SOLVE_TWEAK); _dragFactor *= applied; if(_wing) - _wing->setDragScale(_wing->getDragScale() * applied); + _wing->multiplyDragCoefficient(applied); if(_tail) - _tail->setDragScale(_tail->getDragScale() * applied); + _tail->multiplyDragCoefficient(applied); int i; for(i=0; i<_vstabs.size(); i++) { - Wing* w = (Wing*)_vstabs.get(i); - w->setDragScale(w->getDragScale() * applied); + Wing* w = (Wing*)_vstabs.get(i); + w->multiplyDragCoefficient(applied); } for(i=0; i<_fuselages.size(); i++) { - Fuselage* f = (Fuselage*)_fuselages.get(i); - int j; - for(j=0; jsurfs.size(); j++) { - Surface* s = (Surface*)f->surfs.get(j); - if( isVersionOrNewer( YASIM_VERSION_32 ) ) { - // For new YASim, the solver drag factor is only applied to - // the X axis for Fuselage Surfaces. - // The solver is tuning the coefficient for longitudinal drag, - // along the direction of flight. A fuselage's lateral drag - // is completely independent and is normally much higher; - // it won't be affected by the streamlining done to reduce - // longitudinal drag. So the solver should only adjust the - // fuselage's longitudinal (X axis) drag coefficient. - s->setXDrag(s->getXDrag() * applied); - } else { - // Originally YASim applied the drag factor to all axes - // for Fuselage Surfaces. - s->setDragCoefficient(s->getDragCoefficient() * applied); - } - } + Fuselage* f = (Fuselage*)_fuselages.get(i); + int j; + for(j=0; jsurfs.size(); j++) { + Surface* s = (Surface*)f->surfs.get(j); + if( isVersionOrNewer( YASIM_VERSION_32 ) ) { + // For new YASim, the solver drag factor is only applied to + // the X axis for Fuselage Surfaces. + // The solver is tuning the coefficient for longitudinal drag, + // along the direction of flight. A fuselage's lateral drag + // is completely independent and is normally much higher; + // it won't be affected by the streamlining done to reduce + // longitudinal drag. So the solver should only adjust the + // fuselage's longitudinal (X axis) drag coefficient. + s->setXDrag(s->getXDrag() * applied); + } else { + // Originally YASim applied the drag factor to all axes + // for Fuselage Surfaces. + s->setDragCoefficient(s->getDragCoefficient() * applied); + } + } } for(i=0; i<_weights.size(); i++) { WeightRec* wr = (WeightRec*)_weights.get(i); diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index bd689d9e2..5bad06e85 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -853,7 +853,7 @@ Wing* FGFDM::parseWing(XMLAttributes* a, const char* type, Version * version) w->setInducedDrag(0.7*attrf(a, "idrag", 1)); float effect = attrf(a, "effectiveness", 1); - w->setDragScale(w->getDragScale()*effect); + w->multiplyDragCoefficient(effect); _currObj = w; return w; diff --git a/src/FDM/YASim/Wing.cpp b/src/FDM/YASim/Wing.cpp index 00ef265cb..e4be7666e 100644 --- a/src/FDM/YASim/Wing.cpp +++ b/src/FDM/YASim/Wing.cpp @@ -253,7 +253,7 @@ void Wing::addSurface(Surface* s, float weight, float twist) _surfs.add(sr); } -void Wing::setDragScale(float scale) +void Wing::setDragCoefficient(float scale) { _dragScale = scale; for(int i=0; i<_surfs.size(); i++) { @@ -262,6 +262,11 @@ void Wing::setDragScale(float scale) } } +void Wing::multiplyDragCoefficient(float factor) +{ + setDragCoefficient(_dragScale * factor); +} + void Wing::setLiftRatio(float ratio) { _liftRatio = ratio; diff --git a/src/FDM/YASim/Wing.hpp b/src/FDM/YASim/Wing.hpp index 09d3d8cff..2a0d45868 100644 --- a/src/FDM/YASim/Wing.hpp +++ b/src/FDM/YASim/Wing.hpp @@ -90,8 +90,8 @@ public: // The overall drag coefficient for the wing as a whole. Units are // arbitrary. - void setDragScale(float scale); - float getDragScale() const { return _dragScale; } + void setDragCoefficient(float scale); + void multiplyDragCoefficient(float factor); // The ratio of force along the Z (lift) direction of each wing // segment to that along the X (drag) direction.