public static void checkIntegrity(ref Vector3 vector)
{
float threshold = 0.000001f;
bool mustRenormalize = false;
if (Math.Abs(vector.X) < threshold)
{
vector.X = 0;
mustRenormalize = true;
}
if (Math.Abs(vector.Y) < threshold)
{
vector.Y = 0;
mustRenormalize = true;
}
if (Math.Abs(vector.Z) < threshold)
{
vector.Z = 0;
mustRenormalize = true;
}
if( mustRenormalize )
vector.Normalize();
if (Math.Abs(vector.X) > 0.999999)
vector.X = Math.Sign(vector.X);
if (Math.Abs(vector.Y) > 0.999999)
vector.Y = Math.Sign(vector.Y);
if (Math.Abs(vector.Z) > 0.999999)
vector.Z = Math.Sign(vector.Z);
}