Бранимир Караџић hace 6 años
padre
commit
b0c7d38804
Se han modificado 2 ficheros con 17 adiciones y 0 borrados
  1. 11 0
      include/bx/inline/math.inl
  2. 6 0
      include/bx/math.h

+ 11 - 0
include/bx/inline/math.inl

@@ -499,6 +499,17 @@ namespace bx
 		return sqrt(dot(_a, _a) );
 	}
 
+	inline BX_CONST_FUNC float distanceSq(const Vec3 _a, const Vec3 _b)
+	{
+		const Vec3 ba = sub(_b, _a);
+		return dot(ba, ba);
+	}
+
+	inline BX_CONST_FUNC float distance(const Vec3 _a, const Vec3 _b)
+	{
+		return length(sub(_b, _a) );
+	}
+
 	inline BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t)
 	{
 		return

+ 6 - 0
include/bx/math.h

@@ -333,6 +333,12 @@ namespace bx
 	///
 	BX_CONST_FUNC float length(const Vec3 _a);
 
+	///
+	BX_CONST_FUNC float distanceSq(const Vec3 _a, const Vec3 _b);
+
+	///
+	BX_CONST_FUNC float distance(const Vec3 _a, const Vec3 _b);
+
 	///
 	BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t);