|
|
@@ -358,7 +358,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline void store(void* _ptr, const Vec3& _a)
|
|
|
+ inline void store(void* _ptr, const Vec3 _a)
|
|
|
{
|
|
|
float* ptr = reinterpret_cast<float*>(_ptr);
|
|
|
ptr[0] = _a.x;
|
|
|
@@ -366,7 +366,7 @@ namespace bx
|
|
|
ptr[2] = _a.z;
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 abs(const Vec3& _a)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 abs(const Vec3 _a)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -376,7 +376,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 neg(const Vec3& _a)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 neg(const Vec3 _a)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -386,7 +386,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 add(const Vec3& _a, const Vec3& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 add(const Vec3 _a, const Vec3 _b)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -396,7 +396,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 add(const Vec3& _a, float _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 add(const Vec3 _a, float _b)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -406,7 +406,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 sub(const Vec3& _a, const Vec3& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 sub(const Vec3 _a, const Vec3 _b)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -416,7 +416,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 sub(const Vec3& _a, float _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 sub(const Vec3 _a, float _b)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -426,7 +426,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 mul(const Vec3& _a, const Vec3& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 mul(const Vec3 _a, const Vec3 _b)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -436,7 +436,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 mul(const Vec3& _a, float _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 mul(const Vec3 _a, float _b)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -446,22 +446,22 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 mad(const Vec3& _a, const float _b, const Vec3& _c)
|
|
|
+ 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)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 mad(const Vec3 _a, const Vec3 _b, const Vec3 _c)
|
|
|
{
|
|
|
return add(mul(_a, _b), _c);
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC float dot(const Vec3& _a, const Vec3& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC float dot(const Vec3 _a, const Vec3 _b)
|
|
|
{
|
|
|
return _a.x*_b.x + _a.y*_b.y + _a.z*_b.z;
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 cross(const Vec3& _a, const Vec3& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 cross(const Vec3 _a, const Vec3 _b)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -471,12 +471,12 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONST_FUNC float length(const Vec3& _a)
|
|
|
+ inline BX_CONST_FUNC float length(const Vec3 _a)
|
|
|
{
|
|
|
return sqrt(dot(_a, _a) );
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3& _a, const Vec3& _b, float _t)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -486,7 +486,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3& _a, const Vec3& _b, const Vec3& _t)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, const Vec3 _t)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -496,14 +496,14 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONST_FUNC Vec3 normalize(const Vec3& _a)
|
|
|
+ inline BX_CONST_FUNC Vec3 normalize(const Vec3 _a)
|
|
|
{
|
|
|
const float invLen = 1.0f/length(_a);
|
|
|
const Vec3 result = mul(_a, invLen);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 min(const Vec3& _a, const Vec3& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 min(const Vec3 _a, const Vec3 _b)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -513,7 +513,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 max(const Vec3& _a, const Vec3& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 max(const Vec3 _a, const Vec3 _b)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -523,7 +523,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 rcp(const Vec3& _a)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 rcp(const Vec3 _a)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -533,7 +533,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline void calcTangentFrame(Vec3& _outT, Vec3& _outB, const Vec3& _n)
|
|
|
+ inline void calcTangentFrame(Vec3& _outT, Vec3& _outB, const Vec3 _n)
|
|
|
{
|
|
|
const float nx = _n.x;
|
|
|
const float ny = _n.y;
|
|
|
@@ -557,7 +557,7 @@ namespace bx
|
|
|
_outB = cross(_n, _outT);
|
|
|
}
|
|
|
|
|
|
- inline void calcTangentFrame(Vec3& _outT, Vec3& _outB, const Vec3& _n, float _angle)
|
|
|
+ inline void calcTangentFrame(Vec3& _outT, Vec3& _outB, const Vec3 _n, float _angle)
|
|
|
{
|
|
|
calcTangentFrame(_outT, _outB, _n);
|
|
|
|
|
|
@@ -588,7 +588,7 @@ namespace bx
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- inline void toLatLong(float* _outU, float* _outV, const Vec3& _dir)
|
|
|
+ inline void toLatLong(float* _outU, float* _outV, const Vec3 _dir)
|
|
|
{
|
|
|
const float phi = atan2(_dir.x, _dir.z);
|
|
|
const float theta = acos(_dir.y);
|
|
|
@@ -597,7 +597,7 @@ namespace bx
|
|
|
*_outV = theta*bx::kInvPi;
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Quaternion invert(const Quaternion& _a)
|
|
|
+ inline BX_CONSTEXPR_FUNC Quaternion invert(const Quaternion _a)
|
|
|
{
|
|
|
return
|
|
|
{
|
|
|
@@ -608,7 +608,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 mulXyz(const Quaternion& _a, const Quaternion& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 mulXyz(const Quaternion _a, const Quaternion _b)
|
|
|
{
|
|
|
const float ax = _a.x;
|
|
|
const float ay = _a.y;
|
|
|
@@ -628,7 +628,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Quaternion mul(const Quaternion& _a, const Quaternion& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC Quaternion mul(const Quaternion _a, const Quaternion _b)
|
|
|
{
|
|
|
const float ax = _a.x;
|
|
|
const float ay = _a.y;
|
|
|
@@ -649,17 +649,25 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Vec3 mul(const Vec3& _v, const Quaternion& _q)
|
|
|
+ namespace detail
|
|
|
+ {
|
|
|
+ inline BX_CONSTEXPR_FUNC Quaternion loadQ(const Vec3 _v)
|
|
|
+ {
|
|
|
+ return { _v.x, _v.y, _v.z, 0.0f };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ inline BX_CONSTEXPR_FUNC Vec3 mul(const Vec3 _v, const Quaternion _q)
|
|
|
{
|
|
|
const Quaternion tmp0 = invert(_q);
|
|
|
- const Quaternion qv = { _v.x, _v.y, _v.z, 0.0f };
|
|
|
+ const Quaternion qv = detail::loadQ(_v);
|
|
|
const Quaternion tmp1 = mul(tmp0, qv);
|
|
|
const Vec3 result = mulXyz(tmp1, _q);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC float dot(const Quaternion& _a, const Quaternion& _b)
|
|
|
+ inline BX_CONSTEXPR_FUNC float dot(const Quaternion _a, const Quaternion _b)
|
|
|
{
|
|
|
return
|
|
|
_a.x * _b.x
|
|
|
@@ -669,7 +677,7 @@ namespace bx
|
|
|
;
|
|
|
}
|
|
|
|
|
|
- inline BX_CONSTEXPR_FUNC Quaternion normalize(const Quaternion& _a)
|
|
|
+ inline BX_CONSTEXPR_FUNC Quaternion normalize(const Quaternion _a)
|
|
|
{
|
|
|
const float norm = dot(_a, _a);
|
|
|
if (0.0f < norm)
|
|
|
@@ -694,7 +702,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONST_FUNC Vec3 toEuler(const Quaternion& _a)
|
|
|
+ inline BX_CONST_FUNC Vec3 toEuler(const Quaternion _a)
|
|
|
{
|
|
|
const float xx = _a.x;
|
|
|
const float yy = _a.y;
|
|
|
@@ -712,7 +720,7 @@ namespace bx
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- inline BX_CONST_FUNC Quaternion rotateAxis(const Vec3& _axis, float _angle)
|
|
|
+ inline BX_CONST_FUNC Quaternion rotateAxis(const Vec3 _axis, float _angle)
|
|
|
{
|
|
|
const float ha = _angle * 0.5f;
|
|
|
const float sa = sin(ha);
|
|
|
@@ -942,7 +950,7 @@ namespace bx
|
|
|
mtxQuatTranslation(_result, quat, _translation);
|
|
|
}
|
|
|
|
|
|
- inline Vec3 mul(const Vec3& _vec, const float* _mat)
|
|
|
+ inline Vec3 mul(const Vec3 _vec, const float* _mat)
|
|
|
{
|
|
|
Vec3 result;
|
|
|
result.x = _vec.x * _mat[0] + _vec.y * _mat[4] + _vec.z * _mat[ 8] + _mat[12];
|
|
|
@@ -951,7 +959,7 @@ namespace bx
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- inline Vec3 mulXyz0(const Vec3& _vec, const float* _mat)
|
|
|
+ inline Vec3 mulXyz0(const Vec3 _vec, const float* _mat)
|
|
|
{
|
|
|
Vec3 result;
|
|
|
result.x = _vec.x * _mat[0] + _vec.y * _mat[4] + _vec.z * _mat[ 8];
|
|
|
@@ -960,7 +968,7 @@ namespace bx
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- inline Vec3 mulH(const Vec3& _vec, const float* _mat)
|
|
|
+ inline Vec3 mulH(const Vec3 _vec, const float* _mat)
|
|
|
{
|
|
|
const float xx = _vec.x * _mat[0] + _vec.y * _mat[4] + _vec.z * _mat[ 8] + _mat[12];
|
|
|
const float yy = _vec.x * _mat[1] + _vec.y * _mat[5] + _vec.z * _mat[ 9] + _mat[13];
|