From 11c3c5e615e8715ef5d99fbcba5864d5d1036bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Thu, 21 Oct 2021 19:39:46 -0700 Subject: [PATCH] Added Vec3 version of nms. --- include/bx/inline/math.inl | 10 ++++++++++ include/bx/math.h | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index 6e7fec0..7e0ce57 100644 --- a/include/bx/inline/math.inl +++ b/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); diff --git a/include/bx/math.h b/include/bx/math.h index 22b2609..cf96dd3 100644 --- a/include/bx/math.h +++ b/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);