|
|
@@ -635,12 +635,12 @@ namespace bx
|
|
|
{
|
|
|
enum Enum
|
|
|
{
|
|
|
- RightHanded = false,
|
|
|
- LeftHanded = true,
|
|
|
+ RightHanded,
|
|
|
+ LeftHanded,
|
|
|
};
|
|
|
};
|
|
|
|
|
|
- template <bool HandnessT>
|
|
|
+ template <Handness::Enum HandnessT>
|
|
|
inline void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc = false)
|
|
|
{
|
|
|
const float diff = _far-_near;
|
|
|
@@ -657,7 +657,7 @@ namespace bx
|
|
|
_result[14] = -bb;
|
|
|
}
|
|
|
|
|
|
- template <bool HandnessT>
|
|
|
+ template <Handness::Enum HandnessT>
|
|
|
inline void mtxProj_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
|
|
{
|
|
|
const float invDiffRl = 1.0f/(_rt - _lt);
|
|
|
@@ -669,20 +669,12 @@ namespace bx
|
|
|
mtxProjXYWH<HandnessT>(_result, xx, yy, width, height, _near, _far, _oglNdc);
|
|
|
}
|
|
|
|
|
|
- template <bool HandnessT>
|
|
|
+ template <Handness::Enum HandnessT>
|
|
|
inline void mtxProj_impl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
|
|
{
|
|
|
mtxProj_impl<HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
|
|
|
}
|
|
|
|
|
|
- template <bool HandnessT>
|
|
|
- inline void mtxProj_impl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
|
|
- {
|
|
|
- const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
|
|
|
- const float width = height * 1.0f/_aspect;
|
|
|
- mtxProjXYWH<HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
|
|
|
- }
|
|
|
-
|
|
|
inline void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
|
|
{
|
|
|
mtxProj_impl<Handness::LeftHanded>(_result, _fov, _near, _far, _oglNdc);
|
|
|
@@ -698,6 +690,14 @@ namespace bx
|
|
|
mtxProj_impl<Handness::RightHanded>(_result, _fov, _near, _far, _oglNdc);
|
|
|
}
|
|
|
|
|
|
+ template <Handness::Enum HandnessT>
|
|
|
+ inline void mtxProj_impl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
|
|
+ {
|
|
|
+ const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
|
|
|
+ const float width = height * 1.0f/_aspect;
|
|
|
+ mtxProjXYWH<HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
|
|
|
+ }
|
|
|
+
|
|
|
inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
|
|
{
|
|
|
mtxProj_impl<Handness::LeftHanded>(_result, _fovy, _aspect, _near, _far, _oglNdc);
|
|
|
@@ -722,7 +722,7 @@ namespace bx
|
|
|
};
|
|
|
};
|
|
|
|
|
|
- template <bool NearFarT, bool HandnessT>
|
|
|
+ template <bool NearFarT, Handness::Enum HandnessT>
|
|
|
inline void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc = false)
|
|
|
{
|
|
|
float aa;
|
|
|
@@ -748,7 +748,7 @@ namespace bx
|
|
|
_result[14] = -bb;
|
|
|
}
|
|
|
|
|
|
- template <bool NearFarT, bool HandnessT>
|
|
|
+ template <bool NearFarT, Handness::Enum HandnessT>
|
|
|
inline void mtxProjInf_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
|
|
{
|
|
|
const float invDiffRl = 1.0f/(_rt - _lt);
|
|
|
@@ -760,13 +760,28 @@ namespace bx
|
|
|
mtxProjInfXYWH<NearFarT,HandnessT>(_result, xx, yy, width, height, _near, _oglNdc);
|
|
|
}
|
|
|
|
|
|
- template <bool NearFarT, bool HandnessT>
|
|
|
+ template <bool NearFarT, Handness::Enum HandnessT>
|
|
|
inline void mtxProjInf_impl(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
|
|
{
|
|
|
mtxProjInf_impl<NearFarT,HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc);
|
|
|
}
|
|
|
|
|
|
- template <bool NearFarT, bool HandnessT>
|
|
|
+ inline void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
|
|
+ {
|
|
|
+ mtxProjInf_impl<bx::NearFar::Default, bx::Handness::LeftHanded>(_result, _fov, _near, _oglNdc);
|
|
|
+ }
|
|
|
+
|
|
|
+ inline void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
|
|
+ {
|
|
|
+ mtxProjInf_impl<bx::NearFar::Default, bx::Handness::LeftHanded>(_result, _fov, _near, _oglNdc);
|
|
|
+ }
|
|
|
+
|
|
|
+ inline void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
|
|
+ {
|
|
|
+ mtxProjInf_impl<bx::NearFar::Default, bx::Handness::RightHanded>(_result, _fov, _near, _oglNdc);
|
|
|
+ }
|
|
|
+
|
|
|
+ template <bool NearFarT, Handness::Enum HandnessT>
|
|
|
inline void mtxProjInf_impl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
|
|
{
|
|
|
const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
|
|
|
@@ -774,13 +789,17 @@ namespace bx
|
|
|
mtxProjInfXYWH<NearFarT,HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _oglNdc);
|
|
|
}
|
|
|
|
|
|
- #define mtxProjInf mtxProjInf_impl<bx::NearFar::Default, bx::Handness::LeftHanded>
|
|
|
- #define mtxProjInfLh mtxProjInf_impl<bx::NearFar::Default, bx::Handness::LeftHanded>
|
|
|
- #define mtxProjInfRh mtxProjInf_impl<bx::NearFar::Default, bx::Handness::RightHanded>
|
|
|
- #define mtxProjRevInfLh mtxProjInf_impl<bx::NearFar::Reverse, bx::Handness::LeftHanded>
|
|
|
- #define mtxProjRevInfRh mtxProjInf_impl<bx::NearFar::Reverse, bx::Handness::RightHanded>
|
|
|
+ inline void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
|
|
+ {
|
|
|
+ mtxProjInf_impl<bx::NearFar::Reverse, bx::Handness::LeftHanded>(_result, _fovy, _aspect, _near, _oglNdc);
|
|
|
+ }
|
|
|
+
|
|
|
+ inline void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
|
|
+ {
|
|
|
+ mtxProjInf_impl<bx::NearFar::Reverse, bx::Handness::RightHanded>(_result, _fovy, _aspect, _near, _oglNdc);
|
|
|
+ }
|
|
|
|
|
|
- template <bool HandnessT>
|
|
|
+ template <Handness::Enum HandnessT>
|
|
|
inline void mtxOrtho_impl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
|
|
{
|
|
|
const float aa = 2.0f/(_right - _left);
|
|
|
@@ -800,9 +819,20 @@ namespace bx
|
|
|
_result[15] = 1.0f;
|
|
|
}
|
|
|
|
|
|
- #define mtxOrtho mtxOrtho_impl<bx::Handness::LeftHanded>
|
|
|
- #define mtxOrthoLh mtxOrtho_impl<bx::Handness::LeftHanded>
|
|
|
- #define mtxOrthoRh mtxOrtho_impl<bx::Handness::RightHanded>
|
|
|
+ inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
|
|
+ {
|
|
|
+ mtxOrtho_impl<bx::Handness::LeftHanded>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
|
|
+ }
|
|
|
+
|
|
|
+ inline void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
|
|
+ {
|
|
|
+ mtxOrtho_impl<bx::Handness::LeftHanded>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
|
|
+ }
|
|
|
+
|
|
|
+ inline void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
|
|
+ {
|
|
|
+ mtxOrtho_impl<bx::Handness::RightHanded>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
|
|
+ }
|
|
|
|
|
|
inline void mtxRotateX(float* _result, float _ax)
|
|
|
{
|