Fix possible division by zero in Plane.Normalize

#648
This commit is contained in:
Wojtek Figat
2021-10-11 14:32:34 +02:00
parent a013c3dd04
commit 9450111ae6
3 changed files with 22 additions and 13 deletions

View File

@@ -29,6 +29,17 @@ String Plane::ToString() const
return String::Format(TEXT("{}"), *this);
}
void Plane::Normalize()
{
const float length = Normal.Length();
if (!Math::IsZero(length))
{
const float rcp = 1.0f / length;
Normal *= rcp;
D *= rcp;
}
}
void Plane::Constlection(Matrix& result) const
{
const float x = Normal.X;