This commit is contained in:
Christophe Riccio 2015-12-24 09:56:00 +01:00
commit d269a92c2d
12 changed files with 372 additions and 100 deletions

View File

@ -662,7 +662,7 @@ namespace detail
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'frexp' only accept floating-point inputs");
return std::frexp(x, exp);
return std::frexp(x, &exp);
}
template <typename T, precision P>
@ -670,7 +670,7 @@ namespace detail
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
return tvec1<T, P>(std::frexp(x.x, exp.x));
return tvec1<T, P>(std::frexp(x.x, &exp.x));
}
template <typename T, precision P>

View File

@ -123,7 +123,7 @@ namespace glm
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)
{
return detail::functor2<T, P, vecType>::call(atan2, a, b);
return detail::functor2<T, P, vecType>::call(::std::atan2, a, b);
}
using std::atan;

View File

@ -65,6 +65,8 @@
#ifdef GLM_FORCE_PLATFORM_UNKNOWN
# define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
#elif defined(__CYGWIN__)
# define GLM_PLATFORM GLM_PLATFORM_CYGWIN
#elif defined(__QNXNTO__)
# define GLM_PLATFORM GLM_PLATFORM_QNXNTO
#elif defined(__APPLE__)
@ -577,25 +579,20 @@
# endif
# elif GLM_COMPILER & GLM_COMPILER_INTEL
# ifdef _MSC_EXTENSIONS
# define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG
# else
# define GLM_MSC_EXT
# endif
# if __INTEL_CXX11_MODE__
# if __cplusplus >= 201402L
# 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)
# else
# define GLM_LANG (GLM_LANG_CXX | GLM_LANG_CXXMS_FLAG)
# define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
# endif
# else
# if __cplusplus >= 201402L
# 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
# if __cplusplus >= 199711L
# define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_CXXMS_FLAG)
# else
# define GLM_LANG (GLM_LANG_CXX | GLM_LANG_CXXMS_FLAG)
@ -650,7 +647,7 @@
// http://gcc.gnu.org/projects/cxx0x.html
// http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx
#if GLM_PLATFORM == GLM_PLATFORM_ANDROID
#if GLM_PLATFORM == GLM_PLATFORM_ANDROID || GLM_PLATFORM == GLM_PLATFORM_CYGWIN
# define GLM_HAS_CXX11_STL 0
#elif GLM_COMPILER & (GLM_COMPILER_LLVM | GLM_COMPILER_APPLE_CLANG)
# if __has_include(<__config>) // libc++
@ -667,7 +664,7 @@
# 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_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
// N1720

View File

@ -116,14 +116,14 @@ namespace glm
tmat4x4<T, P> const & m,
tvec3<T, P> const & v);
/// Creates a matrix for an orthographic parallel viewing volume.
///
/// @param left
/// @param right
/// @param bottom
/// @param top
/// @param zNear
/// @param zFar
/// Creates a matrix for an orthographic parallel viewing volume, using the default 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)
@ -136,12 +136,52 @@ namespace glm
T zNear,
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.
///
/// @param left
/// @param right
/// @param bottom
/// @param top
///
/// @param left
/// @param right
/// @param bottom
/// @param top
/// @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, T const & zNear, T const & zFar)
@ -152,14 +192,14 @@ namespace glm
T bottom,
T top);
/// Creates a frustum matrix.
///
/// @param left
/// @param right
/// @param bottom
/// @param top
/// @param near
/// @param far
/// Creates a frustum matrix with default handedness.
///
/// @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>
@ -171,6 +211,44 @@ namespace glm
T near,
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.
///
/// @param fovy Specifies the field of view angle in the y direction. Expressed in radians.
@ -267,8 +345,8 @@ namespace glm
T near,
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 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).
@ -278,6 +356,28 @@ namespace glm
GLM_FUNC_DECL tmat4x4<T, defaultp> infinitePerspective(
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.
///
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.

View File

@ -157,14 +157,65 @@ namespace glm
T zNear,
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);
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);
#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;
}
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;
}
@ -177,13 +228,13 @@ namespace glm
T top
)
{
tmat4x4<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[3][0] = - (right + left) / (right - left);
Result[3][1] = - (top + bottom) / (top - bottom);
return Result;
tmat4x4<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[3][0] = - (right + left) / (right - left);
Result[3][1] = - (top + bottom) / (top - bottom);
return Result;
}
template <typename T>
@ -196,15 +247,67 @@ namespace glm
T nearVal,
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);
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 / (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
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][2] = -(farVal + nearVal) / (farVal - nearVal);
Result[2][3] = static_cast<T>(-1);
Result[3][2] = -(static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
#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;
}
@ -240,9 +343,15 @@ namespace glm
tmat4x4<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);
#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);
#endif
return Result;
}
@ -262,9 +371,15 @@ namespace glm
tmat4x4<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);
#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);
#endif
return Result;
}
@ -306,9 +421,15 @@ namespace glm
tmat4x4<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);
#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);
#endif
return Result;
}
@ -333,9 +454,16 @@ namespace glm
tmat4x4<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);
#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);
#endif
return Result;
}
@ -346,6 +474,21 @@ namespace glm
T aspect,
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 left = -range * aspect;
@ -362,6 +505,29 @@ namespace glm
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
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> tweakedInfinitePerspective

View File

@ -161,7 +161,7 @@ namespace glm
/// Extracts the (X * Y * Z) Euler angles from the rotation matrix M
/// @see gtx_euler_angles
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 & t2,
T & t3);

View File

@ -323,7 +323,7 @@ namespace glm
}
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 & t2,
T & t3)

View File

@ -49,7 +49,7 @@ namespace glm
typename genType::value_type a = glm::dot(e1, p);
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
if(a < Epsilon)
if(a < Epsilon && a > -Epsilon)
return false;
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);
}
//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>
GLM_FUNC_QUALIFIER bool intersectLineTriangle
(

View File

@ -58,15 +58,15 @@ namespace glm
/// @addtogroup gtx_vector_angle
/// @{
//! Returns the absolute angle between two vectors
//! Returns the absolute angle between two vectors.
//! Parameters need to be normalized.
/// @see gtx_vector_angle extension
/// @see gtx_vector_angle extension.
template <typename vecType>
GLM_FUNC_DECL typename vecType::value_type angle(
vecType const & x,
vecType const & y);
//! Returns the oriented angle between two 2d vectors
//! Returns the oriented angle between two 2d vectors.
//! Parameters need to be normalized.
/// @see gtx_vector_angle extension.
template <typename T, precision P>

View File

@ -68,12 +68,15 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
##### Fixes:
- Fixed GTX_extended_min_max filename typo #386
- Fixed intersectRayTriangle to not do any unintentional backface culling
- Fixed frexp compilation error
#### [GLM 0.9.7.2](https://github.com/g-truc/glm/tree/0.9.7) - 2015-XX-XX
##### Fixes:
- Fixed GTC_round floorMultiple/ceilMultiple #412
- Fixed GTC_packing unpackUnorm3x10_1x2 #414
- Fixed GTC_matrix_inverse affineInverse #192
- Fixed Cygwin build errors when using C++11 #405
#### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/tag/0.9.7.1) - 2015-09-07
##### Improvements:

View File

@ -1153,6 +1153,48 @@ namespace sign
}
}//namespace sign
namespace frexp_
{
int test()
{
int Error(0);
{
glm::vec1 x(1024);
glm::ivec1 exp;
glm::vec1 A = glm::frexp(x, exp);
Error += glm::all(glm::epsilonEqual(A, glm::vec1(0.5), 0.00001f)) ? 0 : 1;
Error += glm::all(glm::equal(exp, glm::ivec1(11))) ? 0 : 1;
}
{
glm::vec2 x(1024, 0.24);
glm::ivec2 exp;
glm::vec2 A = glm::frexp(x, exp);
Error += glm::all(glm::epsilonEqual(A, glm::vec2(0.5, 0.96), 0.00001f)) ? 0 : 1;
Error += glm::all(glm::equal(exp, glm::ivec2(11, -2))) ? 0 : 1;
}
{
glm::vec3 x(1024, 0.24, 0);
glm::ivec3 exp;
glm::vec3 A = glm::frexp(x, exp);
Error += glm::all(glm::epsilonEqual(A, glm::vec3(0.5, 0.96, 0.0), 0.00001f)) ? 0 : 1;
Error += glm::all(glm::equal(exp, glm::ivec3(11, -2, 0))) ? 0 : 1;
}
{
glm::vec4 x(1024, 0.24, 0, -1.33);
glm::ivec4 exp;
glm::vec4 A = glm::frexp(x, exp);
Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.5, 0.96, 0.0, -0.665), 0.00001f)) ? 0 : 1;
Error += glm::all(glm::equal(exp, glm::ivec4(11, -2, 0, 1))) ? 0 : 1;
}
return Error;
}
}//namespace frexp_
int main()
{
int Error(0);
@ -1171,6 +1213,7 @@ int main()
Error += roundEven::test();
Error += isnan_::test();
Error += isinf_::test();
Error += frexp_::test();
# ifdef NDEBUG
std::size_t Samples = 1000;

View File

@ -63,10 +63,10 @@ int test_log2()
Error += glm::abs(double(A) - B) <= 24 ? 0 : 1;
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;
}