Browse Source

Added Vec3 version of nms.

Бранимир Караџић 4 years ago
parent
commit
11c3c5e615
2 changed files with 19 additions and 1 deletions
  1. 10 0
      include/bx/inline/math.inl
  2. 9 1
      include/bx/math.h

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

@@ -592,6 +592,16 @@ namespace bx
 		return mul(_a, rcp(_b) );
 	}
 
+	inline BX_CONSTEXPR_FUNC Vec3 nms(const Vec3 _a, const float _b, const Vec3 _c)
+	{
+		return sub(_c, mul(_a, _b) );
+	}
+
+	inline BX_CONSTEXPR_FUNC Vec3 nms(const Vec3 _a, const Vec3 _b, const Vec3 _c)
+	{
+		return sub(_c, mul(_a, _b) );
+	}
+
 	inline BX_CONSTEXPR_FUNC Vec3 mad(const Vec3 _a, const float _b, const Vec3 _c)
 	{
 		return add(mul(_a, _b), _c);

+ 9 - 1
include/bx/math.h

@@ -304,7 +304,7 @@ namespace bx
 	///
 	BX_CONSTEXPR_FUNC float fract(float _a);
 
-	/// Returns result of negated multiply-sub operation -(_a * _b - _c).
+	/// Returns result of negated multiply-sub operation -(_a * _b - _c) -> _c - _a * _b.
 	///
 	BX_CONSTEXPR_FUNC float nms(float _a, float _b, float _c);
 
@@ -407,6 +407,14 @@ namespace bx
 	///
 	BX_CONSTEXPR_FUNC Vec3 div(const Vec3 _a, float _b);
 
+	/// Returns result of negated multiply-sub operation -(_a * _b - _c) -> _c - _a * _b.
+	///
+	BX_CONSTEXPR_FUNC Vec3 nms(const Vec3 _a, const float _b, const Vec3 _c);
+
+	/// Returns result of negated multiply-sub operation -(_a * _b - _c) -> _c - _a * _b.
+	///
+	BX_CONSTEXPR_FUNC Vec3 nms(const Vec3 _a, const Vec3 _b, const Vec3 _c);
+
 	///
 	BX_CONSTEXPR_FUNC Vec3 mad(const Vec3 _a, const float _b, const Vec3 _c);