• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /// @ref gtx_type_trait
2 /// @file glm/gtx/type_trait.hpp
3 ///
4 /// @see core (dependence)
5 ///
6 /// @defgroup gtx_type_trait GLM_GTX_type_trait
7 /// @ingroup gtx
8 ///
9 /// @brief Defines traits for each type.
10 ///
11 /// <glm/gtx/type_trait.hpp> need to be included to use these functionalities.
12 
13 #pragma once
14 
15 // Dependency:
16 #include "../detail/type_vec2.hpp"
17 #include "../detail/type_vec3.hpp"
18 #include "../detail/type_vec4.hpp"
19 #include "../detail/type_mat2x2.hpp"
20 #include "../detail/type_mat2x3.hpp"
21 #include "../detail/type_mat2x4.hpp"
22 #include "../detail/type_mat3x2.hpp"
23 #include "../detail/type_mat3x3.hpp"
24 #include "../detail/type_mat3x4.hpp"
25 #include "../detail/type_mat4x2.hpp"
26 #include "../detail/type_mat4x3.hpp"
27 #include "../detail/type_mat4x4.hpp"
28 #include "../gtc/quaternion.hpp"
29 #include "../gtx/dual_quaternion.hpp"
30 
31 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
32 #	pragma message("GLM: GLM_GTX_type_trait extension included")
33 #endif
34 
35 namespace glm
36 {
37 	/// @addtogroup gtx_type_trait
38 	/// @{
39 
40 	template <template <typename, precision> class genType, typename T, precision P>
41 	struct type
42 	{
43 		static bool const is_vec = false;
44 		static bool const is_mat = false;
45 		static bool const is_quat = false;
46 		static length_t const components = 0;
47 		static length_t const cols = 0;
48 		static length_t const rows = 0;
49 	};
50 
51 	template <typename T, precision P>
52 	struct type<tvec1, T, P>
53 	{
54 		static bool const is_vec = true;
55 		static bool const is_mat = false;
56 		static bool const is_quat = false;
57 		enum
58 		{
59 			components = 1
60 		};
61 	};
62 
63 	template <typename T, precision P>
64 	struct type<tvec2, T, P>
65 	{
66 		static bool const is_vec = true;
67 		static bool const is_mat = false;
68 		static bool const is_quat = false;
69 		enum
70 		{
71 			components = 2
72 		};
73 	};
74 
75 	template <typename T, precision P>
76 	struct type<tvec3, T, P>
77 	{
78 		static bool const is_vec = true;
79 		static bool const is_mat = false;
80 		static bool const is_quat = false;
81 		enum
82 		{
83 			components = 3
84 		};
85 	};
86 
87 	template <typename T, precision P>
88 	struct type<tvec4, T, P>
89 	{
90 		static bool const is_vec = true;
91 		static bool const is_mat = false;
92 		static bool const is_quat = false;
93 		enum
94 		{
95 			components = 4
96 		};
97 	};
98 
99 	template <typename T, precision P>
100 	struct type<tmat2x2, T, P>
101 	{
102 		static bool const is_vec = false;
103 		static bool const is_mat = true;
104 		static bool const is_quat = false;
105 		enum
106 		{
107 			components = 2,
108 			cols = 2,
109 			rows = 2
110 		};
111 	};
112 
113 	template <typename T, precision P>
114 	struct type<tmat2x3, T, P>
115 	{
116 		static bool const is_vec = false;
117 		static bool const is_mat = true;
118 		static bool const is_quat = false;
119 		enum
120 		{
121 			components = 2,
122 			cols = 2,
123 			rows = 3
124 		};
125 	};
126 
127 	template <typename T, precision P>
128 	struct type<tmat2x4, T, P>
129 	{
130 		static bool const is_vec = false;
131 		static bool const is_mat = true;
132 		static bool const is_quat = false;
133 		enum
134 		{
135 			components = 2,
136 			cols = 2,
137 			rows = 4
138 		};
139 	};
140 
141 	template <typename T, precision P>
142 	struct type<tmat3x2, T, P>
143 	{
144 		static bool const is_vec = false;
145 		static bool const is_mat = true;
146 		static bool const is_quat = false;
147 		enum
148 		{
149 			components = 3,
150 			cols = 3,
151 			rows = 2
152 		};
153 	};
154 
155 	template <typename T, precision P>
156 	struct type<tmat3x3, T, P>
157 	{
158 		static bool const is_vec = false;
159 		static bool const is_mat = true;
160 		static bool const is_quat = false;
161 		enum
162 		{
163 			components = 3,
164 			cols = 3,
165 			rows = 3
166 		};
167 	};
168 
169 	template <typename T, precision P>
170 	struct type<tmat3x4, T, P>
171 	{
172 		static bool const is_vec = false;
173 		static bool const is_mat = true;
174 		static bool const is_quat = false;
175 		enum
176 		{
177 			components = 3,
178 			cols = 3,
179 			rows = 4
180 		};
181 	};
182 
183 	template <typename T, precision P>
184 	struct type<tmat4x2, T, P>
185 	{
186 		static bool const is_vec = false;
187 		static bool const is_mat = true;
188 		static bool const is_quat = false;
189 		enum
190 		{
191 			components = 4,
192 			cols = 4,
193 			rows = 2
194 		};
195 	};
196 
197 	template <typename T, precision P>
198 	struct type<tmat4x3, T, P>
199 	{
200 		static bool const is_vec = false;
201 		static bool const is_mat = true;
202 		static bool const is_quat = false;
203 		enum
204 		{
205 			components = 4,
206 			cols = 4,
207 			rows = 3
208 		};
209 	};
210 
211 	template <typename T, precision P>
212 	struct type<tmat4x4, T, P>
213 	{
214 		static bool const is_vec = false;
215 		static bool const is_mat = true;
216 		static bool const is_quat = false;
217 		enum
218 		{
219 			components = 4,
220 			cols = 4,
221 			rows = 4
222 		};
223 	};
224 
225 	template <typename T, precision P>
226 	struct type<tquat, T, P>
227 	{
228 		static bool const is_vec = false;
229 		static bool const is_mat = false;
230 		static bool const is_quat = true;
231 		enum
232 		{
233 			components = 4
234 		};
235 	};
236 
237 	template <typename T, precision P>
238 	struct type<tdualquat, T, P>
239 	{
240 		static bool const is_vec = false;
241 		static bool const is_mat = false;
242 		static bool const is_quat = true;
243 		enum
244 		{
245 			components = 8
246 		};
247 	};
248 
249 	/// @}
250 }//namespace glm
251 
252 #include "type_trait.inl"
253