From 52ef1c838a1a851d1016b68022f5ae8c2f7798df Mon Sep 17 00:00:00 2001 From: Garux Date: Mon, 8 Mar 2021 15:36:46 +0300 Subject: [PATCH] make sure to do VectorNormalize in double --- tools/quake3/common/qmath.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/quake3/common/qmath.h b/tools/quake3/common/qmath.h index 687effcb..10d853a8 100644 --- a/tools/quake3/common/qmath.h +++ b/tools/quake3/common/qmath.h @@ -130,14 +130,15 @@ inline Color4b color_to_byte( const Color4f& color ){ template T VectorNormalize( BasicVector3& vector ) { - const double length = vector3_length( DoubleVector3( vector ) ); + DoubleVector3 v( vector ); // intermediate vector to be sure to do in double + const double length = vector3_length( v ); if ( length == 0 ) { vector.set( 0 ); return 0; } - vector /= length; + vector = v / length; return length; }