type_vec4.hpp
Go to the documentation of this file.
1 
29 #pragma once
30 
31 //#include "../fwd.hpp"
32 #include "setup.hpp"
33 #include "type_vec.hpp"
34 #ifdef GLM_SWIZZLE
35 # if GLM_HAS_ANONYMOUS_UNION
36 # include "_swizzle.hpp"
37 # else
38 # include "_swizzle_func.hpp"
39 # endif
40 #endif //GLM_SWIZZLE
41 #include <cstddef>
42 
43 namespace glm{
44 namespace detail
45 {
46  template <typename T>
47  struct simd
48  {
49  typedef T type[4];
50  };
51 
52 # if(GLM_ARCH & GLM_ARCH_SSE2)
53  template <>
54  struct simd<float>
55  {
56  typedef __m128 type;
57  };
58 # endif
59 
60 # if(GLM_ARCH & GLM_ARCH_AVX)
61  template <>
62  struct simd<double>
63  {
64  typedef __m256d type;
65  };
66 # endif
67 
68  template <typename T, precision P>
69  struct tvec4
70  {
72  // Implementation detail
73 
74  enum ctor{_null};
75 
76  typedef tvec4<T, P> type;
78  typedef T value_type;
79  typedef int size_type;
80 
82  // Helper
83 
85 
87  // Data
88 
89 # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
90  union
91  {
92  typename simd<T>::type data;
93  struct { T r, g, b, a; };
94  struct { T s, t, p, q; };
95  struct { T x, y, z, w;};
96 
97  _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w)
98  _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, r, g, b, a)
99  _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, s, t, p, q)
100  _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, x, y, z, w)
101  _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, r, g, b, a)
102  _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, s, t, p, q)
103  _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, x, y, z, w)
104  _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, r, g, b, a)
105  _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, s, t, p, q)
106  };
107 # else
108 # if(GLM_HAS_UNRESTRICTED_UNIONS)
109  union
110  {
111  typename simd<T>::type data;
112  struct
113  {
114  union { T x, r, s; };
115  union { T y, g, t; };
116  union { T z, b, p; };
117  union { T w, a, q; };
118  };
119  };
120 # else
121  union { T x, r, s; };
122  union { T y, g, t; };
123  union { T z, b, p; };
124  union { T w, a, q; };
125 # endif
126 
127 # ifdef GLM_SWIZZLE
129 # endif
130 # endif//GLM_LANG
131 
133  // Accesses
134 
135  GLM_FUNC_DECL T & operator[](length_t i);
136  GLM_FUNC_DECL T const & operator[](length_t i) const;
137 
139  // Implicit basic constructors
140 
141  GLM_FUNC_DECL tvec4();
142  GLM_FUNC_DECL tvec4(type const & v);
143  template <precision Q>
144  GLM_FUNC_DECL tvec4(tvec4<T, Q> const & v);
145 
147  // Explicit basic constructors
148 
149  GLM_FUNC_DECL explicit tvec4(
150  ctor);
151  GLM_FUNC_DECL explicit tvec4(
152  T const & s);
153  GLM_FUNC_DECL tvec4(
154  T const & s0,
155  T const & s1,
156  T const & s2,
157  T const & s3);
158 
160  // Conversion scalar constructors
161 
163  template <typename A, typename B, typename C, typename D>
164  GLM_FUNC_DECL tvec4(
165  A const & x,
166  B const & y,
167  C const & z,
168  D const & w);
169 
171  // Conversion vector constructors
172 
174  template <typename A, typename B, typename C, precision Q>
175  GLM_FUNC_DECL explicit tvec4(tvec2<A, Q> const & v, B const & s1, C const & s2);
177  template <typename A, typename B, typename C, precision Q>
178  GLM_FUNC_DECL explicit tvec4(A const & s1, tvec2<B, Q> const & v, C const & s2);
180  template <typename A, typename B, typename C, precision Q>
181  GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tvec2<C, Q> const & v);
183  template <typename A, typename B, precision Q>
184  GLM_FUNC_DECL explicit tvec4(tvec3<A, Q> const & v, B const & s);
186  template <typename A, typename B, precision Q>
187  GLM_FUNC_DECL explicit tvec4(A const & s, tvec3<B, Q> const & v);
189  template <typename A, typename B, precision Q>
190  GLM_FUNC_DECL explicit tvec4(tvec2<A, Q> const & v1, tvec2<B, Q> const & v2);
192  template <typename U, precision Q>
193  GLM_FUNC_DECL explicit tvec4(tvec4<U, Q> const & v);
194 
196  // Swizzle constructors
197 
198 # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
199  template <int E0, int E1, int E2, int E3>
200  GLM_FUNC_DECL tvec4(_swizzle<4, T, P, tvec4<T, P>, E0, E1, E2, E3> const & that)
201  {
202  *this = that();
203  }
204 
205  template <int E0, int E1, int F0, int F1>
206  GLM_FUNC_DECL tvec4(_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, _swizzle<2, T, P, tvec2<T, P>, F0, F1, -1, -2> const & u)
207  {
208  *this = tvec4<T, P>(v(), u());
209  }
210 
211  template <int E0, int E1>
212  GLM_FUNC_DECL tvec4(T const & x, T const & y, _swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v)
213  {
214  *this = tvec4<T, P>(x, y, v());
215  }
216 
217  template <int E0, int E1>
218  GLM_FUNC_DECL tvec4(T const & x, _swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, T const & w)
219  {
220  *this = tvec4<T, P>(x, v(), w);
221  }
222 
223  template <int E0, int E1>
224  GLM_FUNC_DECL tvec4(_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, T const & z, T const & w)
225  {
226  *this = tvec4<T, P>(v(), z, w);
227  }
228 
229  template <int E0, int E1, int E2>
230  GLM_FUNC_DECL tvec4(_swizzle<3, T, P, tvec3<T, P>, E0, E1, E2, -1> const & v, T const & w)
231  {
232  *this = tvec4<T, P>(v(), w);
233  }
234 
235  template <int E0, int E1, int E2>
236  GLM_FUNC_DECL tvec4(T const & x, _swizzle<3, T, P, tvec3<T, P>, E0, E1, E2, -1> const & v)
237  {
238  *this = tvec4<T, P>(x, v());
239  }
240 # endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
241 
243  // Unary arithmetic operators
244 
245  GLM_FUNC_DECL tvec4<T, P> & operator= (tvec4<T, P> const & v);
246 
247  GLM_FUNC_DECL tvec4<T, P> & operator+=(T v);
248  GLM_FUNC_DECL tvec4<T, P> & operator+=(tvec4<T, P> const & v);
249  GLM_FUNC_DECL tvec4<T, P> & operator-=(T v);
250  GLM_FUNC_DECL tvec4<T, P> & operator-=(tvec4<T, P> const & v);
251  GLM_FUNC_DECL tvec4<T, P> & operator*=(T v);
252  GLM_FUNC_DECL tvec4<T, P> & operator*=(tvec4<T, P> const & v);
253  GLM_FUNC_DECL tvec4<T, P> & operator/=(T v);
254  GLM_FUNC_DECL tvec4<T, P> & operator/=(tvec4<T, P> const & v);
255 
256  template <typename U, precision Q>
257  GLM_FUNC_DECL tvec4<T, P> & operator= (tvec4<U, Q> const & v);
258  template <typename U>
259  GLM_FUNC_DECL tvec4<T, P> & operator+=(U s);
260  template <typename U>
261  GLM_FUNC_DECL tvec4<T, P> & operator+=(tvec4<U, P> const & v);
262  template <typename U>
263  GLM_FUNC_DECL tvec4<T, P> & operator-=(U s);
264  template <typename U>
265  GLM_FUNC_DECL tvec4<T, P> & operator-=(tvec4<U, P> const & v);
266  template <typename U>
267  GLM_FUNC_DECL tvec4<T, P> & operator*=(U s);
268  template <typename U>
269  GLM_FUNC_DECL tvec4<T, P> & operator*=(tvec4<U, P> const & v);
270  template <typename U>
271  GLM_FUNC_DECL tvec4<T, P> & operator/=(U s);
272  template <typename U>
273  GLM_FUNC_DECL tvec4<T, P> & operator/=(tvec4<U, P> const & v);
274 
276  // Increment and decrement operators
277 
278  GLM_FUNC_DECL tvec4<T, P> & operator++();
279  GLM_FUNC_DECL tvec4<T, P> & operator--();
280  GLM_FUNC_DECL tvec4<T, P> operator++(int);
281  GLM_FUNC_DECL tvec4<T, P> operator--(int);
282 
284  // Unary bit operators
285 
286  template <typename U>
287  GLM_FUNC_DECL tvec4<T, P> & operator%= (U s);
288  template <typename U>
289  GLM_FUNC_DECL tvec4<T, P> & operator%= (tvec4<U, P> const & v);
290  template <typename U>
291  GLM_FUNC_DECL tvec4<T, P> & operator&= (U s);
292  template <typename U>
293  GLM_FUNC_DECL tvec4<T, P> & operator&= (tvec4<U, P> const & v);
294  template <typename U>
295  GLM_FUNC_DECL tvec4<T, P> & operator|= (U s);
296  template <typename U>
297  GLM_FUNC_DECL tvec4<T, P> & operator|= (tvec4<U, P> const & v);
298  template <typename U>
299  GLM_FUNC_DECL tvec4<T, P> & operator^= (U s);
300  template <typename U>
301  GLM_FUNC_DECL tvec4<T, P> & operator^= (tvec4<U, P> const & v);
302  template <typename U>
303  GLM_FUNC_DECL tvec4<T, P> & operator<<=(U s);
304  template <typename U>
305  GLM_FUNC_DECL tvec4<T, P> & operator<<=(tvec4<U, P> const & v);
306  template <typename U>
307  GLM_FUNC_DECL tvec4<T, P> & operator>>=(U s);
308  template <typename U>
309  GLM_FUNC_DECL tvec4<T, P> & operator>>=(tvec4<U, P> const & v);
310  };
311 
312  template <typename T, precision P>
313  GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v, T const & s);
314 
315  template <typename T, precision P>
316  GLM_FUNC_DECL tvec4<T, P> operator+(T const & s, tvec4<T, P> const & v);
317 
318  template <typename T, precision P>
320 
321  template <typename T, precision P>
322  GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v, T const & s);
323 
324  template <typename T, precision P>
325  GLM_FUNC_DECL tvec4<T, P> operator-(T const & s, tvec4<T, P> const & v);
326 
327  template <typename T, precision P>
329 
330  template <typename T, precision P>
331  GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, T const & s);
332 
333  template <typename T, precision P>
334  GLM_FUNC_DECL tvec4<T, P> operator*(T const & s, tvec4<T, P> const & v);
335 
336  template <typename T, precision P>
338 
339  template <typename T, precision P>
340  GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v, T const & s);
341 
342  template <typename T, precision P>
343  GLM_FUNC_DECL tvec4<T, P> operator/(T const & s, tvec4<T, P> const & v);
344 
345  template <typename T, precision P>
347 
348  template <typename T, precision P>
350 
351  template <typename T, precision P>
352  GLM_FUNC_DECL bool operator==(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
353 
354  template <typename T, precision P>
355  GLM_FUNC_DECL bool operator!=(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
356 
357  template <typename T, precision P>
358  GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v, T const & s);
359 
360  template <typename T, precision P>
361  GLM_FUNC_DECL tvec4<T, P> operator%(T const & s, tvec4<T, P> const & v);
362 
363  template <typename T, precision P>
365 
366  template <typename T, precision P>
367  GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v, T const & s);
368 
369  template <typename T, precision P>
370  GLM_FUNC_DECL tvec4<T, P> operator&(T const & s, tvec4<T, P> const & v);
371 
372  template <typename T, precision P>
374 
375  template <typename T, precision P>
376  GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v, T const & s);
377 
378  template <typename T, precision P>
379  GLM_FUNC_DECL tvec4<T, P> operator|(T const & s, tvec4<T, P> const & v);
380 
381  template <typename T, precision P>
383 
384  template <typename T, precision P>
385  GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v, T const & s);
386 
387  template <typename T, precision P>
388  GLM_FUNC_DECL tvec4<T, P> operator^(T const & s, tvec4<T, P> const & v);
389 
390  template <typename T, precision P>
392 
393  template <typename T, precision P>
394  GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v, T const & s);
395 
396  template <typename T, precision P>
397  GLM_FUNC_DECL tvec4<T, P> operator<<(T const & s, tvec4<T, P> const & v);
398 
399  template <typename T, precision P>
400  GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
401 
402  template <typename T, precision P>
403  GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v, T const & s);
404 
405  template <typename T, precision P>
406  GLM_FUNC_DECL tvec4<T, P> operator>>(T const & s, tvec4<T, P> const & v);
407 
408  template <typename T, precision P>
410 
411  template <typename T, precision P>
413 
414 }//namespace detail
415 }//namespace glm
416 
417 #ifndef GLM_EXTERNAL_TEMPLATE
418 #include "type_vec4.inl"
419 #endif//GLM_EXTERNAL_TEMPLATE
GLM_FUNC_DECL tvec1< T, P > operator^(tvec1< T, P > const &v, T const &s)
GLM_FUNC_DECL tvec1< T, P > operator&(tvec1< T, P > const &v, T const &s)
tvec4< T, P > type
Definition: type_vec4.hpp:76
#define _GLM_SWIZZLE4_4_MEMBERS(T, P, V, E0, E1, E2, E3)
Definition: _swizzle.hpp:581
int length_t
Definition: setup.hpp:755
#define _GLM_SWIZZLE4_2_MEMBERS(T, P, V, E0, E1, E2, E3)
Definition: _swizzle.hpp:497
GLM_FUNC_DECL tvec1< T, P > operator|(tvec1< T, P > const &v, T const &s)
GLM_FUNC_DECL tvec1< T, P > operator~(tvec1< T, P > const &v)
GLM_FUNC_DECL tmat2x2< T, P > operator*(tmat2x2< T, P > const &m, T const &s)
GLM_FUNC_DECL tmat2x2< T, P > operator+(tmat2x2< T, P > const &m, T const &s)
GLM_FUNC_DECL tmat2x2< T, P > operator/(tmat2x2< T, P > const &m, T const &s)
#define _GLM_SWIZZLE4_3_MEMBERS(T, P, V, E0, E1, E2, E3)
Definition: _swizzle.hpp:515
GLM_FUNC_DECL bool operator==(tvec1< T, P > const &v1, tvec1< T, P > const &v2)
GLM_FUNC_DECL tmat2x2< T, P > operator-(tmat2x2< T, P > const &m, T const &s)
GLM_FUNC_DECL tvec1< T, P > operator%(tvec1< T, P > const &v, T const &s)
GLM_FUNC_DECL bool operator!=(tvec1< T, P > const &v1, tvec1< T, P > const &v2)
tvec4< bool, P > bool_type
Definition: type_vec4.hpp:77
GLM_FUNC_DECL genType::value_type length(genType const &x)
GLM_FUNC_DECL tvec1< T, P > operator>>(tvec1< T, P > const &v, T const &s)
#define GLM_CONSTEXPR
Definition: setup.hpp:801
#define GLM_SWIZZLE_GEN_VEC_FROM_VEC4(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE)
#define GLM_FUNC_DECL
Definition: setup.hpp:728


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:43:40