I tried using this without actually checking the definition, assuming it would return a unit vector… but no it returns a bool…?
FORCEINLINE bool FVector::Normalize(float Tolerance)
{
const float SquareSum = X*X + Y*Y + Z*Z;
if( SquareSum > Tolerance )
{
const float Scale = FMath::InvSqrt(SquareSum);
X *= Scale; Y *= Scale; Z *= Scale;
return true;
}
return false;
}
Obviously it’s working on the data inside the FVector struct…but shouldn’t this function be called IsNormalized()?
It appears that FVector::ToDirectionAndLength is what I want instead to return a normalized vector…
FORCEINLINE void FVector::ToDirectionAndLength(FVector &OutDir, float &OutLength) const
{
OutLength = Size();
if (OutLength > SMALL_NUMBER)
{
float OneOverLength = 1.0f/OutLength;
OutDir = FVector(X*OneOverLength, Y*OneOverLength,
Z*OneOverLength);
}
else
{
OutDir = FVector::ZeroVector;
}
}
Is there something I’m missing or any valuable insights anyone can offer about this? Thanks!