diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index 531ab5a..0d54580 100644 --- a/include/bx/inline/math.inl +++ b/include/bx/inline/math.inl @@ -446,6 +446,11 @@ namespace bx }; } + inline BX_CONSTEXPR_FUNC Vec3 mad(const Vec3& _a, const float _b, const Vec3& _c) + { + return add(mul(_a, _b), _c); + } + inline BX_CONSTEXPR_FUNC Vec3 mad(const Vec3& _a, const Vec3& _b, const Vec3& _c) { return add(mul(_a, _b), _c); @@ -800,14 +805,9 @@ namespace bx _result[2] = _a[0]*_b[1] - _a[1]*_b[0]; } - inline float vec3Length(const float* _a) - { - return sqrt(vec3Dot(_a, _a) ); - } - inline float vec3Norm(float* _result, const float* _a) { - const float len = vec3Length(_a); + const float len = sqrt(vec3Dot(_a, _a) ); const float invLen = 1.0f/len; _result[0] = _a[0] * invLen; _result[1] = _a[1] * invLen; @@ -815,30 +815,6 @@ namespace bx return len; } - inline void vec3FromLatLong(float* _vec, float _u, float _v) - { - const float phi = _u * kPi2; - const float theta = _v * kPi; - - const float st = sin(theta); - const float sp = sin(phi); - const float ct = cos(theta); - const float cp = cos(phi); - - _vec[0] = -st*sp; - _vec[1] = ct; - _vec[2] = -st*cp; - } - - inline void vec3ToLatLong(float* _outU, float* _outV, const float* _dir) - { - const float phi = atan2(_dir[0], _dir[2]); - const float theta = acos(_dir[1]); - - *_outU = (bx::kPi + phi)/bx::kPi2; - *_outV = theta*bx::kInvPi; - } - inline void mtxIdentity(float* _result) { memSet(_result, 0, sizeof(float)*16); diff --git a/include/bx/math.h b/include/bx/math.h index b0c64a8..98d4ca9 100644 --- a/include/bx/math.h +++ b/include/bx/math.h @@ -297,6 +297,9 @@ namespace bx /// BX_CONSTEXPR_FUNC Vec3 mul(const Vec3& _a, float _b); + /// + BX_CONSTEXPR_FUNC Vec3 mad(const Vec3& _a, const float _b, const Vec3& _c); + /// BX_CONSTEXPR_FUNC Vec3 mad(const Vec3& _a, const Vec3& _b, const Vec3& _c); @@ -390,23 +393,9 @@ namespace bx /// void vec3Cross(float* _result, const float* _a, const float* _b); - /// - float vec3Length(const float* _a); - /// float vec3Norm(float* _result, const float* _a); - /// - void vec3FromLatLong(float* _vec, float _u, float _v); - - /// Convert direction to 2D latitude and longitude. - /// - /// @param[out] _outU U-coordinate. - /// @param[out] _outV V-coordinate. - /// @param[in] _dir Normalized direction vector. - /// - void vec3ToLatLong(float* _outU, float* _outV, const float* _dir); - /// void mtxIdentity(float* _result);