YASIM: move updating of model from Airplane to Wing
This commit is contained in:
parent
fb6f965db7
commit
6b473fde68
3 changed files with 31 additions and 22 deletions
|
@ -310,25 +310,7 @@ float Airplane::compileWing(Wing* w)
|
|||
}
|
||||
|
||||
float wgt = 0;
|
||||
for(int i=0; i<w->numSurfaces(); i++) {
|
||||
Surface* s = (Surface*)w->getSurface(i);
|
||||
float td = s->getDragCoefficient();
|
||||
int sid = s->getID();
|
||||
|
||||
_model.addSurface(s);
|
||||
|
||||
float mass = w->getSurfaceWeight(i);
|
||||
mass = mass * Math::sqrt(mass);
|
||||
float pos[3];
|
||||
s->getPosition(pos);
|
||||
int mid = _model.getBody()->addMass(mass, pos, true);
|
||||
if (_wingsN != 0) {
|
||||
SGPropertyNode_ptr n = _wingsN->getNode("surfaces", true)->getChild("surface", sid, true);
|
||||
n->getNode("drag", true)->setFloatValue(td);
|
||||
n->getNode("mass-id", true)->setIntValue(mid);
|
||||
}
|
||||
wgt += mass;
|
||||
}
|
||||
wgt = w->updateModel(&_model);
|
||||
return wgt;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "yasim-common.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "Surface.hpp"
|
||||
#include "Wing.hpp"
|
||||
|
||||
|
@ -361,8 +362,8 @@ void Wing::writeInfoToProptree()
|
|||
float dragSum = 0;
|
||||
for(int surf=0; surf < numSurfaces(); surf++) {
|
||||
Surface* s = (Surface*)getSurface(surf);
|
||||
float td = s->getDragCoefficient();
|
||||
dragSum += td;
|
||||
float drag = s->getDragCoefficient();
|
||||
dragSum += drag;
|
||||
|
||||
float mass = getSurfaceWeight(surf);
|
||||
mass = mass * Math::sqrt(mass);
|
||||
|
@ -371,4 +372,28 @@ void Wing::writeInfoToProptree()
|
|||
_wingN->getNode("weight", true)->setFloatValue(wgt);
|
||||
_wingN->getNode("drag", true)->setFloatValue(dragSum);
|
||||
}
|
||||
|
||||
float Wing::updateModel(Model* model)
|
||||
{
|
||||
float wgt = 0;
|
||||
for(int surf=0; surf < numSurfaces(); surf++) {
|
||||
Surface* s = (Surface*)getSurface(surf);
|
||||
model->addSurface(s);
|
||||
|
||||
float mass = getSurfaceWeight(surf);
|
||||
mass = mass * Math::sqrt(mass);
|
||||
wgt += mass;
|
||||
|
||||
float pos[3];
|
||||
s->getPosition(pos);
|
||||
int mid = model->getBody()->addMass(mass, pos, true);
|
||||
if (_wingN != nullptr) {
|
||||
SGPropertyNode_ptr n = _wingN->getNode("surfaces", true)->getChild("surface", s->getID(), true);
|
||||
n->getNode("drag", true)->setFloatValue(s->getDragCoefficient());
|
||||
n->getNode("mass-id", true)->setIntValue(mid);
|
||||
}
|
||||
}
|
||||
return wgt;
|
||||
}
|
||||
|
||||
}; // namespace yasim
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
namespace yasim {
|
||||
|
||||
class Surface;
|
||||
class Model;
|
||||
|
||||
struct FlapParams {
|
||||
float start {0};
|
||||
|
@ -99,6 +100,7 @@ public:
|
|||
float getLiftRatio() const { return _liftRatio; }
|
||||
|
||||
void setPropertyNode(SGPropertyNode_ptr n) { _wingN = n; };
|
||||
float updateModel(Model* model);
|
||||
|
||||
private:
|
||||
void interp(const float* v1, const float* v2, const float frac, float* out);
|
||||
|
@ -112,7 +114,7 @@ private:
|
|||
|
||||
void addSurface(Surface* s, float weight, float twist);
|
||||
void writeInfoToProptree();
|
||||
|
||||
|
||||
|
||||
struct SurfRec { Surface * surface; float weight; };
|
||||
// all surfaces of this wing
|
||||
|
|
Loading…
Reference in a new issue