mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 12:41:54 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
71f2b2f422
@ -123,7 +123,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> atan(vecType<T, P> const & a, vecType<T, P> const & b)
|
GLM_FUNC_QUALIFIER vecType<T, P> atan(vecType<T, P> const & a, vecType<T, P> const & b)
|
||||||
{
|
{
|
||||||
return detail::functor2<T, P, vecType>::call(atan2, a, b);
|
return detail::functor2<T, P, vecType>::call(::std::atan2, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
using std::atan;
|
using std::atan;
|
||||||
|
@ -579,25 +579,20 @@
|
|||||||
# endif
|
# endif
|
||||||
# elif GLM_COMPILER & GLM_COMPILER_INTEL
|
# elif GLM_COMPILER & GLM_COMPILER_INTEL
|
||||||
# ifdef _MSC_EXTENSIONS
|
# ifdef _MSC_EXTENSIONS
|
||||||
|
# define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG
|
||||||
|
# else
|
||||||
|
# define GLM_MSC_EXT
|
||||||
|
# endif
|
||||||
|
# if __INTEL_CXX11_MODE__
|
||||||
# if __cplusplus >= 201402L
|
# if __cplusplus >= 201402L
|
||||||
# define GLM_LANG (GLM_LANG_CXX14 | GLM_LANG_CXXMS_FLAG)
|
# define GLM_LANG (GLM_LANG_CXX14 | GLM_LANG_CXXMS_FLAG)
|
||||||
# elif __cplusplus >= 201103L
|
# elif __cplusplus >= 201103L
|
||||||
# define GLM_LANG (GLM_LANG_CXX11 | GLM_LANG_CXXMS_FLAG)
|
# define GLM_LANG (GLM_LANG_CXX11 | GLM_LANG_CXXMS_FLAG)
|
||||||
# elif GLM_COMPILER >= GLM_COMPILER_INTEL13
|
|
||||||
# define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
|
|
||||||
# elif __cplusplus >= 199711L
|
|
||||||
# define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_CXXMS_FLAG)
|
|
||||||
# else
|
# else
|
||||||
# define GLM_LANG (GLM_LANG_CXX | GLM_LANG_CXXMS_FLAG)
|
# define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
# if __cplusplus >= 201402L
|
# if __cplusplus >= 199711L
|
||||||
# define GLM_LANG (GLM_LANG_CXX14 | GLM_LANG_CXXMS_FLAG)
|
|
||||||
# elif __cplusplus >= 201103L
|
|
||||||
# define GLM_LANG (GLM_LANG_CXX11 | GLM_LANG_CXXMS_FLAG)
|
|
||||||
# elif GLM_COMPILER >= GLM_COMPILER_INTEL13
|
|
||||||
# define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
|
|
||||||
# elif __cplusplus >= 199711L
|
|
||||||
# define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_CXXMS_FLAG)
|
# define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_CXXMS_FLAG)
|
||||||
# else
|
# else
|
||||||
# define GLM_LANG (GLM_LANG_CXX | GLM_LANG_CXXMS_FLAG)
|
# define GLM_LANG (GLM_LANG_CXX | GLM_LANG_CXXMS_FLAG)
|
||||||
@ -669,7 +664,7 @@
|
|||||||
# define GLM_HAS_CXX11_STL ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && \
|
# define GLM_HAS_CXX11_STL ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && \
|
||||||
((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
|
((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
|
||||||
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \
|
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \
|
||||||
((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)))
|
((GLM_PLATFORM != GLM_PLATFORM_WINDOWS) && (GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// N1720
|
// N1720
|
||||||
|
@ -116,7 +116,7 @@ namespace glm
|
|||||||
tmat4x4<T, P> const & m,
|
tmat4x4<T, P> const & m,
|
||||||
tvec3<T, P> const & v);
|
tvec3<T, P> const & v);
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume.
|
/// Creates a matrix for an orthographic parallel viewing volume, using the default handedness.
|
||||||
///
|
///
|
||||||
/// @param left
|
/// @param left
|
||||||
/// @param right
|
/// @param right
|
||||||
@ -136,6 +136,46 @@ namespace glm
|
|||||||
T zNear,
|
T zNear,
|
||||||
T zFar);
|
T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using left-handedness.
|
||||||
|
///
|
||||||
|
/// @param left
|
||||||
|
/// @param right
|
||||||
|
/// @param bottom
|
||||||
|
/// @param top
|
||||||
|
/// @param zNear
|
||||||
|
/// @param zFar
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top)
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_DECL tmat4x4<T, defaultp> orthoLH(
|
||||||
|
T left,
|
||||||
|
T right,
|
||||||
|
T bottom,
|
||||||
|
T top,
|
||||||
|
T zNear,
|
||||||
|
T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using right-handedness.
|
||||||
|
///
|
||||||
|
/// @param left
|
||||||
|
/// @param right
|
||||||
|
/// @param bottom
|
||||||
|
/// @param top
|
||||||
|
/// @param zNear
|
||||||
|
/// @param zFar
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top)
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_DECL tmat4x4<T, defaultp> orthoRH(
|
||||||
|
T left,
|
||||||
|
T right,
|
||||||
|
T bottom,
|
||||||
|
T top,
|
||||||
|
T zNear,
|
||||||
|
T zFar);
|
||||||
|
|
||||||
/// Creates a matrix for projecting two-dimensional coordinates onto the screen.
|
/// Creates a matrix for projecting two-dimensional coordinates onto the screen.
|
||||||
///
|
///
|
||||||
/// @param left
|
/// @param left
|
||||||
@ -152,7 +192,7 @@ namespace glm
|
|||||||
T bottom,
|
T bottom,
|
||||||
T top);
|
T top);
|
||||||
|
|
||||||
/// Creates a frustum matrix.
|
/// Creates a frustum matrix with default handedness.
|
||||||
///
|
///
|
||||||
/// @param left
|
/// @param left
|
||||||
/// @param right
|
/// @param right
|
||||||
@ -171,6 +211,44 @@ namespace glm
|
|||||||
T near,
|
T near,
|
||||||
T far);
|
T far);
|
||||||
|
|
||||||
|
/// Creates a left handed frustum matrix.
|
||||||
|
///
|
||||||
|
/// @param left
|
||||||
|
/// @param right
|
||||||
|
/// @param bottom
|
||||||
|
/// @param top
|
||||||
|
/// @param near
|
||||||
|
/// @param far
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_DECL tmat4x4<T, defaultp> frustumLH(
|
||||||
|
T left,
|
||||||
|
T right,
|
||||||
|
T bottom,
|
||||||
|
T top,
|
||||||
|
T near,
|
||||||
|
T far);
|
||||||
|
|
||||||
|
/// Creates a right handed frustum matrix.
|
||||||
|
///
|
||||||
|
/// @param left
|
||||||
|
/// @param right
|
||||||
|
/// @param bottom
|
||||||
|
/// @param top
|
||||||
|
/// @param near
|
||||||
|
/// @param far
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_DECL tmat4x4<T, defaultp> frustumRH(
|
||||||
|
T left,
|
||||||
|
T right,
|
||||||
|
T bottom,
|
||||||
|
T top,
|
||||||
|
T near,
|
||||||
|
T far);
|
||||||
|
|
||||||
/// Creates a matrix for a symetric perspective-view frustum based on the default handedness.
|
/// Creates a matrix for a symetric perspective-view frustum based on the default handedness.
|
||||||
///
|
///
|
||||||
/// @param fovy Specifies the field of view angle in the y direction. Expressed in radians.
|
/// @param fovy Specifies the field of view angle in the y direction. Expressed in radians.
|
||||||
@ -267,7 +345,7 @@ namespace glm
|
|||||||
T near,
|
T near,
|
||||||
T far);
|
T far);
|
||||||
|
|
||||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite.
|
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite with default handedness.
|
||||||
///
|
///
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
@ -278,6 +356,28 @@ namespace glm
|
|||||||
GLM_FUNC_DECL tmat4x4<T, defaultp> infinitePerspective(
|
GLM_FUNC_DECL tmat4x4<T, defaultp> infinitePerspective(
|
||||||
T fovy, T aspect, T near);
|
T fovy, T aspect, T near);
|
||||||
|
|
||||||
|
/// Creates a matrix for a left handed, symmetric perspective-view frustum with far plane at infinite.
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_DECL tmat4x4<T, defaultp> infinitePerspectiveLH(
|
||||||
|
T fovy, T aspect, T near);
|
||||||
|
|
||||||
|
/// Creates a matrix for a right handed, symmetric perspective-view frustum with far plane at infinite.
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_DECL tmat4x4<T, defaultp> infinitePerspectiveRH(
|
||||||
|
T fovy, T aspect, T near);
|
||||||
|
|
||||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||||
///
|
///
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
@ -157,14 +157,65 @@ namespace glm
|
|||||||
T zNear,
|
T zNear,
|
||||||
T zFar
|
T zFar
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
#ifdef GLM_LEFT_HANDED
|
||||||
|
return orthoLH(left, right, bottom, top, zNear, zFar);
|
||||||
|
#else
|
||||||
|
return orthoRH(left, right, bottom, top, zNear, zFar);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> orthoLH
|
||||||
|
(
|
||||||
|
T left,
|
||||||
|
T right,
|
||||||
|
T bottom,
|
||||||
|
T top,
|
||||||
|
T zNear,
|
||||||
|
T zFar
|
||||||
|
)
|
||||||
{
|
{
|
||||||
tmat4x4<T, defaultp> Result(1);
|
tmat4x4<T, defaultp> Result(1);
|
||||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
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][0] = - (right + left) / (right - left);
|
||||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||||
|
|
||||||
|
#ifdef 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);
|
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
||||||
|
#endif
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> orthoRH
|
||||||
|
(
|
||||||
|
T left,
|
||||||
|
T right,
|
||||||
|
T bottom,
|
||||||
|
T top,
|
||||||
|
T zNear,
|
||||||
|
T zFar
|
||||||
|
)
|
||||||
|
{
|
||||||
|
tmat4x4<T, defaultp> Result(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);
|
||||||
|
|
||||||
|
#ifdef 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
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,15 +247,67 @@ namespace glm
|
|||||||
T nearVal,
|
T nearVal,
|
||||||
T farVal
|
T farVal
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
#ifdef GLM_LEFT_HANDED
|
||||||
|
return frustumLH(left, right, bottom, top, nearVal, farVal);
|
||||||
|
#else
|
||||||
|
return frustumRH(left, right, bottom, top, nearVal, farVal);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustumLH
|
||||||
|
(
|
||||||
|
T left,
|
||||||
|
T right,
|
||||||
|
T bottom,
|
||||||
|
T top,
|
||||||
|
T nearVal,
|
||||||
|
T farVal
|
||||||
|
)
|
||||||
{
|
{
|
||||||
tmat4x4<T, defaultp> Result(0);
|
tmat4x4<T, defaultp> Result(0);
|
||||||
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
||||||
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
||||||
Result[2][0] = (right + left) / (right - left);
|
Result[2][0] = (right + left) / (right - left);
|
||||||
Result[2][1] = (top + bottom) / (top - bottom);
|
Result[2][1] = (top + bottom) / (top - bottom);
|
||||||
Result[2][2] = -(farVal + nearVal) / (farVal - nearVal);
|
Result[2][3] = static_cast<T>(1);
|
||||||
Result[2][3] = static_cast<T>(-1);
|
|
||||||
|
#ifdef GLM_DEPTH_ZERO_TO_ONE
|
||||||
|
Result[2][2] = farVal / (zFar - nearVal);
|
||||||
|
Result[3][2] = -(farVal * nearVal) / (zFar - nearVal);
|
||||||
|
#else
|
||||||
|
Result[2][2] = (farVal + nearVal) / (farVal - nearVal);
|
||||||
Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
|
Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
|
||||||
|
#endif
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustumRH
|
||||||
|
(
|
||||||
|
T left,
|
||||||
|
T right,
|
||||||
|
T bottom,
|
||||||
|
T top,
|
||||||
|
T nearVal,
|
||||||
|
T farVal
|
||||||
|
)
|
||||||
|
{
|
||||||
|
tmat4x4<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][3] = static_cast<T>(-1);
|
||||||
|
|
||||||
|
#ifdef GLM_DEPTH_ZERO_TO_ONE
|
||||||
|
Result[2][2] = farVal / (nearVal - farVal);
|
||||||
|
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
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,9 +343,15 @@ namespace glm
|
|||||||
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
|
||||||
Result[2][3] = - static_cast<T>(1);
|
Result[2][3] = - static_cast<T>(1);
|
||||||
|
|
||||||
|
#ifdef 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);
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
|
#endif
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,9 +371,15 @@ namespace glm
|
|||||||
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||||
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
Result[2][3] = static_cast<T>(1);
|
||||||
|
|
||||||
|
#ifdef 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);
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
|
#endif
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,9 +421,15 @@ namespace glm
|
|||||||
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||||
Result[0][0] = w;
|
Result[0][0] = w;
|
||||||
Result[1][1] = h;
|
Result[1][1] = h;
|
||||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
|
||||||
Result[2][3] = - static_cast<T>(1);
|
Result[2][3] = - static_cast<T>(1);
|
||||||
|
|
||||||
|
#ifdef 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);
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
|
#endif
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,9 +454,16 @@ namespace glm
|
|||||||
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||||
Result[0][0] = w;
|
Result[0][0] = w;
|
||||||
Result[1][1] = h;
|
Result[1][1] = h;
|
||||||
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
Result[2][3] = static_cast<T>(1);
|
||||||
|
|
||||||
|
#ifdef 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);
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
|
#endif
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +474,21 @@ namespace glm
|
|||||||
T aspect,
|
T aspect,
|
||||||
T zNear
|
T zNear
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
#ifdef GLM_LEFT_HANDED
|
||||||
|
return infinitePerspectiveLH(fovy, aspect, zNear);
|
||||||
|
#else
|
||||||
|
return infinitePerspectiveRH(fovy, aspect, zNear);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> infinitePerspectiveRH
|
||||||
|
(
|
||||||
|
T fovy,
|
||||||
|
T aspect,
|
||||||
|
T zNear
|
||||||
|
)
|
||||||
{
|
{
|
||||||
T const range = tan(fovy / T(2)) * zNear;
|
T const range = tan(fovy / T(2)) * zNear;
|
||||||
T const left = -range * aspect;
|
T const left = -range * aspect;
|
||||||
@ -362,6 +505,29 @@ namespace glm
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> infinitePerspectiveLH
|
||||||
|
(
|
||||||
|
T fovy,
|
||||||
|
T aspect,
|
||||||
|
T zNear
|
||||||
|
)
|
||||||
|
{
|
||||||
|
T const range = tan(fovy / 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(T(0));
|
||||||
|
Result[0][0] = (T(2) * zNear) / (right - left);
|
||||||
|
Result[1][1] = (T(2) * zNear) / (top - bottom);
|
||||||
|
Result[2][2] = T(1);
|
||||||
|
Result[2][3] = T(1);
|
||||||
|
Result[3][2] = - T(2) * zNear;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
// Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
|
// Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective
|
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective
|
||||||
|
@ -161,7 +161,7 @@ namespace glm
|
|||||||
/// Extracts the (X * Y * Z) Euler angles from the rotation matrix M
|
/// Extracts the (X * Y * Z) Euler angles from the rotation matrix M
|
||||||
/// @see gtx_euler_angles
|
/// @see gtx_euler_angles
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL void extractEulerAngleXYZ(tmat4x4<T, defaultp> & M,
|
GLM_FUNC_DECL void extractEulerAngleXYZ(tmat4x4<T, defaultp> const & M,
|
||||||
T & t1,
|
T & t1,
|
||||||
T & t2,
|
T & t2,
|
||||||
T & t3);
|
T & t3);
|
||||||
|
@ -323,7 +323,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL void extractEulerAngleXYZ(tmat4x4<T, defaultp> & M,
|
GLM_FUNC_DECL void extractEulerAngleXYZ(tmat4x4<T, defaultp> const & M,
|
||||||
T & t1,
|
T & t1,
|
||||||
T & t2,
|
T & t2,
|
||||||
T & t3)
|
T & t3)
|
||||||
|
@ -49,7 +49,7 @@ namespace glm
|
|||||||
typename genType::value_type a = glm::dot(e1, p);
|
typename genType::value_type a = glm::dot(e1, p);
|
||||||
|
|
||||||
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||||
if(a < Epsilon)
|
if(a < Epsilon && a > -Epsilon)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
typename genType::value_type f = typename genType::value_type(1.0f) / a;
|
typename genType::value_type f = typename genType::value_type(1.0f) / a;
|
||||||
@ -73,43 +73,6 @@ namespace glm
|
|||||||
return baryPosition.z >= typename genType::value_type(0.0f);
|
return baryPosition.z >= typename genType::value_type(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//template <typename genType>
|
|
||||||
//GLM_FUNC_QUALIFIER bool intersectRayTriangle
|
|
||||||
//(
|
|
||||||
// genType const & orig, genType const & dir,
|
|
||||||
// genType const & vert0, genType const & vert1, genType const & vert2,
|
|
||||||
// genType & position
|
|
||||||
//)
|
|
||||||
//{
|
|
||||||
// typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
|
||||||
//
|
|
||||||
// genType edge1 = vert1 - vert0;
|
|
||||||
// genType edge2 = vert2 - vert0;
|
|
||||||
//
|
|
||||||
// genType pvec = cross(dir, edge2);
|
|
||||||
//
|
|
||||||
// float det = dot(edge1, pvec);
|
|
||||||
// if(det < Epsilon)
|
|
||||||
// return false;
|
|
||||||
//
|
|
||||||
// genType tvec = orig - vert0;
|
|
||||||
//
|
|
||||||
// position.y = dot(tvec, pvec);
|
|
||||||
// if (position.y < typename genType::value_type(0) || position.y > det)
|
|
||||||
// return typename genType::value_type(0);
|
|
||||||
//
|
|
||||||
// genType qvec = cross(tvec, edge1);
|
|
||||||
//
|
|
||||||
// position.z = dot(dir, qvec);
|
|
||||||
// if (position.z < typename genType::value_type(0) || position.y + position.z > det)
|
|
||||||
// return typename genType::value_type(0);
|
|
||||||
//
|
|
||||||
// position.x = dot(edge2, qvec);
|
|
||||||
// position *= typename genType::value_type(1) / det;
|
|
||||||
//
|
|
||||||
// return typename genType::value_type(1);
|
|
||||||
//}
|
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER bool intersectLineTriangle
|
GLM_FUNC_QUALIFIER bool intersectLineTriangle
|
||||||
(
|
(
|
||||||
|
@ -58,15 +58,15 @@ namespace glm
|
|||||||
/// @addtogroup gtx_vector_angle
|
/// @addtogroup gtx_vector_angle
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
//! Returns the absolute angle between two vectors
|
//! Returns the absolute angle between two vectors.
|
||||||
//! Parameters need to be normalized.
|
//! Parameters need to be normalized.
|
||||||
/// @see gtx_vector_angle extension
|
/// @see gtx_vector_angle extension.
|
||||||
template <typename vecType>
|
template <typename vecType>
|
||||||
GLM_FUNC_DECL typename vecType::value_type angle(
|
GLM_FUNC_DECL typename vecType::value_type angle(
|
||||||
vecType const & x,
|
vecType const & x,
|
||||||
vecType const & y);
|
vecType const & y);
|
||||||
|
|
||||||
//! Returns the oriented angle between two 2d vectors
|
//! Returns the oriented angle between two 2d vectors.
|
||||||
//! Parameters need to be normalized.
|
//! Parameters need to be normalized.
|
||||||
/// @see gtx_vector_angle extension.
|
/// @see gtx_vector_angle extension.
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
|
@ -68,6 +68,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
|
|||||||
|
|
||||||
##### Fixes:
|
##### Fixes:
|
||||||
- Fixed GTX_extended_min_max filename typo #386
|
- Fixed GTX_extended_min_max filename typo #386
|
||||||
|
- Fixed intersectRayTriangle to not do any unintentional backface culling
|
||||||
|
|
||||||
#### [GLM 0.9.7.2](https://github.com/g-truc/glm/tree/0.9.7) - 2015-XX-XX
|
#### [GLM 0.9.7.2](https://github.com/g-truc/glm/tree/0.9.7) - 2015-XX-XX
|
||||||
##### Fixes:
|
##### Fixes:
|
||||||
|
@ -63,10 +63,10 @@ int test_log2()
|
|||||||
Error += glm::abs(double(A) - B) <= 24 ? 0 : 1;
|
Error += glm::abs(double(A) - B) <= 24 ? 0 : 1;
|
||||||
assert(!Error);
|
assert(!Error);
|
||||||
|
|
||||||
printf("Log2(%d) Error: %d, %d\n", 1 << i, A, B);
|
printf("Log2(%d) error A=%d, B=%d\n", 1 << i, A, B);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("log2 error: %d\n", Error);
|
printf("log2 error=%d\n", Error);
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user