void MoveLinear(float pTimestep)
{
ComputeLinearVelocity(pTimestep);
ComputeLinearDeflection(pTimestep);
ComputeLinearTerrainHeightCorrection(pTimestep);
ComputeLinearHover(pTimestep);
ComputeLinearBlockingEndPoint(pTimestep);
ComputeLinearMotorUp(pTimestep);
ApplyGravity(pTimestep);
// If not changing some axis, reduce out velocity
if ((m_flags & (VehicleFlag.NO_X | VehicleFlag.NO_Y | VehicleFlag.NO_Z)) != 0)
{
Vector3 vel = VehicleVelocity;
if ((m_flags & (VehicleFlag.NO_X)) != 0)
vel.X = 0;
if ((m_flags & (VehicleFlag.NO_Y)) != 0)
vel.Y = 0;
if ((m_flags & (VehicleFlag.NO_Z)) != 0)
vel.Z = 0;
VehicleVelocity = vel;
}
// ==================================================================
// Clamp high or low velocities
float newVelocityLengthSq = VehicleVelocity.LengthSquared();
if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocitySquared)
{
Vector3 origVelW = VehicleVelocity; // DEBUG DEBUG
VehicleVelocity /= VehicleVelocity.Length();
VehicleVelocity *= BSParam.VehicleMaxLinearVelocity;
VDetailLog("{0}, MoveLinear,clampMax,origVelW={1},lenSq={2},maxVelSq={3},,newVelW={4}",
ControllingPrim.LocalID, origVelW, newVelocityLengthSq, BSParam.VehicleMaxLinearVelocitySquared,
VehicleVelocity);
}
else if (newVelocityLengthSq < BSParam.VehicleMinLinearVelocitySquared)
VehicleVelocity = Vector3.Zero;
VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID,
ControllingPrim.IsColliding, VehicleVelocity);
} // end MoveLinear()