1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#ifndef __VRAY3_COMPAT_H__
#define __VRAY3_COMPAT_H__
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
#pragma once
#include <vraybase.h>
#include <vrayinterface.h>
#if !defined VRAY_OVERRIDE
#define VRAY_OVERRIDE
#endif
#if VRAY_DLL_VERSION >= 0x30000
#if !defined SHADEVEC_IS_VECTOR3F && !defined SHADEVEC_IS_VECTOR
namespace VUtils {
// This is V-Ray 3.x SDK and we need to define some missing types.
typedef Vector ShadeVec;
typedef Transform ShadeTransform;
typedef Matrix ShadeMatrix;
FORCEINLINE ShadeVec toShadeVec(const Vector& v) { return v; }
FORCEINLINE ShadeVec toShadeVec(const TracePoint &v) { return ShadeVec(v.x, v.y, v.z); }
FORCEINLINE ShadeMatrix toShadeMatrix(const Matrix &m) { return m; }
FORCEINLINE ShadeTransform toShadeTransform(const Transform &m) { return m; }
FORCEINLINE ShadeTransform toShadeTransform(const TraceTransform &m) {
Transform res;
res.m[0]=m.m[0];
res.m[1]=m.m[1];
res.m[2]=m.m[2];
res.offs=ShadeVec(m.offs.x, m.offs.y, m.offs.z);
return res;
}
FORCEINLINE Vector toVector(const ShadeVec& v) { return v; }
FORCEINLINE Color toColor(const ShadeVec& v) { return Color(v.x, v.y, v.z); }
FORCEINLINE Transform toTransform(const ShadeTransform &tm) { return tm; }
FORCEINLINE TraceTransform toTraceTransform(const ShadeTransform &tm) { return TraceTransform(tm); }
FORCEINLINE Matrix toMatrix(const ShadeMatrix &m) { return m; }
FORCEINLINE Transform toTransform(const TraceTransform &tm) {
Transform res;
res.m=tm.m;
res.offs.set(VUtils::real(tm.offs.x), VUtils::real(tm.offs.y), VUtils::real(tm.offs.z));
return res;
}
FORCEINLINE float x(const Vector& v) { return v.x; }
FORCEINLINE float y(const Vector& v) { return v.y; }
FORCEINLINE float z(const Vector& v) { return v.z; }
} // namespace VUtils
#endif // !defined SHADEVEC_IS_VECTOR3F && !defined SHADEVEC_IS_VECTOR
#if !defined SHADECOL_IS_COLOR3F && !defined SHADECOL_IS_COLOR
namespace VUtils {
typedef Color ShadeCol;
typedef AColor ShadeACol;
FORCEINLINE ShadeCol toShadeCol(const Color &col) { return col; }
FORCEINLINE ShadeACol toShadeACol(const AColor &col) { return col; }
FORCEINLINE Color toColor(const ShadeCol &col) { return col; }
FORCEINLINE AColor toAColor(const ShadeACol &col) { return col; }
FORCEINLINE float red(const Color &v) { return v.r; }
FORCEINLINE float green(const Color &v) { return v.g; }
FORCEINLINE float blue(const Color &v) { return v.b; }
FORCEINLINE void setComponent(Color &c, int i, float f) { c[i]=f; }
} // namespace VUtils
#endif // !defined SHADEVEC_IS_VECTOR3F && !defined SHADEVEC_IS_VECTOR
namespace VUtils {
#ifdef VRAY_RAYFLAGS_ARE_64BITS
typedef VUtils::RayFlags VRayRayFlags;
#else
typedef int VRayRayFlags;
const VRayRayFlags RT_NONE=0;
#endif
} // namespace VUtils
#endif // VRAY_DLL_VERSION >= 0x30000
// utility fastfinite functions
namespace VUtils {
#if VRAY_DLL_VERSION >= 0x40000
FORCEINLINE int hasNonFiniteLanes(const Vector &v) {
return v.hasNonFiniteLanes();
}
FORCEINLINE int hasNonFiniteLanes(const Color &v) {
return !(fastfinite(v.r) && fastfinite(v.g) && fastfinite(v.b));
}
FORCEINLINE int hasNonFiniteLanes(const simd::Vector3f &v) {
return v.hasNonFiniteLanes();
}
FORCEINLINE int hasNonFiniteLanes(const simd::Color3f &v) {
return toVector3f(v).hasNonFiniteLanes();
}
FORCEINLINE Vector toVector(const TracePoint &v) {
return v.toVector();
}
#else
FORCEINLINE int hasNonFiniteLanes(const Vector &v) {
return !(fastfinite(v.x) && fastfinite(v.y) && fastfinite(v.z));
}
FORCEINLINE int hasNonFiniteLanes(const Color &v) {
return !(fastfinite(v.r) && fastfinite(v.g) && fastfinite(v.b));
}
FORCEINLINE Vector toVector(const TracePoint &v) {
return Vector(float(v.x), float(v.y), float(v.z));
}
#endif
} // namespace VUtils
#endif // __VRAY3_COMPAT_H__
|