public void ComputeLinearVelocity(float pTimestep)
{
// Step the motor from the current value. Get the correction needed this step.
Vector3 origVelW = VehicleVelocity; // DEBUG
Vector3 currentVelV = VehicleVelocity * Quaternion.Inverse(VehicleOrientation);
Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVelV);
// Friction reduces vehicle motion based on absolute speed. Slow vehicle down by friction.
Vector3 frictionFactorV = ComputeFrictionFactor(m_linearFrictionTimescale, pTimestep);
linearMotorCorrectionV -= (currentVelV * frictionFactorV);
// Motor is vehicle coordinates. Rotate it to world coordinates
Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleFrameOrientation;
// If we're a ground vehicle, don't add any upward Z movement
if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0)
{
if (linearMotorVelocityW.Z > 0f)
linearMotorVelocityW.Z = 0f;
}
// Add this correction to the velocity to make it faster/slower.
VehicleVelocity += linearMotorVelocityW;
VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5}",
ControllingPrim.LocalID, origVelW, currentVelV, linearMotorCorrectionV, linearMotorVelocityW,
VehicleVelocity);
}
//Given a Deflection Effiency and a Velocity, Returns a Velocity that is Partially Deflected onto the X Axis