YASim: changed constructor for Wing. Creating a Wing object without basic geometry data is pointless and this data cannot change during runtime.
This commit is contained in:
parent
614f05bb39
commit
6817292e73
3 changed files with 47 additions and 45 deletions
|
@ -800,37 +800,40 @@ void FGFDM::setOutputProperties(float dt)
|
||||||
|
|
||||||
Wing* FGFDM::parseWing(XMLAttributes* a, const char* type, Version * version)
|
Wing* FGFDM::parseWing(XMLAttributes* a, const char* type, Version * version)
|
||||||
{
|
{
|
||||||
Wing* w = new Wing(version);
|
|
||||||
|
|
||||||
float defDihed = 0;
|
float defDihed = 0;
|
||||||
if(eq(type, "vstab"))
|
bool mirror = true;
|
||||||
|
|
||||||
|
if(eq(type, "vstab")) {
|
||||||
defDihed = 90;
|
defDihed = 90;
|
||||||
else
|
mirror = false;
|
||||||
w->setMirror(true);
|
}
|
||||||
|
|
||||||
float pos[3];
|
float base[3];
|
||||||
pos[0] = attrf(a, "x");
|
base[0] = attrf(a, "x");
|
||||||
pos[1] = attrf(a, "y");
|
base[1] = attrf(a, "y");
|
||||||
pos[2] = attrf(a, "z");
|
base[2] = attrf(a, "z");
|
||||||
w->setBase(pos);
|
|
||||||
|
|
||||||
w->setLength(attrf(a, "length"));
|
float length = attrf(a, "length");
|
||||||
w->setChord(attrf(a, "chord"));
|
float chord = attrf(a, "chord");
|
||||||
w->setSweep(attrf(a, "sweep", 0) * DEG2RAD);
|
float sweep = attrf(a, "sweep", 0) * DEG2RAD;
|
||||||
w->setTaper(attrf(a, "taper", 1));
|
float taper = attrf(a, "taper", 1);
|
||||||
w->setDihedral(attrf(a, "dihedral", defDihed) * DEG2RAD);
|
float dihedral = attrf(a, "dihedral", defDihed) * DEG2RAD;
|
||||||
|
|
||||||
|
// These come in with positive indicating positive AoA, but the
|
||||||
|
// internals expect a rotation about the left-pointing Y axis, so
|
||||||
|
// invert the sign.
|
||||||
|
float incidence = attrf(a, "incidence", 0) * DEG2RAD * -1;
|
||||||
|
float twist = attrf(a, "twist", 0) * DEG2RAD * -1;
|
||||||
|
|
||||||
float camber = attrf(a, "camber", 0);
|
float camber = attrf(a, "camber", 0);
|
||||||
if (!version->isVersionOrNewer(Version::YASIM_VERSION_2017_2) && (camber == 0)) {
|
if (!version->isVersionOrNewer(Version::YASIM_VERSION_2017_2) && (camber == 0)) {
|
||||||
SG_LOG(SG_FLIGHT, SG_DEV_WARN, "YASIM warning: versions before 2017.2 are buggy for wings with camber=0");
|
SG_LOG(SG_FLIGHT, SG_DEV_WARN, "YASIM warning: versions before 2017.2 are buggy for wings with camber=0");
|
||||||
}
|
}
|
||||||
w->setCamber(camber);
|
|
||||||
|
|
||||||
// These come in with positive indicating positive AoA, but the
|
Wing* w = new Wing(version, mirror, base, chord, length,
|
||||||
// internals expect a rotation about the left-pointing Y axis, so
|
taper, sweep, dihedral, twist);
|
||||||
// invert the sign.
|
w->setIncidence(incidence);
|
||||||
w->setIncidence(attrf(a, "incidence", 0) * DEG2RAD * -1);
|
w->setCamber(camber);
|
||||||
w->setTwist(attrf(a, "twist", 0) * DEG2RAD * -1);
|
|
||||||
|
|
||||||
// The 70% is a magic number that sorta kinda seems to match known
|
// The 70% is a magic number that sorta kinda seems to match known
|
||||||
// throttle settings to approach speed.
|
// throttle settings to approach speed.
|
||||||
|
|
|
@ -4,10 +4,23 @@
|
||||||
|
|
||||||
namespace yasim {
|
namespace yasim {
|
||||||
|
|
||||||
Wing::Wing( Version * version ) :
|
Wing::Wing(Version *ver, bool mirror, float* base, float chord,
|
||||||
_version(version)
|
float length, float taper, float sweep, float dihedral, float twist) :
|
||||||
|
_version(ver),
|
||||||
|
_mirror(mirror),
|
||||||
|
_chord(chord),
|
||||||
|
_length(length),
|
||||||
|
_taper(taper),
|
||||||
|
_sweep(sweep),
|
||||||
|
_dihedral(dihedral),
|
||||||
|
_twist(twist)
|
||||||
{
|
{
|
||||||
|
Math::set3(base, _base);
|
||||||
|
_meanChord = _chord*(_taper+1)*0.5f;
|
||||||
|
calculateWingCoordinateSystem();
|
||||||
|
calculateTip();
|
||||||
|
calculateSpan();
|
||||||
|
calculateMAC();
|
||||||
}
|
}
|
||||||
|
|
||||||
Wing::~Wing()
|
Wing::~Wing()
|
||||||
|
@ -207,13 +220,6 @@ void Wing::compile()
|
||||||
last = bounds[i];
|
last = bounds[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateWingCoordinateSystem();
|
|
||||||
calculateTip();
|
|
||||||
_meanChord = _chord*(_taper+1)*0.5f;
|
|
||||||
|
|
||||||
calculateSpan();
|
|
||||||
calculateMAC();
|
|
||||||
|
|
||||||
// Calculate a "nominal" segment length equal to an average chord,
|
// Calculate a "nominal" segment length equal to an average chord,
|
||||||
// normalized to lie within 0-1 over the length of the wing.
|
// normalized to lie within 0-1 over the length of the wing.
|
||||||
float segLen = _meanChord / _length;
|
float segLen = _meanChord / _length;
|
||||||
|
|
|
@ -12,7 +12,8 @@ class Surface;
|
||||||
// FIXME: need to handle "inverted" controls for mirrored wings.
|
// FIXME: need to handle "inverted" controls for mirrored wings.
|
||||||
class Wing {
|
class Wing {
|
||||||
public:
|
public:
|
||||||
Wing( Version * version );
|
Wing(Version *ver, bool mirror, float* base, float chord, float length,
|
||||||
|
float taper = 1, float sweep = 0, float dihedral = 0, float twist = 0);
|
||||||
~Wing();
|
~Wing();
|
||||||
|
|
||||||
// Do we mirror ourselves about the XZ plane?
|
// Do we mirror ourselves about the XZ plane?
|
||||||
|
@ -22,26 +23,20 @@ public:
|
||||||
// Wing geometry in local coordinates:
|
// Wing geometry in local coordinates:
|
||||||
|
|
||||||
// base point of wing
|
// base point of wing
|
||||||
void setBase(const float* base) { Math::set3(base, _base); }
|
|
||||||
void getBase(float* base) const { Math::set3(_base, base); };
|
void getBase(float* base) const { Math::set3(_base, base); };
|
||||||
// dist. ALONG wing (not span!)
|
// dist. ALONG wing (not span!)
|
||||||
void setLength(float length) { _length = length; }
|
|
||||||
float getLength() const { return _length; };
|
float getLength() const { return _length; };
|
||||||
// at base, measured along X axis
|
// at base, measured along X axis
|
||||||
void setChord(float chord) { _chord = chord; }
|
|
||||||
float getChord() const { return _chord; };
|
float getChord() const { return _chord; };
|
||||||
// fraction of chord at wing tip, 0..1
|
// fraction of chord at wing tip, 0..1
|
||||||
void setTaper(float taper) { _taper = taper; }
|
|
||||||
float getTaper() const { return _taper; };
|
float getTaper() const { return _taper; };
|
||||||
// radians
|
// radians
|
||||||
void setSweep(float sweep) { _sweep = sweep; }
|
|
||||||
float getSweep() const { return _sweep; };
|
float getSweep() const { return _sweep; };
|
||||||
// radians, positive is "up"
|
// radians, positive is "up"
|
||||||
void setDihedral(float dihedral) { _dihedral = dihedral; }
|
void setDihedral(float dihedral) { _dihedral = dihedral; }
|
||||||
float getDihedral() const { return _dihedral; };
|
float getDihedral() const { return _dihedral; };
|
||||||
|
|
||||||
void setIncidence(float incidence);
|
void setIncidence(float incidence);
|
||||||
void setTwist(float angle) { _twist = angle; }
|
|
||||||
|
|
||||||
|
|
||||||
// parameters for stall curve
|
// parameters for stall curve
|
||||||
|
@ -110,11 +105,11 @@ private:
|
||||||
Vector _slatSurfs;
|
Vector _slatSurfs;
|
||||||
Vector _spoilerSurfs;
|
Vector _spoilerSurfs;
|
||||||
|
|
||||||
|
Version * _version;
|
||||||
bool _mirror {false};
|
bool _mirror {false};
|
||||||
|
|
||||||
float _base[3] {0,0,0};
|
float _base[3] {0,0,0};
|
||||||
float _length {0};
|
|
||||||
float _chord {0};
|
float _chord {0};
|
||||||
|
float _length {0};
|
||||||
float _taper {1};
|
float _taper {1};
|
||||||
float _sweep {0};
|
float _sweep {0};
|
||||||
float _dihedral {0};
|
float _dihedral {0};
|
||||||
|
@ -161,8 +156,6 @@ private:
|
||||||
float _slatEnd {0};
|
float _slatEnd {0};
|
||||||
float _slatAoA {0};
|
float _slatAoA {0};
|
||||||
float _slatDrag {0};
|
float _slatDrag {0};
|
||||||
|
|
||||||
Version * _version;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace yasim
|
}; // namespace yasim
|
||||||
|
|
Loading…
Reference in a new issue