HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VEX_PodTypes.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: VEX_PodTypes.h (VEX Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __VEX_PodTypes__
12 #define __VEX_PodTypes__
13 
14 #include <VM/VM_Math.h>
15 #include <UT/UT_Vector2.h>
16 #include <UT/UT_Vector3.h>
17 #include <UT/UT_Vector4.h>
18 #include <UT/UT_Matrix2.h>
19 #include <UT/UT_Matrix3.h>
20 #include <UT/UT_Matrix4.h>
21 #include <UT/UT_Quaternion.h>
22 #include <UT/UT_Assert.h>
23 
25 {
26  VEX_32, // 32 bit precision
27  VEX_64, // 64 bit precision
28 };
29 
30 template <VEX_Precision PREC> class VEX_PrecisionResolver;
31 
32 #define VEX_FORCE_32(CLASS) CLASS<VEX_32>
33 
34 template <>
36 {
37 public:
38  using int_type = int32;
47 };
48 
49 template <>
51 {
52 public:
53  using int_type = int64;
62 };
63 
64 template <VEX_Precision P> using VEXfloat = typename VEX_PrecisionResolver<P>::float_type;
65 template <VEX_Precision P> using VEXint = typename VEX_PrecisionResolver<P>::int_type;
66 template <VEX_Precision P> using VEXvec2 = typename VEX_PrecisionResolver<P>::vec2_type;
67 template <VEX_Precision P> using VEXvec3 = typename VEX_PrecisionResolver<P>::vec3_type;
68 template <VEX_Precision P> using VEXvec4 = typename VEX_PrecisionResolver<P>::vec4_type;
69 template <VEX_Precision P> using VEXmat2 = typename VEX_PrecisionResolver<P>::mat2_type;
70 template <VEX_Precision P> using VEXmat3 = typename VEX_PrecisionResolver<P>::mat3_type;
71 template <VEX_Precision P> using VEXmat4 = typename VEX_PrecisionResolver<P>::mat4_type;
72 template <VEX_Precision P> using VEXquaternion = typename VEX_PrecisionResolver<P>::quat_type;
73 
74 template <typename T>
75 static inline void
76 VEXpodFill(T *a, T *b, const T &v)
77  { std::fill(a, b, v); }
78 
79 /// Filling with a disabled predicate
80 template <typename T>
81 static inline void
82 VEXpodFill(T *a, const T *b, const T &val, const uint32 *disabled)
83 {
84  for (; a != b; ++a, ++disabled)
85  *a = *disabled ? *a : val;
86 }
87 
88 template <> inline void
90 {
91  VM_Math::set(a, v, b-a);
92 }
93 
94 template <> inline void
96  const fpreal32 &val, const uint32 *disabled)
97 {
98  VM_Math::set(a, val, b-a, disabled);
99 }
100 
101 template <typename T>
102 static inline T *
103 VEXpodCopy(const T *a, const T *b, T *dest)
104 {
105  UT_ASSERT(dest <= a || dest >= b);
106  return std::copy(a, b, dest);
107 }
108 
109 /// Copying with a disabled predicate
110 template <typename T>
111 static inline T *
112 VEXpodCopy(const T *a, const T *b, T *dest, const uint32 *disabled)
113 {
114  UT_ASSERT(dest <= a || dest >= b);
115  for (; a != b; ++a, ++dest, ++disabled)
116  *dest = *disabled ? *dest : *a;
117  return dest;
118 }
119 
120 template <>
121 inline fpreal32 *
123  const uint32 *disabled)
124 {
125  UT_ASSERT(dest <= a || dest >= b);
126  VM_Math::set(dest, a, b-a, disabled);
127  return dest + (b-a);
128 }
129 
130 template <>
131 inline int32 *
132 VEXpodCopy<int32>(const int32 *a, const int32 *b, int32 *dest,
133  const uint32 *disabled)
134 {
135  UT_ASSERT(dest <= a || dest >= b);
136  VM_Math::set(dest, a, b-a, disabled);
137  return dest + (b-a);
138 }
139 
140 namespace VEX {
141  inline namespace Literal {
142  // 32 bit constants: 32_vi or 3.1415_vf
144  VEXint<VEX_32> operator "" _vi(unsigned long long int v)
145  { return v; }
147  VEXfloat<VEX_32> operator "" _vf(long double v)
148  { return v; }
149 
150  // 64 bit constants: 32_vl or 3.1415_vd
152  VEXint<VEX_64> operator "" _vl(unsigned long long int v)
153  { return v; }
155  VEXfloat<VEX_64> operator "" _vd(long double v)
156  { return v; }
157  }
158 }
159 
160 #endif
int32 * VEXpodCopy< int32 >(const int32 *a, const int32 *b, int32 *dest, const uint32 *disabled)
Definition: VEX_PodTypes.h:132
UT_Matrix4T< fpreal64 > UT_Matrix4D
void VEXpodFill(fpreal32 *a, const fpreal32 *b, const fpreal32 &val, const uint32 *disabled)
Definition: VEX_PodTypes.h:95
const GLdouble * v
Definition: glcorearb.h:836
UT_Vector2T< fpreal64 > UT_Vector2D
VEX_Precision
Definition: VEX_PodTypes.h:24
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
typename VEX_PrecisionResolver< P >::vec3_type VEXvec3
Definition: VEX_PodTypes.h:67
long long int64
Definition: SYS_Types.h:106
UT_QuaternionT< fpreal32 > UT_QuaternionF
fpreal32 * VEXpodCopy< fpreal32 >(const fpreal32 *a, const fpreal32 *b, fpreal32 *dest, const uint32 *disabled)
Definition: VEX_PodTypes.h:122
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
typename VEX_PrecisionResolver< P >::quat_type VEXquaternion
Definition: VEX_PodTypes.h:72
typename VEX_PrecisionResolver< P >::float_type VEXfloat
Definition: VEX_PodTypes.h:64
UT_QuaternionT< fpreal64 > UT_QuaternionD
double fpreal64
Definition: SYS_Types.h:191
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
UT_Matrix4T< fpreal32 > UT_Matrix4F
typename VEX_PrecisionResolver< P >::mat4_type VEXmat4
Definition: VEX_PodTypes.h:71
UT_Matrix3T< fpreal32 > UT_Matrix3F
UT_Vector3T< fpreal64 > UT_Vector3D
int int32
Definition: SYS_Types.h:34
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
UT_Matrix2T< fpreal64 > UT_Matrix2D
UT_Vector3T< fpreal32 > UT_Vector3F
typename VEX_PrecisionResolver< P >::mat2_type VEXmat2
Definition: VEX_PodTypes.h:69
UT_Vector2T< fpreal32 > UT_Vector2F
typename VEX_PrecisionResolver< P >::vec2_type VEXvec2
Definition: VEX_PodTypes.h:66
UT_Vector4T< fpreal32 > UT_Vector4F
VM_SIV set(fpreal32 *d, const fpreal32 *a, exint num, const uint32 *disabled)
VM_Math::set(d, a, disabled) := d[i] = disabled[i] ? d[i] : a[i].
Definition: VM_Math.h:391
GLuint GLfloat * val
Definition: glcorearb.h:1607
typename VEX_PrecisionResolver< P >::vec4_type VEXvec4
Definition: VEX_PodTypes.h:68
typename VEX_PrecisionResolver< P >::int_type VEXint
Definition: VEX_PodTypes.h:65
UT_Vector4T< fpreal64 > UT_Vector4D
UT_Matrix2T< fpreal32 > UT_Matrix2F
typename VEX_PrecisionResolver< P >::mat3_type VEXmat3
Definition: VEX_PodTypes.h:70
float fpreal32
Definition: SYS_Types.h:190
void VEXpodFill< fpreal32 >(fpreal32 *a, fpreal32 *b, const fpreal32 &v)
Definition: VEX_PodTypes.h:89
UT_Matrix3T< fpreal64 > UT_Matrix3D
unsigned int uint32
Definition: SYS_Types.h:35