You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
4.1 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  5. /// Permission is hereby granted, free of charge, to any person obtaining a copy
  6. /// of this software and associated documentation files (the "Software"), to deal
  7. /// in the Software without restriction, including without limitation the rights
  8. /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. /// copies of the Software, and to permit persons to whom the Software is
  10. /// furnished to do so, subject to the following conditions:
  11. ///
  12. /// The above copyright notice and this permission notice shall be included in
  13. /// all copies or substantial portions of the Software.
  14. ///
  15. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. /// THE SOFTWARE.
  22. ///
  23. /// @ref core
  24. /// @file glm/core/_vectorize.hpp
  25. /// @date 2011-10-14 / 2011-10-14
  26. /// @author Christophe Riccio
  27. ///////////////////////////////////////////////////////////////////////////////////
  28. #define VECTORIZE2_VEC(func) \
  29. template <typename T> \
  30. GLM_FUNC_QUALIFIER detail::tvec2<T> func( \
  31. detail::tvec2<T> const & v) \
  32. { \
  33. return detail::tvec2<T>( \
  34. func(v.x), \
  35. func(v.y)); \
  36. }
  37. #define VECTORIZE3_VEC(func) \
  38. template <typename T> \
  39. GLM_FUNC_QUALIFIER detail::tvec3<T> func( \
  40. detail::tvec3<T> const & v) \
  41. { \
  42. return detail::tvec3<T>( \
  43. func(v.x), \
  44. func(v.y), \
  45. func(v.z)); \
  46. }
  47. #define VECTORIZE4_VEC(func) \
  48. template <typename T> \
  49. GLM_FUNC_QUALIFIER detail::tvec4<T> func( \
  50. detail::tvec4<T> const & v) \
  51. { \
  52. return detail::tvec4<T>( \
  53. func(v.x), \
  54. func(v.y), \
  55. func(v.z), \
  56. func(v.w)); \
  57. }
  58. #define VECTORIZE_VEC(func) \
  59. VECTORIZE2_VEC(func) \
  60. VECTORIZE3_VEC(func) \
  61. VECTORIZE4_VEC(func)
  62. #define VECTORIZE2_VEC_SCA(func) \
  63. template <typename T> \
  64. GLM_FUNC_QUALIFIER detail::tvec2<T> func \
  65. ( \
  66. detail::tvec2<T> const & x, \
  67. typename detail::tvec2<T>::value_type const & y \
  68. ) \
  69. { \
  70. return detail::tvec2<T>( \
  71. func(x.x, y), \
  72. func(x.y, y)); \
  73. }
  74. #define VECTORIZE3_VEC_SCA(func) \
  75. template <typename T> \
  76. GLM_FUNC_QUALIFIER detail::tvec3<T> func \
  77. ( \
  78. detail::tvec3<T> const & x, \
  79. typename detail::tvec3<T>::value_type const & y \
  80. ) \
  81. { \
  82. return detail::tvec3<T>( \
  83. func(x.x, y), \
  84. func(x.y, y), \
  85. func(x.z, y)); \
  86. }
  87. #define VECTORIZE4_VEC_SCA(func) \
  88. template <typename T> \
  89. GLM_FUNC_QUALIFIER detail::tvec4<T> func \
  90. ( \
  91. detail::tvec4<T> const & x, \
  92. typename detail::tvec4<T>::value_type const & y \
  93. ) \
  94. { \
  95. return detail::tvec4<T>( \
  96. func(x.x, y), \
  97. func(x.y, y), \
  98. func(x.z, y), \
  99. func(x.w, y)); \
  100. }
  101. #define VECTORIZE_VEC_SCA(func) \
  102. VECTORIZE2_VEC_SCA(func) \
  103. VECTORIZE3_VEC_SCA(func) \
  104. VECTORIZE4_VEC_SCA(func)
  105. #define VECTORIZE2_VEC_VEC(func) \
  106. template <typename T> \
  107. GLM_FUNC_QUALIFIER detail::tvec2<T> func \
  108. ( \
  109. detail::tvec2<T> const & x, \
  110. detail::tvec2<T> const & y \
  111. ) \
  112. { \
  113. return detail::tvec2<T>( \
  114. func(x.x, y.x), \
  115. func(x.y, y.y)); \
  116. }
  117. #define VECTORIZE3_VEC_VEC(func) \
  118. template <typename T> \
  119. GLM_FUNC_QUALIFIER detail::tvec3<T> func \
  120. ( \
  121. detail::tvec3<T> const & x, \
  122. detail::tvec3<T> const & y \
  123. ) \
  124. { \
  125. return detail::tvec3<T>( \
  126. func(x.x, y.x), \
  127. func(x.y, y.y), \
  128. func(x.z, y.z)); \
  129. }
  130. #define VECTORIZE4_VEC_VEC(func) \
  131. template <typename T> \
  132. GLM_FUNC_QUALIFIER detail::tvec4<T> func \
  133. ( \
  134. detail::tvec4<T> const & x, \
  135. detail::tvec4<T> const & y \
  136. ) \
  137. { \
  138. return detail::tvec4<T>( \
  139. func(x.x, y.x), \
  140. func(x.y, y.y), \
  141. func(x.z, y.z), \
  142. func(x.w, y.w)); \
  143. }
  144. #define VECTORIZE_VEC_VEC(func) \
  145. VECTORIZE2_VEC_VEC(func) \
  146. VECTORIZE3_VEC_VEC(func) \
  147. VECTORIZE4_VEC_VEC(func)