12 #if defined(__VEX_COMPILING_KVEX__)
14 #ifndef __VEX_KVexMath__
15 #define __VEX_KVexMath__
17 #define KVEX_FUNC_FV(NAME, IMPL) \
18 template <typename VEC_T> inline VEXfloat \
19 NAME(const VEC_T &v) { return IMPL; } \
22 KVEX_FUNC_FV(length__vxmgl_F_U,
v.length())
23 KVEX_FUNC_FV(length__vxmgl_F_V,
v.length())
24 KVEX_FUNC_FV(length__vxmgl_F_P,
v.length())
26 KVEX_FUNC_FV(length2__vxmgl_F_U,
v.length2())
27 KVEX_FUNC_FV(length2__vxmgl_F_V,
v.length2())
28 KVEX_FUNC_FV(length2__vxmgl_F_P,
v.length2())
30 #define KVEX_FUNC_VVVF(NAME, IMPL) \
31 template <typename VEC_T>
inline VEC_T \
32 NAME(
const VEC_T &
a,
const VEC_T &
b,
VEXfloat c) {
return IMPL; } \
41 KVEX_FUNC_VVVF(lerp__vxmgl_U_UUF,
a + (
b-
a)*
c)
42 KVEX_FUNC_VVVF(lerp__vxmgl_V_VVF,
a + (
b-
a)*
c)
43 KVEX_FUNC_VVVF(lerp__vxmgl_P_PPF,
a + (
b-
a)*
c)
46 xyztorgb__vxmgl_V_V(
const VEXvec3 &xyz)
48 return VEXvec3(3.2406 * xyz.x() - 1.5372 * xyz.y() - 0.4986 * xyz.z(),
49 -0.9689 * xyz.x() + 1.8758 * xyz.y() + 0.0415 * xyz.z(),
50 0.0557 * xyz.x() - 0.2040 * xyz.y() + 1.0570 * xyz.z());
54 rgbtoxyz__vxmgl_V_V(
const VEXvec3 &rgb)
56 return VEXvec3(0.4124 * rgb.x() + 0.3576 * rgb.y() + 0.1805 * rgb.z(),
57 0.2126 * rgb.x() + 0.7152 * rgb.y() + 0.0722 * rgb.z(),
58 0.0193 * rgb.x() + 0.1192 * rgb.y() + 0.9505 * rgb.z());
61 #define KVEX_COMPWISE_TERNARY_BASE(FUNC, FLT_FUNC) \
62 inline VEXvec2 FUNC##_U_UUU(const VEXvec2 &a, const VEXvec2 &b, const VEXvec2 &c) { \
63 return VEXvec2(FLT_FUNC(a.x(), b.x(), c.x()), \
64 FLT_FUNC(a.y(), b.y(), c.y())); \
66 inline VEXvec3 FUNC##_V_VVV(const VEXvec3 &a, const VEXvec3 &b, const VEXvec3 &c) { \
67 return VEXvec3(FLT_FUNC(a.x(), b.x(), c.x()), \
68 FLT_FUNC(a.y(), b.y(), c.y()), \
69 FLT_FUNC(a.z(), b.z(), c.y())); \
71 inline VEXvec4 FUNC##_P_PPP(const VEXvec4 &a, const VEXvec4 &b, const VEXvec4 &c) { \
72 return VEXvec4(FLT_FUNC(a.x(), b.x(), c.x()), \
73 FLT_FUNC(a.y(), b.y(), c.y()), \
74 FLT_FUNC(a.z(), b.z(), c.z()), \
75 FLT_FUNC(a.w(), b.w(), c.w())); \
79 #define KVEX_COMPWISE_TERNARY(FUNC) \
80 KVEX_COMPWISE_TERNARY(FUNC) \
81 KVEX_COMPWISE_TERNARY_BASE(FUNC, FUNC##_F_FFF) \
84 #define KVEX_WRAP_TERNARY(FUNC, WRAP_FUNC) \
85 inline VEXvec2 FUNC##_U_UUU(const VEXvec2 &a, const VEXvec2 &b, const VEXvec2 &c) { \
86 return WRAP_FUNC(a, b, c); \
88 inline VEXvec3 FUNC##_V_VVV(const VEXvec3 &a, const VEXvec3 &b, const VEXvec3 &c) { \
89 return WRAP_FUNC(a, b, c); \
91 inline VEXvec4 FUNC##_P_PPP(const VEXvec4 &a, const VEXvec4 &b, const VEXvec4 &c) { \
92 return WRAP_FUNC(a, b, c); \
95 #if defined(KVEX_CPP_UT)
96 KVEX_COMPWISE_TERNARY_BASE(clamp__vxmgl,
SYSclamp)
99 #if defined(KVEX_CPP_GUT)
100 KVEX_WRAP_TERNARY(clamp_vxmgl,
clamp)
104 #undef KVEX_FUNC_VVVF
105 #undef KVEX_COMPWISE_TERNARY
106 #undef KVEX_COMPWISE_TERNARY_BASE
108 #endif // __VEX_COMPILING_KVEX__
GLboolean GLboolean GLboolean GLboolean a
typename VEX_PrecisionResolver< P >::vec3_type VEXvec3
typename VEX_PrecisionResolver< P >::float_type VEXfloat
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
GLboolean GLboolean GLboolean b