This commit is contained in:
Branimir Karadžić
2017-06-12 22:43:23 -07:00
parent 40a7933018
commit 4ebbb4e124
2 changed files with 83 additions and 80 deletions

View File

@@ -332,85 +332,85 @@ namespace bx
void mtxLookAt(float* _result, const float* _eye, const float* _at, const float* _up = NULL);
///
void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false);
void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc);
///
void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false);
void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc);
///
void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false);
void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc);
///
void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false);
void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc);
///
void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false);
void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc);
///
void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false);
void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc);
///
void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false);
void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc);
///
void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false);
void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc);
///
void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false);
void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc);
///
void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc);
///
void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
///
void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
///
void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
///
void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc);
///
void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
///
void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
///
void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc);
///
void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
///
void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
///
void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc);
///
void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
///
void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc);
///
void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc);
///
void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc);
///
void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false);
void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc);
///
void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false);
void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc);
///
void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false);
void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc);
///
void mtxRotateX(float* _result, float _ax);

View File

@@ -667,7 +667,7 @@ namespace bx
mtxQuatTranslation(_result, quat, _translation);
}
inline void mtxLookAt_Impl(float* _result, const float* _eye, const float* _view, const float* _up)
inline void mtxLookAtImpl(float* _result, const float* _eye, const float* _view, const float* _up)
{
float up[3] = { 0.0f, 1.0f, 0.0f };
if (NULL != _up)
@@ -712,7 +712,7 @@ namespace bx
float view[4];
vec3Norm(view, tmp);
mtxLookAt_Impl(_result, _eye, view, _up);
mtxLookAtImpl(_result, _eye, view, _up);
}
inline void mtxLookAtRh(float* _result, const float* _eye, const float* _at, const float* _up)
@@ -723,7 +723,7 @@ namespace bx
float view[4];
vec3Norm(view, tmp);
mtxLookAt_Impl(_result, _eye, view, _up);
mtxLookAtImpl(_result, _eye, view, _up);
}
inline void mtxLookAt(float* _result, const float* _eye, const float* _at, const float* _up)
@@ -731,12 +731,12 @@ namespace bx
mtxLookAtLh(_result, _eye, _at, _up);
}
template <Handness::Enum HandnessT>
template<Handness::Enum HandnessT>
inline void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc)
{
const float diff = _far-_near;
const float aa = _oglNdc ? (_far+_near)/diff : _far/diff;
const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa;
const float aa = _oglNdc ? ( _far+_near)/diff : _far/diff;
const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa;
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = _width;
@@ -748,8 +748,8 @@ namespace bx
_result[14] = -bb;
}
template <Handness::Enum HandnessT>
inline void mtxProj_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
template<Handness::Enum HandnessT>
inline void mtxProjImpl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
{
const float invDiffRl = 1.0f/(_rt - _lt);
const float invDiffUd = 1.0f/(_ut - _dt);
@@ -760,14 +760,14 @@ namespace bx
mtxProjXYWH<HandnessT>(_result, xx, yy, width, height, _near, _far, _oglNdc);
}
template <Handness::Enum HandnessT>
inline void mtxProj_impl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
template<Handness::Enum HandnessT>
inline void mtxProjImpl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
{
mtxProj_impl<HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
mtxProjImpl<HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
}
template <Handness::Enum HandnessT>
inline void mtxProj_impl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
template<Handness::Enum HandnessT>
inline void mtxProjImpl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
{
const float height = 1.0f/ftan(toRad(_fovy)*0.5f);
const float width = height * 1.0f/_aspect;
@@ -776,50 +776,50 @@ namespace bx
inline void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
{
mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
mtxProjImpl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
}
inline void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
{
mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
mtxProjImpl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
}
inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
{
mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
mtxProjImpl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
}
inline void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
{
mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
mtxProjImpl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
}
inline void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
{
mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
mtxProjImpl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
}
inline void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
{
mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
mtxProjImpl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
}
inline void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
{
mtxProj_impl<Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
mtxProjImpl<Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
}
inline void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
{
mtxProj_impl<Handness::Right>(_result, _fov, _near, _far, _oglNdc);
mtxProjImpl<Handness::Right>(_result, _fov, _near, _far, _oglNdc);
}
inline void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
{
mtxProj_impl<Handness::Right>(_result, _fovy, _aspect, _near, _far, _oglNdc);
mtxProjImpl<Handness::Right>(_result, _fovy, _aspect, _near, _far, _oglNdc);
}
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
template<NearFar::Enum NearFarT, Handness::Enum HandnessT>
inline void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc)
{
float aa;
@@ -845,8 +845,8 @@ namespace bx
_result[14] = -bb;
}
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
inline void mtxProjInf_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
template<NearFar::Enum NearFarT, Handness::Enum HandnessT>
inline void mtxProjInfImpl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
{
const float invDiffRl = 1.0f/(_rt - _lt);
const float invDiffUd = 1.0f/(_ut - _dt);
@@ -857,14 +857,14 @@ namespace bx
mtxProjInfXYWH<NearFarT,HandnessT>(_result, xx, yy, width, height, _near, _oglNdc);
}
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
inline void mtxProjInf_impl(float* _result, const float _fov[4], float _near, bool _oglNdc)
template<NearFar::Enum NearFarT, Handness::Enum HandnessT>
inline void mtxProjInfImpl(float* _result, const float _fov[4], float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFarT,HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc);
mtxProjInfImpl<NearFarT,HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc);
}
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
inline void mtxProjInf_impl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
template<NearFar::Enum NearFarT, Handness::Enum HandnessT>
inline void mtxProjInfImpl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
{
const float height = 1.0f/ftan(toRad(_fovy)*0.5f);
const float width = height * 1.0f/_aspect;
@@ -873,88 +873,91 @@ namespace bx
inline void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
}
inline void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
}
inline void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
}
inline void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
}
inline void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
}
inline void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
mtxProjInfImpl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
}
inline void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
mtxProjInfImpl<NearFar::Default,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
}
inline void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fov, _near, _oglNdc);
mtxProjInfImpl<NearFar::Default,Handness::Right>(_result, _fov, _near, _oglNdc);
}
inline void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
mtxProjInfImpl<NearFar::Default,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
}
inline void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
mtxProjInfImpl<NearFar::Reverse,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
}
inline void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fov, _near, _oglNdc);
mtxProjInfImpl<NearFar::Reverse,Handness::Left>(_result, _fov, _near, _oglNdc);
}
inline void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
mtxProjInfImpl<NearFar::Reverse,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
}
inline void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
mtxProjInfImpl<NearFar::Reverse,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
}
inline void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fov, _near, _oglNdc);
mtxProjInfImpl<NearFar::Reverse,Handness::Right>(_result, _fov, _near, _oglNdc);
}
inline void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
{
mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
mtxProjInfImpl<NearFar::Reverse,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
}
template <Handness::Enum HandnessT>
inline void mtxOrtho_impl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
template<Handness::Enum HandnessT>
inline void mtxOrthoImpl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
{
const float aa = 2.0f/(_right - _left);
const float bb = 2.0f/(_top - _bottom);
const float cc = (_oglNdc ? 2.0f : 1.0f) / (_far - _near);
const float dd = (_left + _right)/(_left - _right);
const float ee = (_top + _bottom)/(_bottom - _top);
const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far);
const float dd = (_left + _right )/(_left - _right);
const float ee = (_top + _bottom)/(_bottom - _top );
const float ff = _oglNdc
? (_near + _far)/(_near - _far)
: _near /(_near - _far)
;
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = aa;
@@ -968,17 +971,17 @@ namespace bx
inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
{
mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
mtxOrthoImpl<Handness::Left>(_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, bool _oglNdc)
{
mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
mtxOrthoImpl<Handness::Left>(_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, bool _oglNdc)
{
mtxOrtho_impl<Handness::Right>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
mtxOrthoImpl<Handness::Right>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
}
inline void mtxRotateX(float* _result, float _ax)