diff options
Diffstat (limited to '')
-rw-r--r-- | external/include/glm/gtc/matrix_transform.inl | 737 |
1 files changed, 485 insertions, 252 deletions
diff --git a/external/include/glm/gtc/matrix_transform.inl b/external/include/glm/gtc/matrix_transform.inl index b9ff418..12623d7 100644 --- a/external/include/glm/gtc/matrix_transform.inl +++ b/external/include/glm/gtc/matrix_transform.inl @@ -7,25 +7,25 @@ namespace glm { - template <typename T, precision P> - GLM_FUNC_QUALIFIER tmat4x4<T, P> translate(tmat4x4<T, P> const & m, tvec3<T, P> const & v) + template<typename T, qualifier Q> + GLM_FUNC_QUALIFIER mat<4, 4, T, Q> translate(mat<4, 4, T, Q> const& m, vec<3, T, Q> const& v) { - tmat4x4<T, P> Result(m); + mat<4, 4, T, Q> Result(m); Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; return Result; } - - template <typename T, precision P> - GLM_FUNC_QUALIFIER tmat4x4<T, P> rotate(tmat4x4<T, P> const & m, T angle, tvec3<T, P> const & v) + + template<typename T, qualifier Q> + GLM_FUNC_QUALIFIER mat<4, 4, T, Q> rotate(mat<4, 4, T, Q> const& m, T angle, vec<3, T, Q> const& v) { T const a = angle; T const c = cos(a); T const s = sin(a); - tvec3<T, P> axis(normalize(v)); - tvec3<T, P> temp((T(1) - c) * axis); + vec<3, T, Q> axis(normalize(v)); + vec<3, T, Q> temp((T(1) - c) * axis); - tmat4x4<T, P> Rotate(uninitialize); + mat<4, 4, T, Q> Rotate; Rotate[0][0] = c + temp[0] * axis[0]; Rotate[0][1] = temp[0] * axis[1] + s * axis[2]; Rotate[0][2] = temp[0] * axis[2] - s * axis[1]; @@ -38,23 +38,23 @@ namespace glm Rotate[2][1] = temp[2] * axis[1] - s * axis[0]; Rotate[2][2] = c + temp[2] * axis[2]; - tmat4x4<T, P> Result(uninitialize); + mat<4, 4, T, Q> Result; Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2]; Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2]; Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2]; Result[3] = m[3]; return Result; } - - template <typename T, precision P> - GLM_FUNC_QUALIFIER tmat4x4<T, P> rotate_slow(tmat4x4<T, P> const & m, T angle, tvec3<T, P> const & v) + + template<typename T, qualifier Q> + GLM_FUNC_QUALIFIER mat<4, 4, T, Q> rotate_slow(mat<4, 4, T, Q> const& m, T angle, vec<3, T, Q> const& v) { T const a = angle; T const c = cos(a); T const s = sin(a); - tmat4x4<T, P> Result; + mat<4, 4, T, Q> Result; - tvec3<T, P> axis = normalize(v); + vec<3, T, Q> axis = normalize(v); Result[0][0] = c + (static_cast<T>(1) - c) * axis.x * axis.x; Result[0][1] = (static_cast<T>(1) - c) * axis.x * axis.y + s * axis.z; @@ -71,14 +71,14 @@ namespace glm Result[2][2] = c + (static_cast<T>(1) - c) * axis.z * axis.z; Result[2][3] = static_cast<T>(0); - Result[3] = tvec4<T, P>(0, 0, 0, 1); + Result[3] = vec<4, T, Q>(0, 0, 0, 1); return m * Result; } - template <typename T, precision P> - GLM_FUNC_QUALIFIER tmat4x4<T, P> scale(tmat4x4<T, P> const & m, tvec3<T, P> const & v) + template<typename T, qualifier Q> + GLM_FUNC_QUALIFIER mat<4, 4, T, Q> scale(mat<4, 4, T, Q> const& m, vec<3, T, Q> const& v) { - tmat4x4<T, P> Result(uninitialize); + mat<4, 4, T, Q> Result; Result[0] = m[0] * v[0]; Result[1] = m[1] * v[1]; Result[2] = m[2] * v[2]; @@ -86,296 +86,497 @@ namespace glm return Result; } - template <typename T, precision P> - GLM_FUNC_QUALIFIER tmat4x4<T, P> scale_slow(tmat4x4<T, P> const & m, tvec3<T, P> const & v) + template<typename T, qualifier Q> + GLM_FUNC_QUALIFIER mat<4, 4, T, Q> scale_slow(mat<4, 4, T, Q> const& m, vec<3, T, Q> const& v) { - tmat4x4<T, P> Result(T(1)); + mat<4, 4, T, Q> Result(T(1)); Result[0][0] = v.x; Result[1][1] = v.y; Result[2][2] = v.z; return m * Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> ortho - ( - T left, T right, - T bottom, T top, - T zNear, T zFar - ) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> ortho(T left, T right, T bottom, T top) { -# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED - return orthoLH(left, right, bottom, top, zNear, zFar); -# else - return orthoRH(left, right, bottom, top, zNear, zFar); -# endif + mat<4, 4, T, defaultp> Result(static_cast<T>(1)); + Result[0][0] = static_cast<T>(2) / (right - left); + Result[1][1] = static_cast<T>(2) / (top - bottom); + Result[3][0] = - (right + left) / (right - left); + Result[3][1] = - (top + bottom) / (top - bottom); + return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> orthoLH - ( - T left, T right, - T bottom, T top, - T zNear, T zFar - ) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH_ZO(T left, T right, T bottom, T top, T zNear, T zFar) { - tmat4x4<T, defaultp> Result(1); + mat<4, 4, T, defaultp> Result(1); Result[0][0] = static_cast<T>(2) / (right - left); Result[1][1] = static_cast<T>(2) / (top - bottom); + Result[2][2] = static_cast<T>(1) / (zFar - zNear); Result[3][0] = - (right + left) / (right - left); Result[3][1] = - (top + bottom) / (top - bottom); - -# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - Result[2][2] = static_cast<T>(1) / (zFar - zNear); - Result[3][2] = - zNear / (zFar - zNear); -# else - Result[2][2] = static_cast<T>(2) / (zFar - zNear); - Result[3][2] = - (zFar + zNear) / (zFar - zNear); -# endif - + Result[3][2] = - zNear / (zFar - zNear); return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> orthoRH - ( - T left, T right, - T bottom, T top, - T zNear, T zFar - ) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH_NO(T left, T right, T bottom, T top, T zNear, T zFar) { - tmat4x4<T, defaultp> Result(1); + mat<4, 4, T, defaultp> Result(1); Result[0][0] = static_cast<T>(2) / (right - left); Result[1][1] = static_cast<T>(2) / (top - bottom); + Result[2][2] = static_cast<T>(2) / (zFar - zNear); Result[3][0] = - (right + left) / (right - left); Result[3][1] = - (top + bottom) / (top - bottom); + Result[3][2] = - (zFar + zNear) / (zFar - zNear); + return Result; + } -# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - Result[2][2] = - static_cast<T>(1) / (zFar - zNear); - Result[3][2] = - zNear / (zFar - zNear); -# else - Result[2][2] = - static_cast<T>(2) / (zFar - zNear); - Result[3][2] = - (zFar + zNear) / (zFar - zNear); -# endif - + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH_ZO(T left, T right, T bottom, T top, T zNear, T zFar) + { + mat<4, 4, T, defaultp> Result(1); + Result[0][0] = static_cast<T>(2) / (right - left); + Result[1][1] = static_cast<T>(2) / (top - bottom); + Result[2][2] = - static_cast<T>(1) / (zFar - zNear); + Result[3][0] = - (right + left) / (right - left); + Result[3][1] = - (top + bottom) / (top - bottom); + Result[3][2] = - zNear / (zFar - zNear); return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> ortho - ( - T left, T right, - T bottom, T top - ) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH_NO(T left, T right, T bottom, T top, T zNear, T zFar) { - tmat4x4<T, defaultp> Result(static_cast<T>(1)); + mat<4, 4, T, defaultp> Result(1); Result[0][0] = static_cast<T>(2) / (right - left); Result[1][1] = static_cast<T>(2) / (top - bottom); - Result[2][2] = - static_cast<T>(1); + Result[2][2] = - static_cast<T>(2) / (zFar - zNear); Result[3][0] = - (right + left) / (right - left); Result[3][1] = - (top + bottom) / (top - bottom); + Result[3][2] = - (zFar + zNear) / (zFar - zNear); return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustum - ( - T left, T right, - T bottom, T top, - T nearVal, T farVal - ) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoZO(T left, T right, T bottom, T top, T zNear, T zFar) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED + return orthoLH_ZO(left, right, bottom, top, zNear, zFar); +# else + return orthoRH_ZO(left, right, bottom, top, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoNO(T left, T right, T bottom, T top, T zNear, T zFar) { # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED - return frustumLH(left, right, bottom, top, nearVal, farVal); + return orthoLH_NO(left, right, bottom, top, zNear, zFar); # else - return frustumRH(left, right, bottom, top, nearVal, farVal); + return orthoRH_NO(left, right, bottom, top, zNear, zFar); # endif } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustumLH - ( - T left, T right, - T bottom, T top, - T nearVal, T farVal - ) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH(T left, T right, T bottom, T top, T zNear, T zFar) { - tmat4x4<T, defaultp> Result(0); +# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return orthoLH_ZO(left, right, bottom, top, zNear, zFar); +# else + return orthoLH_NO(left, right, bottom, top, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH(T left, T right, T bottom, T top, T zNear, T zFar) + { +# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return orthoRH_ZO(left, right, bottom, top, zNear, zFar); +# else + return orthoRH_NO(left, right, bottom, top, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> ortho(T left, T right, T bottom, T top, T zNear, T zFar) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return orthoLH_ZO(left, right, bottom, top, zNear, zFar); +# elif GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_NEGATIVE_ONE_TO_ONE + return orthoLH_NO(left, right, bottom, top, zNear, zFar); +# elif GLM_COORDINATE_SYSTEM == GLM_RIGHT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return orthoRH_ZO(left, right, bottom, top, zNear, zFar); +# elif GLM_COORDINATE_SYSTEM == GLM_RIGHT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_NEGATIVE_ONE_TO_ONE + return orthoRH_NO(left, right, bottom, top, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH_ZO(T left, T right, T bottom, T top, T nearVal, T farVal) + { + mat<4, 4, T, defaultp> Result(0); Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left); Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom); Result[2][0] = (right + left) / (right - left); Result[2][1] = (top + bottom) / (top - bottom); + Result[2][2] = farVal / (farVal - nearVal); Result[2][3] = static_cast<T>(1); + Result[3][2] = -(farVal * nearVal) / (farVal - nearVal); + return Result; + } -# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - Result[2][2] = farVal / (farVal - nearVal); - Result[3][2] = -(farVal * nearVal) / (farVal - nearVal); -# else - Result[2][2] = (farVal + nearVal) / (farVal - nearVal); - Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal); -# endif + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH_NO(T left, T right, T bottom, T top, T nearVal, T farVal) + { + mat<4, 4, T, defaultp> Result(0); + Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left); + Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom); + Result[2][0] = (right + left) / (right - left); + Result[2][1] = (top + bottom) / (top - bottom); + Result[2][2] = (farVal + nearVal) / (farVal - nearVal); + Result[2][3] = static_cast<T>(1); + Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal); + return Result; + } + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH_ZO(T left, T right, T bottom, T top, T nearVal, T farVal) + { + mat<4, 4, T, defaultp> Result(0); + Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left); + Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom); + Result[2][0] = (right + left) / (right - left); + Result[2][1] = (top + bottom) / (top - bottom); + Result[2][2] = farVal / (nearVal - farVal); + Result[2][3] = static_cast<T>(-1); + Result[3][2] = -(farVal * nearVal) / (farVal - nearVal); return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustumRH - ( - T left, T right, - T bottom, T top, - T nearVal, T farVal - ) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH_NO(T left, T right, T bottom, T top, T nearVal, T farVal) { - tmat4x4<T, defaultp> Result(0); + mat<4, 4, T, defaultp> Result(0); Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left); Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom); Result[2][0] = (right + left) / (right - left); Result[2][1] = (top + bottom) / (top - bottom); + Result[2][2] = - (farVal + nearVal) / (farVal - nearVal); Result[2][3] = static_cast<T>(-1); + Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal); + return Result; + } -# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - Result[2][2] = farVal / (nearVal - farVal); - Result[3][2] = -(farVal * nearVal) / (farVal - nearVal); + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumZO(T left, T right, T bottom, T top, T nearVal, T farVal) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED + return frustumLH_ZO(left, right, bottom, top, nearVal, farVal); # else - Result[2][2] = - (farVal + nearVal) / (farVal - nearVal); - Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal); + return frustumRH_ZO(left, right, bottom, top, nearVal, farVal); # endif - - return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspective(T fovy, T aspect, T zNear, T zFar) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumNO(T left, T right, T bottom, T top, T nearVal, T farVal) { # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED - return perspectiveLH(fovy, aspect, zNear, zFar); + return frustumLH_NO(left, right, bottom, top, nearVal, farVal); +# else + return frustumRH_NO(left, right, bottom, top, nearVal, farVal); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH(T left, T right, T bottom, T top, T nearVal, T farVal) + { +# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return frustumLH_ZO(left, right, bottom, top, nearVal, farVal); # else - return perspectiveRH(fovy, aspect, zNear, zFar); + return frustumLH_NO(left, right, bottom, top, nearVal, farVal); # endif } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveRH(T fovy, T aspect, T zNear, T zFar) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH(T left, T right, T bottom, T top, T nearVal, T farVal) + { +# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return frustumRH_ZO(left, right, bottom, top, nearVal, farVal); +# else + return frustumRH_NO(left, right, bottom, top, nearVal, farVal); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustum(T left, T right, T bottom, T top, T nearVal, T farVal) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return frustumLH_ZO(left, right, bottom, top, nearVal, farVal); +# elif GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_NEGATIVE_ONE_TO_ONE + return frustumLH_NO(left, right, bottom, top, nearVal, farVal); +# elif GLM_COORDINATE_SYSTEM == GLM_RIGHT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return frustumRH_ZO(left, right, bottom, top, nearVal, farVal); +# elif GLM_COORDINATE_SYSTEM == GLM_RIGHT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_NEGATIVE_ONE_TO_ONE + return frustumRH_NO(left, right, bottom, top, nearVal, farVal); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH_ZO(T fovy, T aspect, T zNear, T zFar) { assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0)); T const tanHalfFovy = tan(fovy / static_cast<T>(2)); - tmat4x4<T, defaultp> Result(static_cast<T>(0)); + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy); Result[1][1] = static_cast<T>(1) / (tanHalfFovy); + Result[2][2] = zFar / (zNear - zFar); Result[2][3] = - static_cast<T>(1); + Result[3][2] = -(zFar * zNear) / (zFar - zNear); + return Result; + } -# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - Result[2][2] = zFar / (zNear - zFar); - Result[3][2] = -(zFar * zNear) / (zFar - zNear); -# else - Result[2][2] = - (zFar + zNear) / (zFar - zNear); - Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear); -# endif + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH_NO(T fovy, T aspect, T zNear, T zFar) + { + assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0)); + + T const tanHalfFovy = tan(fovy / static_cast<T>(2)); + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); + Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy); + Result[1][1] = static_cast<T>(1) / (tanHalfFovy); + Result[2][2] = - (zFar + zNear) / (zFar - zNear); + Result[2][3] = - static_cast<T>(1); + Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear); return Result; } - - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveLH(T fovy, T aspect, T zNear, T zFar) + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH_ZO(T fovy, T aspect, T zNear, T zFar) { assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0)); T const tanHalfFovy = tan(fovy / static_cast<T>(2)); - - tmat4x4<T, defaultp> Result(static_cast<T>(0)); + + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy); Result[1][1] = static_cast<T>(1) / (tanHalfFovy); + Result[2][2] = zFar / (zFar - zNear); Result[2][3] = static_cast<T>(1); + Result[3][2] = -(zFar * zNear) / (zFar - zNear); + return Result; + } -# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - Result[2][2] = zFar / (zFar - zNear); - Result[3][2] = -(zFar * zNear) / (zFar - zNear); -# else - Result[2][2] = (zFar + zNear) / (zFar - zNear); - Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear); -# endif + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH_NO(T fovy, T aspect, T zNear, T zFar) + { + assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0)); + + T const tanHalfFovy = tan(fovy / static_cast<T>(2)); + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); + Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy); + Result[1][1] = static_cast<T>(1) / (tanHalfFovy); + Result[2][2] = (zFar + zNear) / (zFar - zNear); + Result[2][3] = static_cast<T>(1); + Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear); return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveFov(T fov, T width, T height, T zNear, T zFar) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveZO(T fovy, T aspect, T zNear, T zFar) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED + return perspectiveLH_ZO(fovy, aspect, zNear, zFar); +# else + return perspectiveRH_ZO(fovy, aspect, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveNO(T fovy, T aspect, T zNear, T zFar) { # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED - return perspectiveFovLH(fov, width, height, zNear, zFar); + return perspectiveLH_NO(fovy, aspect, zNear, zFar); +# else + return perspectiveRH_NO(fovy, aspect, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH(T fovy, T aspect, T zNear, T zFar) + { +# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return perspectiveLH_ZO(fovy, aspect, zNear, zFar); # else - return perspectiveFovRH(fov, width, height, zNear, zFar); + return perspectiveLH_NO(fovy, aspect, zNear, zFar); # endif } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveFovRH(T fov, T width, T height, T zNear, T zFar) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH(T fovy, T aspect, T zNear, T zFar) + { +# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return perspectiveRH_ZO(fovy, aspect, zNear, zFar); +# else + return perspectiveRH_NO(fovy, aspect, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspective(T fovy, T aspect, T zNear, T zFar) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return perspectiveLH_ZO(fovy, aspect, zNear, zFar); +# elif GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_NEGATIVE_ONE_TO_ONE + return perspectiveLH_NO(fovy, aspect, zNear, zFar); +# elif GLM_COORDINATE_SYSTEM == GLM_RIGHT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return perspectiveRH_ZO(fovy, aspect, zNear, zFar); +# elif GLM_COORDINATE_SYSTEM == GLM_RIGHT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_NEGATIVE_ONE_TO_ONE + return perspectiveRH_NO(fovy, aspect, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH_ZO(T fov, T width, T height, T zNear, T zFar) { assert(width > static_cast<T>(0)); assert(height > static_cast<T>(0)); assert(fov > static_cast<T>(0)); - + T const rad = fov; T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad); T const w = h * height / width; ///todo max(width , Height) / min(width , Height)? - tmat4x4<T, defaultp> Result(static_cast<T>(0)); + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); Result[0][0] = w; Result[1][1] = h; + Result[2][2] = zFar / (zNear - zFar); Result[2][3] = - static_cast<T>(1); + Result[3][2] = -(zFar * zNear) / (zFar - zNear); + return Result; + } -# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - Result[2][2] = zFar / (zNear - zFar); - Result[3][2] = -(zFar * zNear) / (zFar - zNear); -# else - Result[2][2] = - (zFar + zNear) / (zFar - zNear); - Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear); -# endif + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH_NO(T fov, T width, T height, T zNear, T zFar) + { + assert(width > static_cast<T>(0)); + assert(height > static_cast<T>(0)); + assert(fov > static_cast<T>(0)); + + T const rad = fov; + T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad); + T const w = h * height / width; ///todo max(width , Height) / min(width , Height)? + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); + Result[0][0] = w; + Result[1][1] = h; + Result[2][2] = - (zFar + zNear) / (zFar - zNear); + Result[2][3] = - static_cast<T>(1); + Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear); return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> perspectiveFovLH(T fov, T width, T height, T zNear, T zFar) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH_ZO(T fov, T width, T height, T zNear, T zFar) { assert(width > static_cast<T>(0)); assert(height > static_cast<T>(0)); assert(fov > static_cast<T>(0)); - + T const rad = fov; T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad); T const w = h * height / width; ///todo max(width , Height) / min(width , Height)? - tmat4x4<T, defaultp> Result(static_cast<T>(0)); + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); Result[0][0] = w; Result[1][1] = h; + Result[2][2] = zFar / (zFar - zNear); Result[2][3] = static_cast<T>(1); + Result[3][2] = -(zFar * zNear) / (zFar - zNear); + return Result; + } -# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - Result[2][2] = zFar / (zFar - zNear); - Result[3][2] = -(zFar * zNear) / (zFar - zNear); -# else - Result[2][2] = (zFar + zNear) / (zFar - zNear); - Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear); -# endif + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH_NO(T fov, T width, T height, T zNear, T zFar) + { + assert(width > static_cast<T>(0)); + assert(height > static_cast<T>(0)); + assert(fov > static_cast<T>(0)); + + T const rad = fov; + T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad); + T const w = h * height / width; ///todo max(width , Height) / min(width , Height)? + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); + Result[0][0] = w; + Result[1][1] = h; + Result[2][2] = (zFar + zNear) / (zFar - zNear); + Result[2][3] = static_cast<T>(1); + Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear); return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> infinitePerspective(T fovy, T aspect, T zNear) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovZO(T fov, T width, T height, T zNear, T zFar) { # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED - return infinitePerspectiveLH(fovy, aspect, zNear); + return perspectiveFovLH_ZO(fov, width, height, zNear, zFar); # else - return infinitePerspectiveRH(fovy, aspect, zNear); + return perspectiveFovRH_ZO(fov, width, height, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovNO(T fov, T width, T height, T zNear, T zFar) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED + return perspectiveFovLH_NO(fov, width, height, zNear, zFar); +# else + return perspectiveFovRH_NO(fov, width, height, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH(T fov, T width, T height, T zNear, T zFar) + { +# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return perspectiveFovLH_ZO(fov, width, height, zNear, zFar); +# else + return perspectiveFovLH_NO(fov, width, height, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH(T fov, T width, T height, T zNear, T zFar) + { +# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return perspectiveFovRH_ZO(fov, width, height, zNear, zFar); +# else + return perspectiveFovRH_NO(fov, width, height, zNear, zFar); # endif } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> infinitePerspectiveRH(T fovy, T aspect, T zNear) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFov(T fov, T width, T height, T zNear, T zFar) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return perspectiveFovLH_ZO(fov, width, height, zNear, zFar); +# elif GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_NEGATIVE_ONE_TO_ONE + return perspectiveFovLH_NO(fov, width, height, zNear, zFar); +# elif GLM_COORDINATE_SYSTEM == GLM_RIGHT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return perspectiveFovRH_ZO(fov, width, height, zNear, zFar); +# elif GLM_COORDINATE_SYSTEM == GLM_RIGHT_HANDED && GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_NEGATIVE_ONE_TO_ONE + return perspectiveFovRH_NO(fov, width, height, zNear, zFar); +# endif + } + + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveRH(T fovy, T aspect, T zNear) { T const range = tan(fovy / static_cast<T>(2)) * zNear; T const left = -range * aspect; @@ -383,7 +584,7 @@ namespace glm T const bottom = -range; T const top = range; - tmat4x4<T, defaultp> Result(static_cast<T>(0)); + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); Result[0][0] = (static_cast<T>(2) * zNear) / (right - left); Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom); Result[2][2] = - static_cast<T>(1); @@ -392,8 +593,8 @@ namespace glm return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> infinitePerspectiveLH(T fovy, T aspect, T zNear) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveLH(T fovy, T aspect, T zNear) { T const range = tan(fovy / static_cast<T>(2)) * zNear; T const left = -range * aspect; @@ -401,7 +602,7 @@ namespace glm T const bottom = -range; T const top = range; - tmat4x4<T, defaultp> Result(T(0)); + mat<4, 4, T, defaultp> Result(T(0)); Result[0][0] = (static_cast<T>(2) * zNear) / (right - left); Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom); Result[2][2] = static_cast<T>(1); @@ -410,17 +611,27 @@ namespace glm return Result; } + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspective(T fovy, T aspect, T zNear) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED + return infinitePerspectiveLH(fovy, aspect, zNear); +# else + return infinitePerspectiveRH(fovy, aspect, zNear); +# endif + } + // Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear, T ep) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear, T ep) { - T const range = tan(fovy / static_cast<T>(2)) * zNear; + T const range = tan(fovy / static_cast<T>(2)) * zNear; T const left = -range * aspect; T const right = range * aspect; T const bottom = -range; T const top = range; - tmat4x4<T, defaultp> Result(static_cast<T>(0)); + mat<4, 4, T, defaultp> Result(static_cast<T>(0)); Result[0][0] = (static_cast<T>(2) * zNear) / (right - left); Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom); Result[2][2] = ep - static_cast<T>(1); @@ -429,107 +640,124 @@ namespace glm return Result; } - template <typename T> - GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear) + template<typename T> + GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear) { return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon<T>()); } - template <typename T, typename U, precision P> - GLM_FUNC_QUALIFIER tvec3<T, P> project - ( - tvec3<T, P> const & obj, - tmat4x4<T, P> const & model, - tmat4x4<T, P> const & proj, - tvec4<U, P> const & viewport - ) + template<typename T, typename U, qualifier Q> + GLM_FUNC_QUALIFIER vec<3, T, Q> projectZO(vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport) { - tvec4<T, P> tmp = tvec4<T, P>(obj, static_cast<T>(1)); + vec<4, T, Q> tmp = vec<4, T, Q>(obj, static_cast<T>(1)); tmp = model * tmp; tmp = proj * tmp; tmp /= tmp.w; -# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - tmp.x = tmp.x * static_cast<T>(0.5) + static_cast<T>(0.5); - tmp.y = tmp.y * static_cast<T>(0.5) + static_cast<T>(0.5); -# else - tmp = tmp * static_cast<T>(0.5) + static_cast<T>(0.5); -# endif + tmp.x = tmp.x * static_cast<T>(0.5) + static_cast<T>(0.5); + tmp.y = tmp.y * static_cast<T>(0.5) + static_cast<T>(0.5); + tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]); - return tvec3<T, P>(tmp); + return vec<3, T, Q>(tmp); } - template <typename T, typename U, precision P> - GLM_FUNC_QUALIFIER tvec3<T, P> unProject - ( - tvec3<T, P> const & win, - tmat4x4<T, P> const & model, - tmat4x4<T, P> const & proj, - tvec4<U, P> const & viewport - ) + template<typename T, typename U, qualifier Q> + GLM_FUNC_QUALIFIER vec<3, T, Q> projectNO(vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport) { - tmat4x4<T, P> Inverse = inverse(proj * model); + vec<4, T, Q> tmp = vec<4, T, Q>(obj, static_cast<T>(1)); + tmp = model * tmp; + tmp = proj * tmp; - tvec4<T, P> tmp = tvec4<T, P>(win, T(1)); - tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]); - tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]); + tmp /= tmp.w; + tmp = tmp * static_cast<T>(0.5) + static_cast<T>(0.5); + tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); + tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]); + + return vec<3, T, Q>(tmp); + } + + template<typename T, typename U, qualifier Q> + GLM_FUNC_QUALIFIER vec<3, T, Q> project(vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport) + { # if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - tmp.x = tmp.x * static_cast<T>(2) - static_cast<T>(1); - tmp.y = tmp.y * static_cast<T>(2) - static_cast<T>(1); + return projectZO(obj, model, proj, viewport); # else - tmp = tmp * static_cast<T>(2) - static_cast<T>(1); + return projectNO(obj, model, proj, viewport); # endif + } + + template<typename T, typename U, qualifier Q> + GLM_FUNC_QUALIFIER vec<3, T, Q> unProjectZO(vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport) + { + mat<4, 4, T, Q> Inverse = inverse(proj * model); + + vec<4, T, Q> tmp = vec<4, T, Q>(win, T(1)); + tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]); + tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]); + tmp.x = tmp.x * static_cast<T>(2) - static_cast<T>(1); + tmp.y = tmp.y * static_cast<T>(2) - static_cast<T>(1); + + vec<4, T, Q> obj = Inverse * tmp; + obj /= obj.w; + + return vec<3, T, Q>(obj); + } + + template<typename T, typename U, qualifier Q> + GLM_FUNC_QUALIFIER vec<3, T, Q> unProjectNO(vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport) + { + mat<4, 4, T, Q> Inverse = inverse(proj * model); + + vec<4, T, Q> tmp = vec<4, T, Q>(win, T(1)); + tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]); + tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]); + tmp = tmp * static_cast<T>(2) - static_cast<T>(1); - tvec4<T, P> obj = Inverse * tmp; + vec<4, T, Q> obj = Inverse * tmp; obj /= obj.w; - return tvec3<T, P>(obj); + return vec<3, T, Q>(obj); + } + + template<typename T, typename U, qualifier Q> + GLM_FUNC_QUALIFIER vec<3, T, Q> unProject(vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport) + { +# if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE + return unProjectZO(win, model, proj, viewport); +# else + return unProjectNO(win, model, proj, viewport); +# endif } - template <typename T, precision P, typename U> - GLM_FUNC_QUALIFIER tmat4x4<T, P> pickMatrix(tvec2<T, P> const & center, tvec2<T, P> const & delta, tvec4<U, P> const & viewport) + template<typename T, qualifier Q, typename U> + GLM_FUNC_QUALIFIER mat<4, 4, T, Q> pickMatrix(vec<2, T, Q> const& center, vec<2, T, Q> const& delta, vec<4, U, Q> const& viewport) { assert(delta.x > static_cast<T>(0) && delta.y > static_cast<T>(0)); - tmat4x4<T, P> Result(static_cast<T>(1)); + mat<4, 4, T, Q> Result(static_cast<T>(1)); if(!(delta.x > static_cast<T>(0) && delta.y > static_cast<T>(0))) return Result; // Error - tvec3<T, P> Temp( + vec<3, T, Q> Temp( (static_cast<T>(viewport[2]) - static_cast<T>(2) * (center.x - static_cast<T>(viewport[0]))) / delta.x, (static_cast<T>(viewport[3]) - static_cast<T>(2) * (center.y - static_cast<T>(viewport[1]))) / delta.y, static_cast<T>(0)); // Translate and scale the picked region to the entire window Result = translate(Result, Temp); - return scale(Result, tvec3<T, P>(static_cast<T>(viewport[2]) / delta.x, static_cast<T>(viewport[3]) / delta.y, static_cast<T>(1))); + return scale(Result, vec<3, T, Q>(static_cast<T>(viewport[2]) / delta.x, static_cast<T>(viewport[3]) / delta.y, static_cast<T>(1))); } - template <typename T, precision P> - GLM_FUNC_QUALIFIER tmat4x4<T, P> lookAt(tvec3<T, P> const & eye, tvec3<T, P> const & center, tvec3<T, P> const & up) + template<typename T, qualifier Q> + GLM_FUNC_QUALIFIER mat<4, 4, T, Q> lookAtRH(vec<3, T, Q> const& eye, vec<3, T, Q> const& center, vec<3, T, Q> const& up) { -# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED - return lookAtLH(eye, center, up); -# else - return lookAtRH(eye, center, up); -# endif - } - - template <typename T, precision P> - GLM_FUNC_QUALIFIER tmat4x4<T, P> lookAtRH - ( - tvec3<T, P> const & eye, - tvec3<T, P> const & center, - tvec3<T, P> const & up - ) - { - tvec3<T, P> const f(normalize(center - eye)); - tvec3<T, P> const s(normalize(cross(f, up))); - tvec3<T, P> const u(cross(s, f)); + vec<3, T, Q> const f(normalize(center - eye)); + vec<3, T, Q> const s(normalize(cross(f, up))); + vec<3, T, Q> const u(cross(s, f)); - tmat4x4<T, P> Result(1); + mat<4, 4, T, Q> Result(1); Result[0][0] = s.x; Result[1][0] = s.y; Result[2][0] = s.z; @@ -545,19 +773,14 @@ namespace glm return Result; } - template <typename T, precision P> - GLM_FUNC_QUALIFIER tmat4x4<T, P> lookAtLH - ( - tvec3<T, P> const & eye, - tvec3<T, P> const & center, - tvec3<T, P> const & up - ) + template<typename T, qualifier Q> + GLM_FUNC_QUALIFIER mat<4, 4, T, Q> lookAtLH(vec<3, T, Q> const& eye, vec<3, T, Q> const& center, vec<3, T, Q> const& up) { - tvec3<T, P> const f(normalize(center - eye)); - tvec3<T, P> const s(normalize(cross(up, f))); - tvec3<T, P> const u(cross(f, s)); + vec<3, T, Q> const f(normalize(center - eye)); + vec<3, T, Q> const s(normalize(cross(up, f))); + vec<3, T, Q> const u(cross(f, s)); - tmat4x4<T, P> Result(1); + mat<4, 4, T, Q> Result(1); Result[0][0] = s.x; Result[1][0] = s.y; Result[2][0] = s.z; @@ -572,4 +795,14 @@ namespace glm Result[3][2] = -dot(f, eye); return Result; } + + template<typename T, qualifier Q> + GLM_FUNC_QUALIFIER mat<4, 4, T, Q> lookAt(vec<3, T, Q> const& eye, vec<3, T, Q> const& center, vec<3, T, Q> const& up) + { +# if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED + return lookAtLH(eye, center, up); +# else + return lookAtRH(eye, center, up); +# endif + } }//namespace glm |