From d3c9529df66025cf11c2b6bae991c14335596e05 Mon Sep 17 00:00:00 2001 From: BjossiAlfreds Date: Fri, 7 Jul 2023 23:58:16 +0000 Subject: [PATCH] Fixed VectorNormalize2 not writing 0-length vectors to out --- src/common/shared/shared.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/common/shared/shared.c b/src/common/shared/shared.c index 0b02a6e6..fc066d54 100644 --- a/src/common/shared/shared.c +++ b/src/common/shared/shared.c @@ -521,20 +521,9 @@ VectorNormalize(vec3_t v) vec_t VectorNormalize2(vec3_t v, vec3_t out) { - float length, ilength; + VectorCopy(v, out); - length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; - length = (float)sqrt(length); - - if (length) - { - ilength = 1 / length; - out[0] = v[0] * ilength; - out[1] = v[1] * ilength; - out[2] = v[2] * ilength; - } - - return length; + return VectorNormalize(out); } void