YASim fix performance problem due to export to prop.tree.
This commit is contained in:
parent
76a0ea96cc
commit
a87442c6f3
6 changed files with 102 additions and 56 deletions
|
@ -133,6 +133,18 @@ void FGFDM::init()
|
||||||
_cg_x = _yasimN->getNode("cg-x-m", true);
|
_cg_x = _yasimN->getNode("cg-x-m", true);
|
||||||
_cg_y = _yasimN->getNode("cg-y-m", true);
|
_cg_y = _yasimN->getNode("cg-y-m", true);
|
||||||
_cg_z = _yasimN->getNode("cg-z-m", true);
|
_cg_z = _yasimN->getNode("cg-z-m", true);
|
||||||
|
_vxN = _yasimN->getNode("velocities/v-x", true);
|
||||||
|
_vyN = _yasimN->getNode("velocities/v-y", true);
|
||||||
|
_vzN = _yasimN->getNode("velocities/v-z", true);
|
||||||
|
_vrxN = _yasimN->getNode("velocities/vrot-x", true);
|
||||||
|
_vryN = _yasimN->getNode("velocities/vrot-y", true);
|
||||||
|
_vrzN = _yasimN->getNode("velocities/vrot-z", true);
|
||||||
|
_axN = _yasimN->getNode("accelerations/a-x", true);
|
||||||
|
_ayN = _yasimN->getNode("accelerations/a-y", true);
|
||||||
|
_azN = _yasimN->getNode("accelerations/a-z", true);
|
||||||
|
_arxN = _yasimN->getNode("accelerations/arot-x", true);
|
||||||
|
_aryN = _yasimN->getNode("accelerations/arot-y", true);
|
||||||
|
_arzN = _yasimN->getNode("accelerations/arot-z", true);
|
||||||
|
|
||||||
// Allows the user to start with something other than full fuel
|
// Allows the user to start with something other than full fuel
|
||||||
_airplane.setFuelFraction(fgGetFloat("/sim/fuel-fraction", 1));
|
_airplane.setFuelFraction(fgGetFloat("/sim/fuel-fraction", 1));
|
||||||
|
@ -626,18 +638,18 @@ void FGFDM::setOutputProperties(float dt)
|
||||||
Math::vmul33(s->orient, s->rot, rot);
|
Math::vmul33(s->orient, s->rot, rot);
|
||||||
Math::vmul33(s->orient, s->racc, racc);
|
Math::vmul33(s->orient, s->racc, racc);
|
||||||
|
|
||||||
_yasimN->getNode("velocities/v-x", true)->setFloatValue(v[0]);
|
_vxN->setFloatValue(v[0]);
|
||||||
_yasimN->getNode("velocities/v-y", true)->setFloatValue(v[1]);
|
_vyN->setFloatValue(v[1]);
|
||||||
_yasimN->getNode("velocities/v-z", true)->setFloatValue(v[2]);
|
_vzN->setFloatValue(v[2]);
|
||||||
_yasimN->getNode("velocities/vrot-x", true)->setFloatValue(rot[0]);
|
_vrxN->setFloatValue(rot[0]);
|
||||||
_yasimN->getNode("velocities/vrot-y", true)->setFloatValue(rot[1]);
|
_vryN->setFloatValue(rot[1]);
|
||||||
_yasimN->getNode("velocities/vrot-z", true)->setFloatValue(rot[2]);
|
_vrzN->setFloatValue(rot[2]);
|
||||||
_yasimN->getNode("accelerations/a-x", true)->setFloatValue(acc[0]);
|
_axN->setFloatValue(acc[0]);
|
||||||
_yasimN->getNode("accelerations/a-y", true)->setFloatValue(acc[1]);
|
_ayN->setFloatValue(acc[1]);
|
||||||
_yasimN->getNode("accelerations/a-z", true)->setFloatValue(acc[2]);
|
_azN->setFloatValue(acc[2]);
|
||||||
_yasimN->getNode("accelerations/arot-x", true)->setFloatValue(racc[0]);
|
_arxN->setFloatValue(racc[0]);
|
||||||
_yasimN->getNode("accelerations/arot-y", true)->setFloatValue(racc[1]);
|
_aryN->setFloatValue(racc[1]);
|
||||||
_yasimN->getNode("accelerations/arot-z", true)->setFloatValue(racc[2]);
|
_arzN->setFloatValue(racc[2]);
|
||||||
|
|
||||||
ControlMap* cm = _airplane.getControlMap();
|
ControlMap* cm = _airplane.getControlMap();
|
||||||
for(int i=0; i<_controlProps.size(); i++) {
|
for(int i=0; i<_controlProps.size(); i++) {
|
||||||
|
|
|
@ -106,6 +106,18 @@ private:
|
||||||
std::vector<SGPropertyNode_ptr> _tank_level_lbs;
|
std::vector<SGPropertyNode_ptr> _tank_level_lbs;
|
||||||
std::vector<ThrusterProps> _thrust_props;
|
std::vector<ThrusterProps> _thrust_props;
|
||||||
std::vector<FuelProps> _fuel_props;
|
std::vector<FuelProps> _fuel_props;
|
||||||
|
SGPropertyNode* _vxN;
|
||||||
|
SGPropertyNode* _vyN;
|
||||||
|
SGPropertyNode* _vzN;
|
||||||
|
SGPropertyNode* _vrxN;
|
||||||
|
SGPropertyNode* _vryN;
|
||||||
|
SGPropertyNode* _vrzN;
|
||||||
|
SGPropertyNode* _axN;
|
||||||
|
SGPropertyNode* _ayN;
|
||||||
|
SGPropertyNode* _azN;
|
||||||
|
SGPropertyNode* _arxN;
|
||||||
|
SGPropertyNode* _aryN;
|
||||||
|
SGPropertyNode* _arzN;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace yasim
|
}; // namespace yasim
|
||||||
|
|
|
@ -417,9 +417,6 @@ void Model::calcForces(State* s)
|
||||||
// point is different due to rotation.
|
// point is different due to rotation.
|
||||||
float faero[3];
|
float faero[3];
|
||||||
faero[0] = faero[1] = faero[2] = 0;
|
faero[0] = faero[1] = faero[2] = 0;
|
||||||
int id = 0;
|
|
||||||
SGPropertyNode_ptr n = fgGetNode("/fdm/yasim/surfaces", true);
|
|
||||||
SGPropertyNode_ptr surfN;
|
|
||||||
for(i=0; i<_surfaces.size(); i++) {
|
for(i=0; i<_surfaces.size(); i++) {
|
||||||
Surface* sf = (Surface*)_surfaces.get(i);
|
Surface* sf = (Surface*)_surfaces.get(i);
|
||||||
|
|
||||||
|
@ -430,21 +427,13 @@ void Model::calcForces(State* s)
|
||||||
|
|
||||||
float force[3], torque[3];
|
float force[3], torque[3];
|
||||||
sf->calcForce(vs, _rho, force, torque);
|
sf->calcForce(vs, _rho, force, torque);
|
||||||
id = sf->getID();
|
|
||||||
if (n != 0) {
|
|
||||||
surfN = n->getChild("surface", id, true);
|
|
||||||
surfN->getNode("f-abs", true)->setFloatValue(Math::mag3(force));
|
|
||||||
surfN->getNode("f-x", true)->setFloatValue(force[0]);
|
|
||||||
surfN->getNode("f-y", true)->setFloatValue(force[1]);
|
|
||||||
surfN->getNode("f-z", true)->setFloatValue(force[2]);
|
|
||||||
}
|
|
||||||
Math::add3(faero, force, faero);
|
Math::add3(faero, force, faero);
|
||||||
|
|
||||||
_body.addForce(pos, force);
|
_body.addForce(pos, force);
|
||||||
_body.addTorque(torque);
|
_body.addTorque(torque);
|
||||||
}
|
}
|
||||||
float ld0 = faero[2]/faero[0];
|
float ld0 = faero[2]/faero[0];
|
||||||
n = fgGetNode("/fdm/yasim/forces", true);
|
SGPropertyNode_ptr n = fgGetNode("/fdm/yasim/forces", true);
|
||||||
if (n != 0) {
|
if (n != 0) {
|
||||||
n->getNode("f0-aero-x-drag", true)->setFloatValue(faero[0]);
|
n->getNode("f0-aero-x-drag", true)->setFloatValue(faero[0]);
|
||||||
n->getNode("f0-aero-y-side", true)->setFloatValue(faero[1]);
|
n->getNode("f0-aero-y-side", true)->setFloatValue(faero[1]);
|
||||||
|
|
|
@ -35,9 +35,21 @@ Surface::Surface( Version * version ) :
|
||||||
_slatAlpha = 0;
|
_slatAlpha = 0;
|
||||||
_spoilerLift = 1;
|
_spoilerLift = 1;
|
||||||
_inducedDrag = 1;
|
_inducedDrag = 1;
|
||||||
|
_stallAlpha = 0;
|
||||||
|
_alpha = 0;
|
||||||
_surfN = fgGetNode("/fdm/yasim/surfaces", true);
|
_surfN = fgGetNode("/fdm/yasim/surfaces", true);
|
||||||
if (_surfN != 0)
|
if (_surfN != 0) {
|
||||||
_surfN = _surfN->getChild("surface", _id, true);
|
_surfN = _surfN->getChild("surface", _id, true);
|
||||||
|
_fxN = _surfN->getNode("f-x", true);
|
||||||
|
_fyN = _surfN->getNode("f-y", true);
|
||||||
|
_fzN = _surfN->getNode("f-z", true);
|
||||||
|
_fabsN = _surfN->getNode("f-abs", true);
|
||||||
|
_alphaN = _surfN->getNode("alpha", true);
|
||||||
|
_stallAlphaN = _surfN->getNode("stall-alpha", true);
|
||||||
|
_flapN = _surfN->getNode("flap-pos", true);
|
||||||
|
_slatN = _surfN->getNode("slat-pos", true);
|
||||||
|
_spoilerN = _surfN->getNode("spoiler-pos", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,7 +164,7 @@ void Surface::setFlapPos(float pos)
|
||||||
{
|
{
|
||||||
if (_flapPos != pos) {
|
if (_flapPos != pos) {
|
||||||
_flapPos = pos;
|
_flapPos = pos;
|
||||||
if (_surfN != 0) _surfN->getNode("flap-pos", true)->setFloatValue(pos);
|
if (_surfN != 0) _flapN->setFloatValue(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +183,7 @@ void Surface::setSlatPos(float pos)
|
||||||
{
|
{
|
||||||
if (_slatPos != pos) {
|
if (_slatPos != pos) {
|
||||||
_slatPos = pos;
|
_slatPos = pos;
|
||||||
if (_surfN != 0) _surfN->getNode("slat-pos", true)->setFloatValue(pos);
|
if (_surfN != 0) _slatN->setFloatValue(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,14 +191,14 @@ void Surface::setSpoilerPos(float pos)
|
||||||
{
|
{
|
||||||
if (_spoilerPos != pos) {
|
if (_spoilerPos != pos) {
|
||||||
_spoilerPos = pos;
|
_spoilerPos = pos;
|
||||||
if (_surfN != 0) _surfN->getNode("spoiler-pos", true)->setFloatValue(pos);
|
if (_surfN != 0) _spoilerN->setFloatValue(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the aerodynamic force given a wind vector v (in the
|
// Calculate the aerodynamic force given a wind vector v (in the
|
||||||
// aircraft's "local" coordinates) and an air density rho. Returns a
|
// aircraft's "local" coordinates) and an air density rho. Returns a
|
||||||
// torque about the Y axis, too.
|
// torque about the Y axis, too.
|
||||||
void Surface::calcForce(float* v, float rho, float* out, float* torque)
|
void Surface::calcForce(const float* v, const float rho, float* out, float* torque)
|
||||||
{
|
{
|
||||||
// Split v into magnitude and direction:
|
// Split v into magnitude and direction:
|
||||||
float vel = Math::mag3(v);
|
float vel = Math::mag3(v);
|
||||||
|
@ -270,6 +282,15 @@ void Surface::calcForce(float* v, float rho, float* out, float* torque)
|
||||||
float scale = 0.5f*rho*vel*vel*_c0;
|
float scale = 0.5f*rho*vel*vel*_c0;
|
||||||
Math::mul3(scale, out, out);
|
Math::mul3(scale, out, out);
|
||||||
Math::mul3(scale, torque, torque);
|
Math::mul3(scale, torque, torque);
|
||||||
|
// if we have a property tree, export info
|
||||||
|
if (_surfN != 0) {
|
||||||
|
_fabsN->setFloatValue(Math::mag3(out));
|
||||||
|
_fxN->setFloatValue(out[0]);
|
||||||
|
_fyN->setFloatValue(out[1]);
|
||||||
|
_fzN->setFloatValue(out[2]);
|
||||||
|
_alphaN->setFloatValue(_alpha);
|
||||||
|
_stallAlphaN->setFloatValue(_stallAlpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -79,7 +79,10 @@ public:
|
||||||
// Induced drag multiplier
|
// Induced drag multiplier
|
||||||
void setInducedDrag(float mul) { _inducedDrag = mul; }
|
void setInducedDrag(float mul) { _inducedDrag = mul; }
|
||||||
|
|
||||||
void calcForce(float* v, float rho, float* forceOut, float* torqueOut);
|
void calcForce(const float* v, const float rho, float* out, float* torque);
|
||||||
|
|
||||||
|
float getAlpha() { return _alpha; };
|
||||||
|
float getStallAlpha() { return _stallAlpha; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SGPropertyNode_ptr _surfN;
|
SGPropertyNode_ptr _surfN;
|
||||||
|
@ -120,6 +123,15 @@ private:
|
||||||
float _alpha;
|
float _alpha;
|
||||||
|
|
||||||
Version * _version;
|
Version * _version;
|
||||||
|
SGPropertyNode* _fxN;
|
||||||
|
SGPropertyNode* _fyN;
|
||||||
|
SGPropertyNode* _fzN;
|
||||||
|
SGPropertyNode* _stallAlphaN;
|
||||||
|
SGPropertyNode* _alphaN;
|
||||||
|
SGPropertyNode* _flapN;
|
||||||
|
SGPropertyNode* _slatN;
|
||||||
|
SGPropertyNode* _spoilerN;
|
||||||
|
SGPropertyNode* _fabsN;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace yasim
|
}; // namespace yasim
|
||||||
|
|
Loading…
Reference in a new issue