From 0b5e8b49f3ed65b746481dc175d67daf0c48a830 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Wed, 16 Dec 2020 19:19:59 +0000 Subject: [PATCH] mathlib: Simplify VectorNormalizeLength to use existing math macros git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13066 d7cf8633-e32d-0410-b094-e92efae38249 --- mathlib.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/mathlib.c b/mathlib.c index cf9e24a8..4c19dfe1 100644 --- a/mathlib.c +++ b/mathlib.c @@ -762,21 +762,14 @@ void AngleMatrix (const vec3_t angles, const vec3_t translate, vec_t matrix[][4] // LadyHavoc: renamed this to Length, and made the normal one a #define float VectorNormalizeLength (vec3_t v) { - float length, ilength; + float length; - length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - length = sqrt (length); + length = sqrt(DotProduct(v,v)); if (length) - { - ilength = 1/length; - v[0] *= ilength; - v[1] *= ilength; - v[2] *= ilength; - } + VectorScale(v, 1 / length, v); return length; - } -- 2.39.2