internal float ApplyImpulse()
{
//Compute relative velocity and convert to an impulse
float lambda = RelativeVelocity * velocityToImpulse;
//Clamp accumulated impulse
float previousAccumulatedImpulse = accumulatedImpulse;
float maxForce = -blendedCoefficient * wheel.suspension.accumulatedImpulse;
accumulatedImpulse = MathHelper.Clamp(accumulatedImpulse + lambda, -maxForce, maxForce);
lambda = accumulatedImpulse - previousAccumulatedImpulse;
//Apply the impulse
#if !WINDOWS
Vector3 linear = new Vector3();
Vector3 angular = new Vector3();
#else
Vector3 linear, angular;
#endif
linear.X = lambda * linearAX;
linear.Y = lambda * linearAY;
linear.Z = lambda * linearAZ;
if (vehicleEntity.isDynamic)
{
angular.X = lambda * angularAX;
angular.Y = lambda * angularAY;
angular.Z = lambda * angularAZ;
vehicleEntity.ApplyLinearImpulse(ref linear);
vehicleEntity.ApplyAngularImpulse(ref angular);
}
if (supportIsDynamic)
{
linear.X = -linear.X;
linear.Y = -linear.Y;
linear.Z = -linear.Z;
angular.X = lambda * angularBX;
angular.Y = lambda * angularBY;
angular.Z = lambda * angularBZ;
supportEntity.ApplyLinearImpulse(ref linear);
supportEntity.ApplyAngularImpulse(ref angular);
}
return lambda;
}