Merge branch '0.9.3' of github.com:Groovounet/glm into 0.9.3

This commit is contained in:
Christophe Riccio 2012-05-08 20:58:01 +01:00
commit ff3ad788df
8 changed files with 105 additions and 136 deletions

View File

@ -804,20 +804,21 @@ namespace detail
}
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::bool_type isnan
(
genType const & x
)
GLM_FUNC_QUALIFIER bool isnan(genType const & x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'mix' only accept floating-point inputs");
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'isnan' only accept floating-point inputs");
#if(GLM_COMPILER & GLM_COMPILER_VC)
return typename genType::bool_type(_isnan(x));
#elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return typename genType::bool_type(::isnanf(x));
#else
return typename genType::bool_type(std::isnan(x));
#endif
# if(GLM_COMPILER & GLM_COMPILER_VC)
return _isnan(x);
# elif(GLM_COMPILER & GLM_COMPILER_GCC)
# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return _isnan(x) != 0;
# else
return std::isnan(x) != 0;
# endif
# else
return std::isnan(x) != 0;
# endif
}
template <typename T>
@ -857,20 +858,22 @@ namespace detail
}
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::bool_type isinf
(
genType const & x
)
GLM_FUNC_QUALIFIER bool isinf(
genType const & x)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'isinf' only accept floating-point inputs");
#if(GLM_COMPILER & GLM_COMPILER_VC)
return typename genType::bool_type(_fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF);
#elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return typename genType::bool_type(::__isinf(x));
#else
return typename genType::bool_type(std::isinf(x));
#endif
# if(GLM_COMPILER & GLM_COMPILER_VC)
return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF;
# elif(GLM_COMPILER & GLM_COMPILER_GCC)
# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return _isinf(x) != 0;
# else
return std::isinf(x) != 0;
# endif
# else
return std::isinf(x) != 0;
# endif
}
template <typename T>

View File

@ -58,7 +58,7 @@
# define GLM_PLATFORM GLM_PLATFORM_WINDOWS
#elif defined(__native_client__)
# define GLM_PLATFORM GLM_PLATFORM_CHROME_NACL
#elif defined(ANDROID)
#elif defined(__ANDROID__)
# define GLM_PLATFORM GLM_PLATFORM_ANDROID
#elif defined(__linux)
# define GLM_PLATFORM GLM_PLATFORM_LINUX

View File

@ -87,16 +87,6 @@ namespace glm
template <typename valType> detail::tvec3<bool> isfinite(const detail::tvec3<valType>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template <typename valType> detail::tvec4<bool> isfinite(const detail::tvec4<valType>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template <typename genType> bool isinf(genType const & x); //!< \brief Determines whether the given floating-point value is infinite. (From GLM_GTX_compatibility extension)
template <typename genType> detail::tvec2<bool> isinf(const detail::tvec2<genType>& x); //!< \brief Determines whether the given floating-point value is infinite. (From GLM_GTX_compatibility extension)
template <typename genType> detail::tvec3<bool> isinf(const detail::tvec3<genType>& x); //!< \brief Determines whether the given floating-point value is infinite. (From GLM_GTX_compatibility extension)
template <typename genType> detail::tvec4<bool> isinf(const detail::tvec4<genType>& x); //!< \brief Determines whether the given floating-point value is infinite. (From GLM_GTX_compatibility extension)
template <typename genType> bool isnan(genType const & x); //!< \brief Checks given floating-point value for not a number (NAN) (From GLM_GTX_compatibility extension)
template <typename genType> detail::tvec2<bool> isnan(const detail::tvec2<genType>& x); //!< \brief Checks given floating-point value for not a number (NAN) (From GLM_GTX_compatibility extension)
template <typename genType> detail::tvec3<bool> isnan(const detail::tvec3<genType>& x); //!< \brief Checks given floating-point value for not a number (NAN) (From GLM_GTX_compatibility extension)
template <typename genType> detail::tvec4<bool> isnan(const detail::tvec4<genType>& x); //!< \brief Checks given floating-point value for not a number (NAN) (From GLM_GTX_compatibility extension)
typedef bool bool1; //!< \brief boolean type with 1 component. (From GLM_GTX_compatibility extension)
typedef detail::tvec2<bool> bool2; //!< \brief boolean type with 2 components. (From GLM_GTX_compatibility extension)
typedef detail::tvec3<bool> bool3; //!< \brief boolean type with 3 components. (From GLM_GTX_compatibility extension)

View File

@ -58,98 +58,4 @@ namespace glm
isfinite(x.w));
}
// isinf
template <typename genType>
GLM_FUNC_QUALIFIER bool isinf(
genType const & x)
{
# if(GLM_COMPILER & GLM_COMPILER_VC)
return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF;
# elif(GLM_COMPILER & GLM_COMPILER_GCC)
# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return _isinf(x) != 0;
# else
return std::isinf(x) != 0;
# endif
# else
return std::isinf(x) != 0;
# endif
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> isinf(
detail::tvec2<valType> const & x)
{
return detail::tvec2<bool>(
isinf(x.x),
isinf(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> isinf(
detail::tvec3<valType> const & x)
{
return detail::tvec3<bool>(
isinf(x.x),
isinf(x.y),
isinf(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> isinf(
detail::tvec4<valType> const & x)
{
return detail::tvec4<bool>(
isinf(x.x),
isinf(x.y),
isinf(x.z),
isinf(x.w));
}
// isnan
template <typename genType>
GLM_FUNC_QUALIFIER bool isnan(genType const & x)
{
# if(GLM_COMPILER & GLM_COMPILER_VC)
return _isnan(x);
# elif(GLM_COMPILER & GLM_COMPILER_GCC)
# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return _isnan(x) != 0;
# else
return std::isnan(x) != 0;
# endif
# else
return std::isnan(x) != 0;
# endif
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> isnan(
detail::tvec2<valType> const & x)
{
return detail::tvec2<bool>(
isnan(x.x),
isnan(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> isnan(
detail::tvec3<valType> const & x)
{
return detail::tvec3<bool>(
isnan(x.x),
isnan(x.y),
isnan(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> isnan(
detail::tvec4<valType> const & x)
{
return detail::tvec4<bool>(
isnan(x.x),
isnan(x.y),
isnan(x.z),
isnan(x.w));
}
}//namespace glm

View File

@ -47,7 +47,8 @@
# pragma message("GLM: GLM_VIRTREV_xstream extension included")
#endif
namespace glm
namespace glm{
namespace detail
{
template<typename T>
std::ostream & operator << (std::ostream & stream, glm::detail::tvec2<T> const & vec)
@ -159,6 +160,7 @@ namespace glm
return stream;
}
}//namespace detail
}//namespace glm
#endif//GLM_VIRTREV_xstream

View File

@ -352,6 +352,62 @@ int test_roundEven()
return Error;
}
int test_isnan()
{
int Error = 0;
float Zero_f = 0.0;
double Zero_d = 0.0;
{
Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::dvec2(0.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::dvec3(0.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::dvec4(0.0f/Zero_f))) ? 0 : 1;
}
{
Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1;
}
return Error;
}
int test_isinf()
{
int Error = 0;
float Zero_f = 0.0;
double Zero_d = 0.0;
{
Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1;
Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1;
}
{
Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1;
Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1;
}
return Error;
}
int main()
{
int Error(0);
@ -362,6 +418,8 @@ int main()
Error += test_mix();
Error += test_round();
Error += test_roundEven();
Error += test_isnan();
Error += test_isinf();
return Error;
}

View File

@ -7,11 +7,21 @@
// File : test/core/core_func_swizzle.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_ONLY_XYZW
//#define GLM_FORCE_PURE
#define GLM_MESSAGES
#define GLM_SWIZZLE
#define GLM_FORCE_CXX98
#ifndef GLM_FORCE_ONLY_XYZW
# define GLM_FORCE_ONLY_XYZW
#endif
//#ifndef GLM_FORCE_PURE
//# define GLM_FORCE_PURE
//#endif
#ifndef GLM_MESSAGES
# define GLM_MESSAGES
#endif
#ifndef GLM_SWIZZLE
# define GLM_SWIZZLE
#endif
#ifndef GLM_FORCE_CXX98
# define GLM_FORCE_CXX98
#endif
#include <glm/glm.hpp>
int test_vec2_swizzle()

View File

@ -53,8 +53,8 @@ int test_nlz()
{
int Error = 0;
for(std::size_t i = 1; i < 33; ++i)
Error += glm::nlz(i) == 31u - glm::findMSB(i) ? 0 : 1;
for(glm::uint i = 1; i < glm::uint(33); ++i)
Error += glm::nlz(i) == glm::uint(31u) - glm::findMSB(i) ? 0 : 1;
//printf("%d, %d\n", glm::nlz(i), 31u - glm::findMSB(i));
return Error;