void MoveAngular(float pTimestep)
{
ComputeAngularTurning(pTimestep);
ComputeAngularVerticalAttraction();
ComputeAngularDeflection();
ComputeAngularBanking();
// ==================================================================
if (VehicleRotationalVelocity.ApproxEquals(Vector3.Zero, 0.0001f))
{
// The vehicle is not adding anything angular wise.
VehicleRotationalVelocity = Vector3.Zero;
VDetailLog("{0}, MoveAngular,done,zero", ControllingPrim.LocalID);
}
else
{
VDetailLog("{0}, MoveAngular,done,nonZero,angVel={1}", ControllingPrim.LocalID,
VehicleRotationalVelocity);
}
// ==================================================================
//Offset section
if (m_linearMotorOffset != Vector3.Zero)
{
//Offset of linear velocity doesn't change the linear velocity,
// but causes a torque to be applied, for example...
//
// IIIII >>> IIIII
// IIIII >>> IIIII
// IIIII >>> IIIII
// ^
// | Applying a force at the arrow will cause the object to move forward, but also rotate
//
//
// The torque created is the linear velocity crossed with the offset
// TODO: this computation should be in the linear section
// because that is where we know the impulse being applied.
Vector3 torqueFromOffset = Vector3.Zero;
// torqueFromOffset = Vector3.Cross(m_linearMotorOffset, appliedImpulse);
if (float.IsNaN(torqueFromOffset.X))
torqueFromOffset.X = 0;
if (float.IsNaN(torqueFromOffset.Y))
torqueFromOffset.Y = 0;
if (float.IsNaN(torqueFromOffset.Z))
torqueFromOffset.Z = 0;
VehicleAddAngularForce(torqueFromOffset * m_vehicleMass);
VDetailLog("{0}, BSDynamic.MoveAngular,motorOffset,applyTorqueImpulse={1}", ControllingPrim.LocalID,
torqueFromOffset);
}
}