9
3

compatibility.inl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include <limits>
  2. namespace glm
  3. {
  4. // isfinite
  5. template<typename genType>
  6. GLM_FUNC_QUALIFIER bool isfinite(
  7. genType const& x)
  8. {
  9. # if GLM_HAS_CXX11_STL
  10. return std::isfinite(x) != 0;
  11. # elif GLM_COMPILER & GLM_COMPILER_VC
  12. return _finite(x) != 0;
  13. # elif GLM_COMPILER & GLM_COMPILER_GCC && GLM_PLATFORM & GLM_PLATFORM_ANDROID
  14. return _isfinite(x) != 0;
  15. # else
  16. if (std::numeric_limits<genType>::is_integer || std::denorm_absent == std::numeric_limits<genType>::has_denorm)
  17. return std::numeric_limits<genType>::min() <= x && std::numeric_limits<genType>::max() >= x;
  18. else
  19. return -std::numeric_limits<genType>::max() <= x && std::numeric_limits<genType>::max() >= x;
  20. # endif
  21. }
  22. template<typename T, qualifier Q>
  23. GLM_FUNC_QUALIFIER vec<1, bool, Q> isfinite(
  24. vec<1, T, Q> const& x)
  25. {
  26. return vec<1, bool, Q>(
  27. isfinite(x.x));
  28. }
  29. template<typename T, qualifier Q>
  30. GLM_FUNC_QUALIFIER vec<2, bool, Q> isfinite(
  31. vec<2, T, Q> const& x)
  32. {
  33. return vec<2, bool, Q>(
  34. isfinite(x.x),
  35. isfinite(x.y));
  36. }
  37. template<typename T, qualifier Q>
  38. GLM_FUNC_QUALIFIER vec<3, bool, Q> isfinite(
  39. vec<3, T, Q> const& x)
  40. {
  41. return vec<3, bool, Q>(
  42. isfinite(x.x),
  43. isfinite(x.y),
  44. isfinite(x.z));
  45. }
  46. template<typename T, qualifier Q>
  47. GLM_FUNC_QUALIFIER vec<4, bool, Q> isfinite(
  48. vec<4, T, Q> const& x)
  49. {
  50. return vec<4, bool, Q>(
  51. isfinite(x.x),
  52. isfinite(x.y),
  53. isfinite(x.z),
  54. isfinite(x.w));
  55. }
  56. }//namespace glm