Flow Visualisation
type_vec3.hpp
Go to the documentation of this file.
1 
29 #ifndef glm_core_type_gentype3
30 #define glm_core_type_gentype3
31 
32 #include "type_vec.hpp"
33 #include "type_float.hpp"
34 #include "type_int.hpp"
35 #include "type_size.hpp"
36 #include "_swizzle.hpp"
37 
38 namespace glm{
39 namespace detail
40 {
41  template <typename T> struct tref2;
42  template <typename T> struct tref3;
43  template <typename T> struct tref4;
44  template <typename T> struct tvec2;
45  template <typename T> struct tvec4;
46 
47  template <typename T>
48  struct tvec3
49  {
50  enum ctor{null};
51 
52  typedef T value_type;
53  typedef std::size_t size_type;
54  typedef tvec3<T> type;
56 
57  GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
58 
60  // Data
61 
62 # if(GLM_COMPONENT == GLM_COMPONENT_CXX11)
63  union
64  {
65 # if(defined(GLM_SWIZZLE))
67  _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g, b)
68  _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t, p)
69  _GLM_SWIZZLE3_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y, z)
70  _GLM_SWIZZLE3_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g, b)
71  _GLM_SWIZZLE3_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t, p)
72  _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y, z)
73  _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g, b)
74  _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t, p)
75 # endif//(defined(GLM_SWIZZLE))
76 
77  struct{value_type r, g, b;};
78  struct{value_type s, t, p;};
79  struct{value_type x, y, z;};
80  };
81 # elif(GLM_COMPONENT == GLM_COMPONENT_CXX98)
82  union {value_type x, r, s;};
83  union {value_type y, g, t;};
84  union {value_type z, b, p;};
85 
86 # if(defined(GLM_SWIZZLE))
87  // Defines all he swizzle operator as functions
88  GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, detail::tvec3, detail::tref2, detail::tref3)
89  GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4)
90 # endif//(defined(GLM_SWIZZLE))
91 # else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
92  value_type x, y, z;
93 
94 # if(defined(GLM_SWIZZLE))
95  // Defines all he swizzle operator as functions
97  GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4, x, y, z)
98 # endif//(defined(GLM_SWIZZLE))
99 # endif//GLM_COMPONENT
100 
102  // Accesses
103 
104  GLM_FUNC_DECL value_type & operator[](size_type i);
105  GLM_FUNC_DECL value_type const & operator[](size_type i) const;
106 
108  // Implicit basic constructors
109 
111  GLM_FUNC_DECL tvec3(tvec3<T> const & v);
112 
114  // Explicit basic constructors
115 
116  GLM_FUNC_DECL explicit tvec3(
117  ctor);
118  GLM_FUNC_DECL explicit tvec3(
119  value_type const & s);
120  GLM_FUNC_DECL explicit tvec3(
121  value_type const & s1,
122  value_type const & s2,
123  value_type const & s3);
124 
126  // Convertion scalar constructors
127 
129  template <typename U>
130  GLM_FUNC_DECL explicit tvec3(
131  U const & x);
133  template <typename U, typename V, typename W>
134  GLM_FUNC_DECL explicit tvec3(
135  U const & x,
136  V const & y,
137  W const & z);
138 
140  // Convertion vector constructors
141 
143  template <typename A, typename B>
144  GLM_FUNC_DECL explicit tvec3(tvec2<A> const & v, B const & s);
146  template <typename A, typename B>
147  GLM_FUNC_DECL explicit tvec3(A const & s, tvec2<B> const & v);
149  template <typename U>
150  GLM_FUNC_DECL explicit tvec3(tvec3<U> const & v);
152  template <typename U>
153  GLM_FUNC_DECL explicit tvec3(tvec4<U> const & v);
154 
156  // Swizzle constructors
157 
158  GLM_FUNC_DECL tvec3(tref3<T> const & r);
159 
160  template <typename A, typename B>
161  GLM_FUNC_DECL explicit tvec3(tref2<A> const & v, B const & s);
162 
163  template <typename A, typename B>
164  GLM_FUNC_DECL explicit tvec3(A const & s, tref2<B> const & v);
165 
166  template <int E0, int E1, int E2>
167  GLM_FUNC_DECL tvec3(glm::detail::swizzle<3, T, tvec3<T>, E0, E1, E2, -1> const & that)
168  {
169  *this = that();
170  }
171 
172  template <int E0, int E1>
173  GLM_FUNC_DECL tvec3(glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v, T const & s)
174  {
175  *this = tvec3<T>(v(), s);
176  }
177 
178  template <int E0, int E1>
179  GLM_FUNC_DECL tvec3(T const & s, glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v)
180  {
181  *this = tvec3<T>(s, v());
182  }
183 
185  // Unary arithmetic operators
186 
188  template <typename U>
190 
191  template <typename U>
192  GLM_FUNC_DECL tvec3<T> & operator+=(U const & s);
193  template <typename U>
195  template <typename U>
196  GLM_FUNC_DECL tvec3<T> & operator-=(U const & s);
197  template <typename U>
199  template <typename U>
200  GLM_FUNC_DECL tvec3<T> & operator*=(U const & s);
201  template <typename U>
203  template <typename U>
204  GLM_FUNC_DECL tvec3<T> & operator/=(U const & s);
205  template <typename U>
209 
211  // Unary bit operators
212 
213  template <typename U>
214  GLM_FUNC_DECL tvec3<T> & operator%= (U const & s);
215  template <typename U>
217  template <typename U>
218  GLM_FUNC_DECL tvec3<T> & operator&= (U const & s);
219  template <typename U>
221  template <typename U>
222  GLM_FUNC_DECL tvec3<T> & operator|= (U const & s);
223  template <typename U>
225  template <typename U>
226  GLM_FUNC_DECL tvec3<T> & operator^= (U const & s);
227  template <typename U>
229  template <typename U>
230  GLM_FUNC_DECL tvec3<T> & operator<<=(U const & s);
231  template <typename U>
232  GLM_FUNC_DECL tvec3<T> & operator<<=(tvec3<U> const & v);
233  template <typename U>
234  GLM_FUNC_DECL tvec3<T> & operator>>=(U const & s);
235  template <typename U>
237 
239  // Swizzle operators
240 
241  GLM_FUNC_DECL value_type swizzle(comp X) const;
247  };
248 
249  template <typename T>
250  struct tref3
251  {
252  GLM_FUNC_DECL tref3(T & x, T & y, T & z);
253  GLM_FUNC_DECL tref3(tref3<T> const & r);
254  GLM_FUNC_DECL explicit tref3(tvec3<T> const & v);
255 
256  GLM_FUNC_DECL tref3<T> & operator= (tref3<T> const & r);
257  GLM_FUNC_DECL tref3<T> & operator= (tvec3<T> const & v);
258 
259  GLM_FUNC_DECL tvec3<T> operator() ();
260 
261  T & x;
262  T & y;
263  T & z;
264  };
265 
266  GLM_DETAIL_IS_VECTOR(tvec3);
267 } //namespace detail
268 
271 
278 
285 
292 
299 
306 
313 
320 
327 
334 
336 }//namespace glm
337 
338 #ifndef GLM_EXTERNAL_TEMPLATE
339 #include "type_vec3.inl"
340 #endif//GLM_EXTERNAL_TEMPLATE
341 
342 #endif//glm_core_type_gentype3
detail::tvec3< mediump_int > mediump_ivec3
Definition: type_vec3.hpp:305
GLM_FUNC_DECL tvec3< T > & operator=(tvec3< T > const &v)
Definition: type_vec3.inl:233
GLM_FUNC_DECL tvec3< T > & operator++()
Definition: type_vec3.inl:361
GLM_FUNC_DECL tvec3< T > & operator+=(U const &s)
Definition: type_vec3.hpp:50
value_type z
Definition: type_vec3.hpp:92
T & z
Definition: type_vec3.hpp:263
value_type x
Definition: type_vec3.hpp:92
#define GLM_CONSTEXPR
Definition: _detail.hpp:479
Definition: _swizzle.hpp:204
GLM_FUNC_DECL value_type swizzle(comp X) const
Definition: type_vec3.inl:566
Definition: _detail.hpp:38
GLM_FUNC_DECL tvec3< T > & operator>>=(U const &s)
GLM_FUNC_DECL tvec3< T > & operator/=(U const &s)
Definition: type_mat2x2.hpp:38
GLM_FUNC_DECL tvec3(glm::detail::swizzle< 2, T, tvec2< T >, E0, E1,-1,-2 > const &v, T const &s)
Definition: type_vec3.hpp:173
GLM_FUNC_DECL tvec3< T > & operator|=(U const &s)
Definition: _swizzle.hpp:43
detail::tvec3< mediump_float > mediump_vec3
Definition: type_vec3.hpp:284
GLM_FUNC_DECL tvec3< T > & operator^=(U const &s)
GLM_FUNC_DECL tvec3(T const &s, glm::detail::swizzle< 2, T, tvec2< T >, E0, E1,-1,-2 > const &v)
Definition: type_vec3.hpp:179
GLM_FUNC_DECL tvec3< T > & operator*=(U const &s)
#define GLM_SWIZZLE_GEN_VEC_FROM_VEC3(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE)
Definition: _swizzle_func.hpp:426
#define _GLM_SWIZZLE3_3_MEMBERS(T, P, E0, E1, E2)
Definition: _swizzle.hpp:398
tvec3< bool > bool_type
Definition: type_vec3.hpp:55
#define GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C)
Definition: _swizzle_func.hpp:421
GLM_FUNC_DECL tref3< T > & operator=(tref3< T > const &r)
Definition: type_vec3.inl:1123
tvec3< T > type
Definition: type_vec3.hpp:54
#define _GLM_SWIZZLE3_2_MEMBERS(T, P2, E0, E1, E2)
Definition: _swizzle.hpp:387
detail::tvec3< lowp_int > lowp_ivec3
Definition: type_vec3.hpp:312
Definition: _swizzle.hpp:45
Definition: type_vec1.hpp:42
detail::tvec3< highp_uint > highp_uvec3
Definition: type_vec3.hpp:319
GLM_FUNC_DECL tref3(T &x, T &y, T &z)
Definition: type_vec3.inl:1095
GLM_FUNC_DECL tvec3()
Definition: type_vec3.inl:67
GLM_FUNC_DECL tvec3< T > & operator&=(U const &s)
GLM_FUNC_DECL tvec3< T > operator()()
Definition: type_vec3.inl:1146
T value_type
Definition: type_vec3.hpp:52
detail::tvec3< highp_int > highp_ivec3
Definition: type_vec3.hpp:298
std::size_t size_type
Definition: type_vec3.hpp:53
Definition: type_mat2x2.hpp:39
Definition: _swizzle.hpp:44
ctor
Definition: type_vec3.hpp:50
T & x
Definition: type_vec3.hpp:261
detail::tvec3< lowp_float > lowp_vec3
Definition: type_vec3.hpp:291
GLM_FUNC_DECL tvec3< T > & operator-=(U const &s)
#define _GLM_SWIZZLE3_4_MEMBERS(T, P2, E0, E1, E2)
Definition: _swizzle.hpp:427
detail::tvec3< mediump_uint > mediump_uvec3
Definition: type_vec3.hpp:326
T & y
Definition: type_vec3.hpp:262
Definition: _swizzle.hpp:48
detail::tvec3< lowp_uint > lowp_uvec3
Definition: type_vec3.hpp:333
GLM_FUNC_DECL value_type & operator[](size_type i)
Definition: type_vec3.inl:44
GLM_FUNC_DECL tvec3< T > & operator<<=(U const &s)
detail::tvec3< highp_float > highp_vec3
Definition: type_vec3.hpp:277
Definition: type_mat2x2.hpp:40
Definition: type_vec1.hpp:43
#define GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, A, B, C)
Definition: _swizzle_func.hpp:100
GLM_FUNC_DECL tvec3< T > & operator--()
Definition: type_vec3.inl:370
GLM_FUNC_DECL tvec3(glm::detail::swizzle< 3, T, tvec3< T >, E0, E1, E2,-1 > const &that)
Definition: type_vec3.hpp:167
value_type y
Definition: type_vec3.hpp:92
Definition: _swizzle.hpp:47
GLM_DETAIL_IS_VECTOR(tvec1)
comp
Definition: _swizzle.hpp:36
#define GLM_FUNC_DECL
Definition: setup.hpp:678
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const
Definition: type_vec3.inl:33
Definition: _swizzle.hpp:38
#define GLM_SWIZZLE_GEN_REF_FROM_VEC3(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE)
Definition: _swizzle_func.hpp:104
Definition: _swizzle.hpp:41
GLM_FUNC_DECL tvec3< T > & operator%=(U const &s)