HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_VectorTypes.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_VectorTypes.h (Utility library, C++)
7  *
8  * COMMENTS:
9  * This class prototypes our vector types, such
10  * as UT_QuaternionR, UT_Vector3R, etc.
11  */
12 
13 #ifndef __UT_VectorTypes__
14 #define __UT_VectorTypes__
15 
16 #include "UT_API.h"
17 
18 #include <SYS/SYS_Types.h>
19 #include <SYS/SYS_TypeDecorate.h>
20 
21 // Define this so that H11 users can use this to determine if they have
22 // UT_Vector3R, UT_Matrix3R, etc.
23 #define UT_VECTORTYPES_HAVE_FPREAL 1
24 
25 template <typename T> class UT_API UT_Vector2T;
30 typedef UT_Vector2T<float> UT_Vector2; // deprecated
33 
34 template <typename T> class UT_API UT_Vector3T;
39 typedef UT_Vector3T<float> UT_Vector3; // deprecated
42 
43 template <typename T> class UT_API UT_Vector4T;
48 typedef UT_Vector4T<float> UT_Vector4; // deprecated
51 
52 class UT_XformOrder;
53 
54 template <typename T> class UT_API UT_QuaternionT;
59 typedef UT_QuaternionT<float> UT_Quaternion; // deprecated
60 
61 template <typename T> class UT_API UT_Matrix2T;
65 typedef UT_Matrix2T<float> UT_Matrix2; // deprecated
66 typedef UT_Matrix2T<double> UT_DMatrix2; // deprecated
67 
68 template <typename T> class UT_API UT_Matrix3T;
72 typedef UT_Matrix3T<float> UT_Matrix3; // deprecated
73 typedef UT_Matrix3T<double> UT_DMatrix3; // deprecated
74 
75 template <typename T> class UT_API UT_Matrix4T;
79 typedef UT_Matrix4T<float> UT_Matrix4; // deprecated
80 typedef UT_Matrix4T<double> UT_DMatrix4; // deprecated
81 
82 
83 //
84 // Declare the following types as POD so that UT_ValArray can be optimized
85 //
98 
108 
109 //
110 // Declare relocation traits
111 //
112 
113 // Guaranteed safe for trivial relocation:
114 
115 template <typename T>
117 
118 template <typename T>
119 struct SafeTrivialRelocationNoCV< UT_Vector3T< T > > : SafeTrivialRelocationNoCV< SYS_RemoveCV_t< T > > {};
120 
121 template <typename T>
122 struct SafeTrivialRelocationNoCV< UT_Vector4T< T > > : SafeTrivialRelocationNoCV< SYS_RemoveCV_t< T > > {};
123 
124 // Known to be unsafe for trivial relocation:
125 
126 template <typename T>
127 struct UnsafeTrivialRelocationNoCV< UT_Vector2T< T > > : UnsafeTrivialRelocationNoCV< SYS_RemoveCV_t< T > > {};
128 
129 template <typename T>
130 struct UnsafeTrivialRelocationNoCV< UT_Vector3T< T > > : UnsafeTrivialRelocationNoCV< SYS_RemoveCV_t< T > > {};
131 
132 template <typename T>
133 struct UnsafeTrivialRelocationNoCV< UT_Vector4T< T > > : UnsafeTrivialRelocationNoCV< SYS_RemoveCV_t< T > > {};
134 
135 //
136 // Declare common array types
137 //
138 template <typename T> class UT_API_TMPL UT_ValArray;
139 
152 
165 
172 
179 
183 
187 
188 
189 //
190 // Type Conversion
191 //
192 template< typename FT, template<typename> class V >
193 inline const V<fpreal>
195  const V<FT>& v
196 )
197 {
198  return V<fpreal>(v);
199 }
200 template< typename FT, template<typename> class V >
201 inline const V<double>
203  const V<FT>& v
204 )
205 {
206  return V<double>(v);
207 }
208 template< typename FT, template<typename> class V >
209 inline const V<float>
211  const V<FT>& v
212 )
213 {
214  return V<float>(v);
215 }
216 #if (SYS_SIZEOF_FPREAL == 4)
217  #define UT_R_FROM_D(VAL) UTconvertToR(VAL)
218  #define UT_R_FROM_F(VAL) (VAL)
219  #define UT_D_FROM_R(VAL) UTconvertToD(VAL)
220  #define UT_F_FROM_R(VAL) (VAL)
221 #elif (SYS_SIZEOF_FPREAL == 8)
222  #define UT_R_FROM_F(VAL) UTconvertToR(VAL)
223  #define UT_R_FROM_D(VAL) (VAL)
224  #define UT_F_FROM_R(VAL) UTconvertToF(VAL)
225  #define UT_D_FROM_R(VAL) (VAL)
226 #else
227  #error Missing FPREAL type
228 #endif
229 
230 
231 template<typename T>
232 static inline const char *UT_TypeShortName();
233 
234 template<>
235 inline const char *UT_TypeShortName<fpreal16>() { return "H"; }
236 
237 template<>
238 inline const char *UT_TypeShortName<fpreal32>() { return "F"; }
239 
240 template<>
241 inline const char *UT_TypeShortName<fpreal64>() { return "D"; }
242 
243 template<>
244 inline const char *UT_TypeShortName<int32>() { return "i"; }
245 
246 template<>
247 inline const char *UT_TypeShortName<int64>() { return "I"; }
248 
249 
250 // Type promotion
251 // This is used to define promoted types for specific use cases.
252 // E.g. We define PreciseType as the promoted version of a type to use in
253 // calculations where we want extra precision (e.g. norm calculations)
254 
255 template<typename T>
257 {
258  // Default precise promotion is T
259  typedef T PreciseType;
260 };
261 
262 template<>
264 {
265  // Use double precision for precise calculations
267 };
268 
269 // Templated typedefs for convenience
270 
271 // e.g. UT_PreciseT<fpreal32> is type fpreal64
272 template <typename T>
274 
275 /// UT_FromUnbounded creates a V from an unbounded array-like type.
276 template <typename V>
277 struct UT_FromUnbounded
278 {
279  template <typename TS>
280  constexpr SYS_FORCE_INLINE V operator()(const TS& as) const noexcept
281  {
282  return as[0];
283  }
284 };
285 
286 #endif
UT_ValArray< UT_Vector3R > UT_Vector3RArray
UT_Vector2T< int64 > UT_Vector2I
UT_ValArray< UT_Vector3i > UT_Vector3iArray
UT_Matrix4T< double > UT_DMatrix4
UT_Matrix4T< fpreal64 > UT_Matrix4D
UT_Matrix3T< double > UT_DMatrix3
UT_ValArray< UT_Matrix4D > UT_Matrix4DArray
UT_Vector3T< fpreal16 > UT_Vector3H
UT_ValArray< UT_Vector2i > UT_Vector2iArray
UT_ValArray< exint > UT_ExintArray
UT_FromUnbounded creates a V from an unbounded array-like type.
Definition: UT_Vector2.h:795
const V< double > UTconvertToD(const V< FT > &v)
UT_ValArray< UT_Matrix4F > UT_Matrix4FArray
UT_Vector3T< int32 > UT_Vector3i
UT_ValArray< UT_Vector3F > UT_Vector3FArray
UT_Vector2T< float > UT_Vector2
const GLdouble * v
Definition: glcorearb.h:837
const char * UT_TypeShortName< int64 >()
UT_Vector2T< fpreal64 > UT_Vector2D
Transformation order of scales, rotates, and translates.
Definition: UT_XformOrder.h:23
UT_ValArray< UT_Matrix2F > UT_Matrix2FArray
UT_Vector3T< float > UT_Vector3
UT_ValArray< UT_Vector4H > UT_Vector4HArray
UT_ValArray< int > UT_IntArray
UT_ValArray< UT_Vector3 > UT_Vector3Array
UT_Vector4T< int64 > UT_Vector4I
#define UT_API
Definition: UT_API.h:14
UT_ValArray< int16 > UT_Int16Array
UT_Vector3T< int64 > UT_Vector3I
UT_ValArray< UT_Vector4I > UT_Vector4IArray
UT_ValArray< UT_Vector2F > UT_Vector2FArray
3D Vector class.
4D Vector class.
Definition: UT_Vector4.h:174
2D Vector class.
Definition: UT_Vector2.h:159
float fpreal32
Definition: SYS_Types.h:200
UT_ValArray< UT_QuaternionR > UT_QuaternionRArray
UT_Matrix3T< fpreal > UT_Matrix3R
UT_Matrix4T< float > UT_Matrix4
UT_ValArray< UT_Vector2 > UT_Vector2Array
UT_ValArray< fpreal64 > UT_Fpreal64Array
const char * UT_TypeShortName< fpreal32 >()
UT_ValArray< float > UT_FloatArray
double fpreal64
Definition: SYS_Types.h:201
UT_Vector4T< fpreal > UT_Vector4R
UT_Vector4T< int32 > UT_Vector4i
UT_ValArray< UT_Matrix3F > UT_Matrix3FArray
UT_ValArray< int8 > UT_Int8Array
UT_Vector4T< float > UT_Vector4
UT_Matrix2T< fpreal > UT_Matrix2R
UT_QuaternionT< fpreal > UT_QuaternionR
UT_Matrix3T< float > UT_Matrix3
UT_ValArray< UT_Vector3I > UT_Vector3IArray
UT_Vector4T< fpreal16 > UT_Vector4H
typename SYS_RemoveCV< T >::type SYS_RemoveCV_t
UT_ValArray< UT_Vector4D > UT_Vector4DArray
UT_ValArray< UT_Vector2R > UT_Vector2RArray
UT_ValArray< UT_Matrix2D > UT_Matrix2DArray
UT_Matrix2T< double > UT_DMatrix2
UT_QuaternionT< fpreal16 > UT_QuaternionH
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
const char * UT_TypeShortName< int32 >()
UT_ValArray< fpreal > UT_FprealArray
UT_Matrix2T< float > UT_Matrix2
typename UT_TypePromoteT< T >::PreciseType UT_PreciseT
UT_Matrix4T< fpreal32 > UT_Matrix4F
#define SYS_DECLARE_IS_POD(T)
Declare a type as POD.
UT_ValArray< int32 > UT_Int32Array
UT_Vector2T< fpreal16 > UT_Vector2H
UT_ValArray< UT_QuaternionF > UT_QuaternionFArray
UT_Matrix3T< fpreal32 > UT_Matrix3F
UT_Vector3T< fpreal64 > UT_Vector3D
UT_ValArray< UT_Vector4R > UT_Vector4RArray
UT_QuaternionT< fpreal32 > UT_QuaternionF
UT_QuaternionT< fpreal64 > UT_QuaternionD
UT_QuaternionT< float > UT_Quaternion
UT_Matrix2T< fpreal64 > UT_Matrix2D
UT_Vector3T< fpreal32 > UT_Vector3F
UT_ValArray< UT_Vector2D > UT_Vector2DArray
const char * UT_TypeShortName< fpreal16 >()
Quaternion class.
Definition: GEO_Detail.h:48
const V< fpreal > UTconvertToR(const V< FT > &v)
UT_Vector2T< fpreal32 > UT_Vector2F
constexpr SYS_FORCE_INLINE V operator()(const TS &as) const noexcept
UT_Vector2T< fpreal > UT_Vector2R
UT_ValArray< UT_Vector2H > UT_Vector2HArray
UT_ValArray< UT_Vector4i > UT_Vector4iArray
UT_Vector4T< fpreal32 > UT_Vector4F
UT_ValArray< UT_Vector2I > UT_Vector2IArray
UT_Vector3T< fpreal > UT_Vector3R
UT_ValArray< UT_Vector3H > UT_Vector3HArray
UT_ValArray< int64 > UT_Int64Array
#define UT_API_TMPL
Definition: UT_API.h:15
UT_ValArray< double > UT_DoubleArray
UT_ValArray< uint8 > UT_Uint8Array
UT_ValArray< UT_QuaternionD > UT_QuaternionDArray
UT_ValArray< UT_Vector3D > UT_Vector3DArray
const char * UT_TypeShortName< fpreal64 >()
UT_Matrix4T< fpreal > UT_Matrix4R
UT_Vector4T< fpreal64 > UT_Vector4D
UT_ValArray< UT_Matrix3D > UT_Matrix3DArray
UT_Matrix2T< fpreal32 > UT_Matrix2F
UT_ValArray< UT_Vector4 > UT_Vector4Array
UT_Vector2T< int32 > UT_Vector2i
const V< float > UTconvertToF(const V< FT > &v)
UT_ValArray< fpreal32 > UT_Fpreal32Array
UT_ValArray< UT_Vector4F > UT_Vector4FArray
UT_Matrix3T< fpreal64 > UT_Matrix3D