1
0
Fork 0

Patch from Joacim to fix a bug where rotor weights were doubled.

This commit is contained in:
andy 2007-01-10 19:03:02 +00:00
parent 23ab95802b
commit 5aa142ee5f
4 changed files with 11 additions and 19 deletions

View file

@ -482,9 +482,9 @@ float Airplane::compileWing(Wing* w)
return wgt; return wgt;
} }
float Airplane::compileRotorgear() void Airplane::compileRotorgear()
{ {
return getRotorgear()->compile(_model.getBody()); getRotorgear()->compile();
} }
float Airplane::compileFuselage(Fuselage* f) float Airplane::compileFuselage(Fuselage* f)
@ -626,8 +626,6 @@ void Airplane::compile()
for(i=0; i<_vstabs.size(); i++) for(i=0; i<_vstabs.size(); i++)
aeroWgt += compileWing((Wing*)_vstabs.get(i)); aeroWgt += compileWing((Wing*)_vstabs.get(i));
// The rotor(s)
aeroWgt += compileRotorgear();
// The fuselage(s) // The fuselage(s)
for(i=0; i<_fuselages.size(); i++) for(i=0; i<_fuselages.size(); i++)
@ -681,7 +679,12 @@ void Airplane::compile()
solveGear(); solveGear();
if(_wing && _tail) solve(); if(_wing && _tail) solve();
else solveHelicopter(); else
{
// The rotor(s) mass:
compileRotorgear();
solveHelicopter();
}
// Do this after solveGear, because it creates "gear" objects that // Do this after solveGear, because it creates "gear" objects that
// we don't want to affect. // we don't want to affect.

View file

@ -108,7 +108,7 @@ private:
void solve(); void solve();
void solveHelicopter(); void solveHelicopter();
float compileWing(Wing* w); float compileWing(Wing* w);
float compileRotorgear(); void compileRotorgear();
float compileFuselage(Fuselage* f); float compileFuselage(Fuselage* f);
void compileGear(GearRec* gr); void compileGear(GearRec* gr);
void applyDragFactor(float factor); void applyDragFactor(float factor);

View file

@ -1362,24 +1362,13 @@ void Rotorgear::addRotor(Rotor* rotor)
_in_use = 1; _in_use = 1;
} }
float Rotorgear::compile(RigidBody* body) void Rotorgear::compile()
{ {
float wgt = 0; float wgt = 0;
for(int j=0; j<_rotors.size(); j++) { for(int j=0; j<_rotors.size(); j++) {
Rotor* r = (Rotor*)_rotors.get(j); Rotor* r = (Rotor*)_rotors.get(j);
r->compile(); r->compile();
int i;
for(i=0; i<r->numRotorparts(); i++) {
Rotorpart* rp = (Rotorpart*)r->getRotorpart(i);
float mass = rp->getWeight();
mass = mass * Math::sqrt(mass);
float pos[3];
rp->getPosition(pos);
body->addMass(mass, pos);
wgt += mass;
}
} }
return wgt;
} }
void Rotorgear::getDownWash(float *pos, float * v_heli, float *downwash) void Rotorgear::getDownWash(float *pos, float * v_heli, float *downwash)

View file

@ -223,7 +223,7 @@ public:
~Rotorgear(); ~Rotorgear();
int isInUse() {return _in_use;} int isInUse() {return _in_use;}
void setInUse() {_in_use = 1;} void setInUse() {_in_use = 1;}
float compile(RigidBody* body); void compile();
void addRotor(Rotor* rotor); void addRotor(Rotor* rotor);
int getNumRotors() {return _rotors.size();} int getNumRotors() {return _rotors.size();}
Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);} Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);}