func_vector_relational.inl 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. namespace glm
  2. {
  3. template<length_t L, typename T, qualifier Q>
  4. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> lessThan(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
  5. {
  6. vec<L, bool, Q> Result(true);
  7. for(length_t i = 0; i < L; ++i)
  8. Result[i] = x[i] < y[i];
  9. return Result;
  10. }
  11. template<length_t L, typename T, qualifier Q>
  12. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> lessThanEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
  13. {
  14. vec<L, bool, Q> Result(true);
  15. for(length_t i = 0; i < L; ++i)
  16. Result[i] = x[i] <= y[i];
  17. return Result;
  18. }
  19. template<length_t L, typename T, qualifier Q>
  20. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> greaterThan(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
  21. {
  22. vec<L, bool, Q> Result(true);
  23. for(length_t i = 0; i < L; ++i)
  24. Result[i] = x[i] > y[i];
  25. return Result;
  26. }
  27. template<length_t L, typename T, qualifier Q>
  28. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> greaterThanEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
  29. {
  30. vec<L, bool, Q> Result(true);
  31. for(length_t i = 0; i < L; ++i)
  32. Result[i] = x[i] >= y[i];
  33. return Result;
  34. }
  35. template<length_t L, typename T, qualifier Q>
  36. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> equal(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
  37. {
  38. vec<L, bool, Q> Result(true);
  39. for(length_t i = 0; i < L; ++i)
  40. Result[i] = x[i] == y[i];
  41. return Result;
  42. }
  43. template<length_t L, typename T, qualifier Q>
  44. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> notEqual(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
  45. {
  46. vec<L, bool, Q> Result(true);
  47. for(length_t i = 0; i < L; ++i)
  48. Result[i] = x[i] != y[i];
  49. return Result;
  50. }
  51. template<length_t L, qualifier Q>
  52. GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool any(vec<L, bool, Q> const& v)
  53. {
  54. bool Result = false;
  55. for(length_t i = 0; i < L; ++i)
  56. Result = Result || v[i];
  57. return Result;
  58. }
  59. template<length_t L, qualifier Q>
  60. GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool all(vec<L, bool, Q> const& v)
  61. {
  62. bool Result = true;
  63. for(length_t i = 0; i < L; ++i)
  64. Result = Result && v[i];
  65. return Result;
  66. }
  67. template<length_t L, qualifier Q>
  68. GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<L, bool, Q> not_(vec<L, bool, Q> const& v)
  69. {
  70. vec<L, bool, Q> Result(true);
  71. for(length_t i = 0; i < L; ++i)
  72. Result[i] = !v[i];
  73. return Result;
  74. }
  75. }//namespace glm
  76. #if GLM_CONFIG_SIMD == GLM_ENABLE
  77. # include "func_vector_relational_simd.inl"
  78. #endif