HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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;
58 typedef UT_QuaternionT<float> UT_Quaternion; // deprecated
59 
60 template <typename T> class UT_API UT_Matrix2T;
64 typedef UT_Matrix2T<float> UT_Matrix2; // deprecated
65 typedef UT_Matrix2T<double> UT_DMatrix2; // deprecated
66 
67 template <typename T> class UT_API UT_Matrix3T;
71 typedef UT_Matrix3T<float> UT_Matrix3; // deprecated
72 typedef UT_Matrix3T<double> UT_DMatrix3; // deprecated
73 
74 template <typename T> class UT_API UT_Matrix4T;
78 typedef UT_Matrix4T<float> UT_Matrix4; // deprecated
79 typedef UT_Matrix4T<double> UT_DMatrix4; // deprecated
80 
81 
82 //
83 // Declare the following types as POD so that UT_ValArray can be optimized
84 //
97 
106 
107 //
108 // Declare common array types
109 //
110 template <typename T> class UT_API_TMPL UT_ValArray;
111 
112 typedef UT_ValArray<fpreal> UT_FprealArray;
113 typedef UT_ValArray<fpreal32> UT_Fpreal32Array;
114 typedef UT_ValArray<fpreal64> UT_Fpreal64Array;
115 typedef UT_ValArray<float> UT_FloatArray;
116 typedef UT_ValArray<double> UT_DoubleArray;
117 typedef UT_ValArray<int> UT_IntArray;
118 typedef UT_ValArray<exint> UT_ExintArray;
119 typedef UT_ValArray<int16> UT_Int16Array;
120 typedef UT_ValArray<int32> UT_Int32Array;
121 typedef UT_ValArray<int64> UT_Int64Array;
122 
123 typedef UT_ValArray<UT_Vector2R> UT_Vector2RArray;
124 typedef UT_ValArray<UT_Vector3R> UT_Vector3RArray;
125 typedef UT_ValArray<UT_Vector4R> UT_Vector4RArray;
126 typedef UT_ValArray<UT_Vector2F> UT_Vector2FArray;
127 typedef UT_ValArray<UT_Vector3F> UT_Vector3FArray;
128 typedef UT_ValArray<UT_Vector4F> UT_Vector4FArray;
129 typedef UT_ValArray<UT_Vector2D> UT_Vector2DArray;
130 typedef UT_ValArray<UT_Vector3D> UT_Vector3DArray;
131 typedef UT_ValArray<UT_Vector4D> UT_Vector4DArray;
132 typedef UT_ValArray<UT_Vector2H> UT_Vector2HArray;
133 typedef UT_ValArray<UT_Vector3H> UT_Vector3HArray;
134 typedef UT_ValArray<UT_Vector4H> UT_Vector4HArray;
135 
136 typedef UT_ValArray<UT_Vector2I> UT_Vector2IArray;
137 typedef UT_ValArray<UT_Vector3I> UT_Vector3IArray;
138 typedef UT_ValArray<UT_Vector4I> UT_Vector4IArray;
139 typedef UT_ValArray<UT_Vector2i> UT_Vector2iArray;
140 typedef UT_ValArray<UT_Vector3i> UT_Vector3iArray;
141 typedef UT_ValArray<UT_Vector4i> UT_Vector4iArray;
142 
143 typedef UT_ValArray<UT_Matrix2F> UT_Matrix2FArray;
144 typedef UT_ValArray<UT_Matrix3F> UT_Matrix3FArray;
145 typedef UT_ValArray<UT_Matrix4F> UT_Matrix4FArray;
146 typedef UT_ValArray<UT_Matrix2D> UT_Matrix2DArray;
147 typedef UT_ValArray<UT_Matrix3D> UT_Matrix3DArray;
148 typedef UT_ValArray<UT_Matrix4D> UT_Matrix4DArray;
149 
150 typedef UT_ValArray<UT_Vector2> UT_Vector2Array; // deprecated
151 typedef UT_ValArray<UT_Vector3> UT_Vector3Array; // deprecated
152 typedef UT_ValArray<UT_Vector4> UT_Vector4Array; // deprecated
153 
154 
155 //
156 // Type Conversion
157 //
158 template< typename FT, template<typename> class V >
159 inline const V<fpreal>
161  const V<FT>& v
162 )
163 {
164  return V<fpreal>(v);
165 }
166 template< typename FT, template<typename> class V >
167 inline const V<double>
169  const V<FT>& v
170 )
171 {
172  return V<double>(v);
173 }
174 template< typename FT, template<typename> class V >
175 inline const V<float>
177  const V<FT>& v
178 )
179 {
180  return V<float>(v);
181 }
182 #if (SYS_SIZEOF_FPREAL == 4)
183  #define UT_R_FROM_D(VAL) UTconvertToR(VAL)
184  #define UT_R_FROM_F(VAL) (VAL)
185  #define UT_D_FROM_R(VAL) UTconvertToD(VAL)
186  #define UT_F_FROM_R(VAL) (VAL)
187 #elif (SYS_SIZEOF_FPREAL == 8)
188  #define UT_R_FROM_F(VAL) UTconvertToR(VAL)
189  #define UT_R_FROM_D(VAL) (VAL)
190  #define UT_F_FROM_R(VAL) UTconvertToF(VAL)
191  #define UT_D_FROM_R(VAL) (VAL)
192 #else
193  #error Missing FPREAL type
194 #endif
195 
196 
197 template<typename T>
198 static inline const char *UT_TypeShortName();
199 
200 template<>
201 inline const char *UT_TypeShortName<fpreal16>() { return "H"; }
202 
203 template<>
204 inline const char *UT_TypeShortName<fpreal32>() { return "F"; }
205 
206 template<>
207 inline const char *UT_TypeShortName<fpreal64>() { return "D"; }
208 
209 template<>
210 inline const char *UT_TypeShortName<int32>() { return "i"; }
211 
212 template<>
213 inline const char *UT_TypeShortName<int64>() { return "I"; }
214 
215 
216 // Type promotion
217 // This is used to define promoted types for specific use cases.
218 // E.g. We define PreciseType as the promoted version of a type to use in
219 // calculations where we want extra precision (e.g. norm calculations)
220 
221 template<typename T>
223 {
224  // Default precise promotion is T
225  typedef T PreciseType;
226 };
227 
228 template<>
230 {
231  // Use double precision for precise calculations
233 };
234 
235 // Templated typedefs for convenience
236 
237 // e.g. UT_PreciseT<fpreal32> is type fpreal64
238 template <typename T>
240 
241 #endif
UT_Vector2T< int64 > UT_Vector2I
UT_Matrix4T< double > UT_DMatrix4
UT_Matrix4T< fpreal64 > UT_Matrix4D
UT_Matrix3T< double > UT_DMatrix3
UT_Vector3T< fpreal16 > UT_Vector3H
const V< double > UTconvertToD(const V< FT > &v)
UT_Vector3T< int32 > UT_Vector3i
UT_Vector2T< float > UT_Vector2
const GLdouble * v
Definition: glcorearb.h:836
const char * UT_TypeShortName< int64 >()
UT_Vector2T< fpreal64 > UT_Vector2D
UT_Vector3T< float > UT_Vector3
UT_Vector4T< int64 > UT_Vector4I
#define UT_API
Definition: UT_API.h:12
UT_Vector3T< int64 > UT_Vector3I
3D Vector class.
4D Vector class.
Definition: UT_Vector4.h:152
2D Vector class.
Definition: UT_Vector2.h:137
UT_Matrix3T< fpreal > UT_Matrix3R
UT_Matrix4T< float > UT_Matrix4
const char * UT_TypeShortName< fpreal32 >()
UT_Vector4T< fpreal > UT_Vector4R
UT_Vector4T< int32 > UT_Vector4i
long long int64
Definition: SYS_Types.h:100
UT_Vector4T< float > UT_Vector4
UT_Matrix2T< fpreal > UT_Matrix2R
UT_QuaternionT< fpreal > UT_QuaternionR
UT_Matrix3T< float > UT_Matrix3
UT_Vector4T< fpreal16 > UT_Vector4H
int64 exint
Definition: SYS_Types.h:109
double fpreal64
Definition: SYS_Types.h:185
UT_Matrix2T< double > UT_DMatrix2
const char * UT_TypeShortName< int32 >()
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_Vector2T< fpreal16 > UT_Vector2H
UT_Matrix3T< fpreal32 > UT_Matrix3F
UT_Vector3T< fpreal64 > UT_Vector3D
int int32
Definition: SYS_Types.h:28
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
const char * UT_TypeShortName< fpreal16 >()
double fpreal
Definition: SYS_Types.h:263
Quaternion class.
Definition: UT_Quaternion.h:44
const V< fpreal > UTconvertToR(const V< FT > &v)
UT_Vector2T< fpreal32 > UT_Vector2F
UT_Vector2T< fpreal > UT_Vector2R
UT_Vector4T< fpreal32 > UT_Vector4F
UT_Vector3T< fpreal > UT_Vector3R
#define UT_API_TMPL
Definition: UT_API.h:13
const char * UT_TypeShortName< fpreal64 >()
UT_Matrix4T< fpreal > UT_Matrix4R
#define const
Definition: zconf.h:214
UT_Vector4T< fpreal64 > UT_Vector4D
short int16
Definition: SYS_Types.h:26
UT_Matrix2T< fpreal32 > UT_Matrix2F
float fpreal32
Definition: SYS_Types.h:184
UT_Vector2T< int32 > UT_Vector2i
const V< float > UTconvertToF(const V< FT > &v)
UT_Matrix3T< fpreal64 > UT_Matrix3D