+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "Atmosphere.hpp"
#include "ControlMap.hpp"
#include "Gear.hpp"
_liftRatio = 1;
_cruiseAoA = 0;
_tailIncidence = 0;
+
+ _failureMsg = 0;
}
Airplane::~Airplane()
// Gravity
Glue::geodUp(s->pos, out);
Math::mul3(-9.8f, out, out);
+ Math::vmul33(s->orient, out, out);
+ out[0] = -out[0];
// The regular acceleration
float tmp[3];
- Math::mul3(-1, s->acc, tmp);
- Math::add3(tmp, out, out);
-
// Convert to aircraft coordinates
- Math::vmul33(s->orient, out, out);
+ Math::vmul33(s->orient, s->acc, tmp);
+ tmp[1] = -tmp[1];
+ tmp[2] = -tmp[2];
+
+ Math::add3(tmp, out, out);
// FIXME: rotational & centripetal acceleration needed
}
return _tailIncidence;
}
-char* Airplane::getFailureMsg()
+const char* Airplane::getFailureMsg()
{
return _failureMsg;
}
float fwd[3];
Math::sub3(f->front, f->back, fwd);
float len = Math::mag3(fwd);
+ if (len == 0) {
+ _failureMsg = "Zero length fuselage";
+ return 0;
+ }
float wid = f->width;
int segs = (int)Math::ceil(len/wid);
float segWgt = len*wid/segs;
t->handle = body->addMass(0, t->pos);
totalFuel += t->cap;
}
- _cruiseWeight = _emptyWeight + totalFuel*0.5f;
- _approachWeight = _emptyWeight + totalFuel*0.2f;
+ _cruiseWeight = _emptyWeight + totalFuel*_cruiseFuel;
+ _approachWeight = _emptyWeight + totalFuel*_approachFuel;
body->recalc();
_model.setGroundEffect(gepos, gespan, 0.15f);
}
+ // solve function below resets failure message
+ // so check if we have any problems and abort here
+ if (_failureMsg) return;
+
solveGear();
if(_wing && _tail) solve();
else
void Airplane::runCruise()
{
- setupState(_cruiseAoA, _cruiseSpeed,_approachGlideAngle, &_cruiseState);
+ setupState(_cruiseAoA, _cruiseSpeed,_cruiseGlideAngle, &_cruiseState);
_model.setState(&_cruiseState);
_model.setAir(_cruiseP, _cruiseT,
Atmosphere::calcStdDensity(_cruiseP, _cruiseT));