Disable wheel button if lowering would be dangerous.
parent
1a4d57b4c0
commit
9ad8b6ced6
|
@ -110,6 +110,22 @@ void DynamicBody::SetFrame(Frame *f)
|
|||
m_externalForce = m_gravityForce = m_atmosForce = vector3d(0.0);
|
||||
}
|
||||
|
||||
double DynamicBody::CalcAtmosphericForce(double dragCoeff) const
|
||||
{
|
||||
Body *body = GetFrame()->GetBody();
|
||||
if (!body || !GetFrame()->IsRotFrame() || !body->IsType(Object::PLANET))
|
||||
return 0.0;
|
||||
Planet *planet = static_cast<Planet*>(body);
|
||||
double dist = GetPosition().Length();
|
||||
double speed = m_vel.Length();
|
||||
double pressure, density;
|
||||
planet->GetAtmosphericState(dist, &pressure, &density);
|
||||
const double radius = GetClipRadius(); // bogus, preserving behaviour
|
||||
const double area = radius;
|
||||
// ^^^ yes that is as stupid as it looks
|
||||
return 0.5*density*speed*speed*area*dragCoeff;
|
||||
}
|
||||
|
||||
void DynamicBody::CalcExternalForce()
|
||||
{
|
||||
// gravity
|
||||
|
@ -128,16 +144,8 @@ void DynamicBody::CalcExternalForce()
|
|||
// atmospheric drag
|
||||
if (body && GetFrame()->IsRotFrame() && body->IsType(Object::PLANET))
|
||||
{
|
||||
Planet *planet = static_cast<Planet*>(body);
|
||||
double dist = GetPosition().Length();
|
||||
double speed = m_vel.Length();
|
||||
double pressure, density;
|
||||
planet->GetAtmosphericState(dist, &pressure, &density);
|
||||
const double radius = GetClipRadius(); // bogus, preserving behaviour
|
||||
const double AREA = radius;
|
||||
// ^^^ yes that is as stupid as it looks
|
||||
vector3d dragDir = -m_vel.NormalizedSafe();
|
||||
vector3d fDrag = 0.5*density*speed*speed*AREA*m_dragCoeff*dragDir;
|
||||
vector3d fDrag = CalcAtmosphericForce(m_dragCoeff)*dragDir;
|
||||
|
||||
// make this a bit less daft at high time accel
|
||||
// only allow atmosForce to increase by .1g per frame
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
bool IsMoving() const { return m_isMoving; }
|
||||
virtual double GetMass() const { return m_mass; } // XXX don't override this
|
||||
virtual void TimeStepUpdate(const float timeStep);
|
||||
double CalcAtmosphericForce(double dragCoeff) const;
|
||||
void CalcExternalForce();
|
||||
void UndoTimestep();
|
||||
|
||||
|
|
|
@ -876,6 +876,13 @@ void Ship::FireWeapon(int num)
|
|||
LuaEvent::Queue("onShipFiring", this);
|
||||
}
|
||||
|
||||
double Ship::ExtrapolateHullTemperature() const
|
||||
{
|
||||
const double dragCoeff = DynamicBody::DEFAULT_DRAG_COEFF * 1.25;
|
||||
const double dragGs = CalcAtmosphericForce(dragCoeff) / (GetMass() * 9.81);
|
||||
return dragGs / 5.0;
|
||||
}
|
||||
|
||||
double Ship::GetHullTemperature() const
|
||||
{
|
||||
double dragGs = GetAtmosForce().Length() / (GetMass() * 9.81);
|
||||
|
|
|
@ -152,6 +152,8 @@ public:
|
|||
|
||||
// 0 to 1.0 is alive, > 1.0 = death
|
||||
double GetHullTemperature() const;
|
||||
// Calculate temperature we would have with wheels down
|
||||
double ExtrapolateHullTemperature() const;
|
||||
|
||||
enum ECMResult {
|
||||
ECM_NOT_INSTALLED,
|
||||
|
|
|
@ -567,6 +567,10 @@ void WorldView::RefreshButtonStateAndVisibility()
|
|||
m_game->GetCpan()->SetOverlayToolTip(ShipCpanel::OVERLAY_BOTTOM_RIGHT, Lang::SHIP_ALTITUDE_ABOVE_TERRAIN);
|
||||
}
|
||||
|
||||
if (is_equal_exact(Pi::player->GetWheelState(), 0.0f) && Pi::player->ExtrapolateHullTemperature() > 0.7)
|
||||
m_wheelsButton->Hide();
|
||||
else
|
||||
m_wheelsButton->Show();
|
||||
m_wheelsButton->SetActiveState(int(Pi::player->GetWheelState()) || Pi::player->GetWheelTransition() == 1);
|
||||
|
||||
RefreshHyperspaceButton();
|
||||
|
|
Loading…
Reference in New Issue