From 6ef7924e0122155c390698bdd66e9757f4da5fa0 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 17 Apr 2020 15:15:42 +0200 Subject: implemented CVector2D::NormaliseSafe for SkidMarks --- src/math/math.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/math/math.cpp') diff --git a/src/math/math.cpp b/src/math/math.cpp index 4f74fac9..04fab797 100644 --- a/src/math/math.cpp +++ b/src/math/math.cpp @@ -4,6 +4,19 @@ // TODO: move more stuff into here +void +CVector2D::Normalise(void) +{ + float sq = MagnitudeSqr(); + assert(sq != 0.0f); // just be safe here + //if(sq > 0.0f){ + float invsqrt = RecipSqrt(sq); + x *= invsqrt; + y *= invsqrt; + //}else + // x = 1.0f; +} + void CMatrix::SetRotate(float xAngle, float yAngle, float zAngle) { -- cgit v1.2.3