Added Vec3 version of nms.

This commit is contained in:
Бранимир Караџић
2021-10-21 19:39:46 -07:00
parent f324ffad46
commit 11c3c5e615
2 changed files with 19 additions and 1 deletions

View File

@@ -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);

View File

@@ -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);