From 0bcfed4e9379ddebbc75e494374ff3162512e7da Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 12 Nov 2020 16:12:11 +0800 Subject: [PATCH] fix a bug, it's adaptive a error vector type. --- inc/hgl/math/Vector.h | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/inc/hgl/math/Vector.h b/inc/hgl/math/Vector.h index c06379a..d2557cc 100644 --- a/inc/hgl/math/Vector.h +++ b/inc/hgl/math/Vector.h @@ -180,28 +180,15 @@ namespace hgl return sqrt(length_squared_2d(v)); } - template - inline float length_squared(const T1 &v1, const T2 &v2) - { - const float x = (v1.x - v2.x); - const float y = (v1.y - v2.y); - - return x*x + y*y; - } - template inline float length(const T1 &v1, const T2 &v2) { - return sqrt(length_squared(v1, v2)); + return sqrt(length_squared(v1-v2)); } - - inline float length_squared(const Vector3f &v1, const Vector3f &v2) + template + inline float length_squared(const T1 &v1, const T2 &v2) { - const float x = (v1.x - v2.x); - const float y = (v1.y - v2.y); - const float z = (v1.z - v2.z); - - return x*x + y*y + z*z; + return length_squared(v1-v2); } template @@ -213,11 +200,6 @@ namespace hgl return x*x + y*y; } - inline float length(const Vector3f &v1, const Vector3f &v2) - { - return sqrt(length_squared(v1, v2)); - } - template inline float length_2d(const T1 &v1, const T2 &v2) {