void Missile::TimeStepUpdate(const float timeStep) { const vector3d thrust=GetActualLinThrust(); AddRelForce( thrust ); AddRelTorque( GetActualAngThrust() ); DynamicBody::TimeStepUpdate(timeStep); Propulsion::UpdateFuel(timeStep); const float MISSILE_DETECTION_RADIUS = 100.0f; if (!m_owner) { Explode(); } else if (m_armed) { Space::BodyNearList nearby; Pi::game->GetSpace()->GetBodiesMaybeNear(this, MISSILE_DETECTION_RADIUS, nearby); for (Space::BodyNearIterator i = nearby.begin(); i != nearby.end(); ++i) { if (*i == this) continue; double dist = ((*i)->GetPosition() - GetPosition()).Length(); if (dist < MISSILE_DETECTION_RADIUS) { Explode(); break; } } } }
void Ship::TimeStepUpdate(const float timeStep) { // XXX why not just f*****g do this rather than track down the // reason that ship geoms are being collision tested during launch if (m_flightState == FLYING) Enable(); else Disable(); vector3d maxThrust = GetMaxThrust(m_thrusters); AddRelForce(vector3d(maxThrust.x*m_thrusters.x, maxThrust.y*m_thrusters.y, maxThrust.z*m_thrusters.z)); AddRelTorque(GetShipType().angThrust * m_angThrusters); DynamicBody::TimeStepUpdate(timeStep); }
void Ship::TimeStepUpdate(const float timeStep) { // If docked, station is responsible for updating position/orient of ship // but we call this crap anyway and hope it doesn't do anything bad vector3d maxThrust = GetMaxThrust(m_thrusters); vector3d thrust = vector3d(maxThrust.x*m_thrusters.x, maxThrust.y*m_thrusters.y, maxThrust.z*m_thrusters.z); AddRelForce(thrust); AddRelTorque(GetShipType().angThrust * m_angThrusters); DynamicBody::TimeStepUpdate(timeStep); // fuel use decreases mass, so do this as the last thing in the frame UpdateFuel(timeStep, thrust); if (m_landingGearAnimation) static_cast<SceneGraph::Model*>(GetModel())->UpdateAnimations(); }
void Ship::TimeStepUpdate(const float timeStep) { // If docked, station is responsible for updating position/orient of ship // but we call this crap anyway and hope it doesn't do anything bad const vector3d thrust(m_thrusters * GetMaxThrust(m_thrusters)); AddRelForce(thrust); AddRelTorque(GetShipType()->angThrust * m_angThrusters); if (m_landingGearAnimation) m_landingGearAnimation->SetProgress(m_wheelState); m_dragCoeff = DynamicBody::DEFAULT_DRAG_COEFF * (1.0 + 0.25 * m_wheelState); DynamicBody::TimeStepUpdate(timeStep); // fuel use decreases mass, so do this as the last thing in the frame UpdateFuel(timeStep, thrust); m_navLights->SetEnabled(m_wheelState > 0.01f); m_navLights->Update(timeStep); if (m_sensors.get()) m_sensors->Update(timeStep); }