HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
rtcore_common.h
Go to the documentation of this file.
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include <stddef.h>
7
#include <sys/types.h>
8
#include <stdbool.h>
9
10
#include "
rtcore_config.h
"
11
12
RTC_NAMESPACE_BEGIN
13
14
#if defined(_WIN32)
15
#if defined(_M_X64)
16
typedef
long
long
ssize_t;
17
#else
18
typedef
int
ssize_t;
19
#endif
20
#endif
21
22
#ifdef _WIN32
23
# define RTC_ALIGN(...) __declspec(align(__VA_ARGS__))
24
#else
25
# define RTC_ALIGN(...) __attribute__((aligned(__VA_ARGS__)))
26
#endif
27
28
#if !defined (RTC_DEPRECATED)
29
#ifdef __GNUC__
30
#define RTC_DEPRECATED __attribute__((deprecated))
31
#elif defined(_MSC_VER)
32
#define RTC_DEPRECATED __declspec(deprecated)
33
#else
34
#define RTC_DEPRECATED
35
#endif
36
#endif
37
38
#if defined(_WIN32)
39
# define RTC_FORCEINLINE __forceinline
40
#else
41
# define RTC_FORCEINLINE inline __attribute__((always_inline))
42
#endif
43
44
/* Invalid geometry ID */
45
#define RTC_INVALID_GEOMETRY_ID ((unsigned int)-1)
46
47
/* Maximum number of time steps */
48
#define RTC_MAX_TIME_STEP_COUNT 129
49
50
/* Formats of buffers and other data structures */
51
enum
RTCFormat
52
{
53
RTC_FORMAT_UNDEFINED
= 0,
54
55
/* 8-bit unsigned integer */
56
RTC_FORMAT_UCHAR
= 0x1001,
57
RTC_FORMAT_UCHAR2
,
58
RTC_FORMAT_UCHAR3
,
59
RTC_FORMAT_UCHAR4
,
60
61
/* 8-bit signed integer */
62
RTC_FORMAT_CHAR
= 0x2001,
63
RTC_FORMAT_CHAR2
,
64
RTC_FORMAT_CHAR3
,
65
RTC_FORMAT_CHAR4
,
66
67
/* 16-bit unsigned integer */
68
RTC_FORMAT_USHORT
= 0x3001,
69
RTC_FORMAT_USHORT2
,
70
RTC_FORMAT_USHORT3
,
71
RTC_FORMAT_USHORT4
,
72
73
/* 16-bit signed integer */
74
RTC_FORMAT_SHORT
= 0x4001,
75
RTC_FORMAT_SHORT2
,
76
RTC_FORMAT_SHORT3
,
77
RTC_FORMAT_SHORT4
,
78
79
/* 32-bit unsigned integer */
80
RTC_FORMAT_UINT
= 0x5001,
81
RTC_FORMAT_UINT2
,
82
RTC_FORMAT_UINT3
,
83
RTC_FORMAT_UINT4
,
84
85
/* 32-bit signed integer */
86
RTC_FORMAT_INT
= 0x6001,
87
RTC_FORMAT_INT2
,
88
RTC_FORMAT_INT3
,
89
RTC_FORMAT_INT4
,
90
91
/* 64-bit unsigned integer */
92
RTC_FORMAT_ULLONG
= 0x7001,
93
RTC_FORMAT_ULLONG2
,
94
RTC_FORMAT_ULLONG3
,
95
RTC_FORMAT_ULLONG4
,
96
97
/* 64-bit signed integer */
98
RTC_FORMAT_LLONG
= 0x8001,
99
RTC_FORMAT_LLONG2
,
100
RTC_FORMAT_LLONG3
,
101
RTC_FORMAT_LLONG4
,
102
103
/* 32-bit float */
104
RTC_FORMAT_FLOAT
= 0x9001,
105
RTC_FORMAT_FLOAT2
,
106
RTC_FORMAT_FLOAT3
,
107
RTC_FORMAT_FLOAT4
,
108
RTC_FORMAT_FLOAT5
,
109
RTC_FORMAT_FLOAT6
,
110
RTC_FORMAT_FLOAT7
,
111
RTC_FORMAT_FLOAT8
,
112
RTC_FORMAT_FLOAT9
,
113
RTC_FORMAT_FLOAT10
,
114
RTC_FORMAT_FLOAT11
,
115
RTC_FORMAT_FLOAT12
,
116
RTC_FORMAT_FLOAT13
,
117
RTC_FORMAT_FLOAT14
,
118
RTC_FORMAT_FLOAT15
,
119
RTC_FORMAT_FLOAT16
,
120
121
/* 32-bit float matrix (row-major order) */
122
RTC_FORMAT_FLOAT2X2_ROW_MAJOR
= 0x9122,
123
RTC_FORMAT_FLOAT2X3_ROW_MAJOR
= 0x9123,
124
RTC_FORMAT_FLOAT2X4_ROW_MAJOR
= 0x9124,
125
RTC_FORMAT_FLOAT3X2_ROW_MAJOR
= 0x9132,
126
RTC_FORMAT_FLOAT3X3_ROW_MAJOR
= 0x9133,
127
RTC_FORMAT_FLOAT3X4_ROW_MAJOR
= 0x9134,
128
RTC_FORMAT_FLOAT4X2_ROW_MAJOR
= 0x9142,
129
RTC_FORMAT_FLOAT4X3_ROW_MAJOR
= 0x9143,
130
RTC_FORMAT_FLOAT4X4_ROW_MAJOR
= 0x9144,
131
132
/* 32-bit float matrix (column-major order) */
133
RTC_FORMAT_FLOAT2X2_COLUMN_MAJOR
= 0x9222,
134
RTC_FORMAT_FLOAT2X3_COLUMN_MAJOR
= 0x9223,
135
RTC_FORMAT_FLOAT2X4_COLUMN_MAJOR
= 0x9224,
136
RTC_FORMAT_FLOAT3X2_COLUMN_MAJOR
= 0x9232,
137
RTC_FORMAT_FLOAT3X3_COLUMN_MAJOR
= 0x9233,
138
RTC_FORMAT_FLOAT3X4_COLUMN_MAJOR
= 0x9234,
139
RTC_FORMAT_FLOAT4X2_COLUMN_MAJOR
= 0x9242,
140
RTC_FORMAT_FLOAT4X3_COLUMN_MAJOR
= 0x9243,
141
RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR
= 0x9244,
142
143
/* special 12-byte format for grids */
144
RTC_FORMAT_GRID
= 0xA001
145
};
146
147
/* Build quality levels */
148
enum
RTCBuildQuality
149
{
150
RTC_BUILD_QUALITY_LOW
= 0,
151
RTC_BUILD_QUALITY_MEDIUM
= 1,
152
RTC_BUILD_QUALITY_HIGH
= 2,
153
RTC_BUILD_QUALITY_REFIT
= 3,
154
};
155
156
/* Axis-aligned bounding box representation */
157
struct
RTC_ALIGN
(16) RTCBounds
158
{
159
float
lower_x, lower_y, lower_z, align0;
160
float
upper_x, upper_y, upper_z, align1;
161
};
162
163
/* Linear axis-aligned bounding box representation */
164
struct
RTC_ALIGN
(16) RTCLinearBounds
165
{
166
struct
RTCBounds bounds0;
167
struct
RTCBounds bounds1;
168
};
169
170
/* Intersection context flags */
171
enum
RTCIntersectContextFlags
172
{
173
RTC_INTERSECT_CONTEXT_FLAG_NONE
= 0,
174
RTC_INTERSECT_CONTEXT_FLAG_INCOHERENT
= (0 << 0),
// optimize for incoherent rays
175
RTC_INTERSECT_CONTEXT_FLAG_COHERENT
= (1 << 0)
// optimize for coherent rays
176
};
177
178
/* Arguments for RTCFilterFunctionN */
179
struct
RTCFilterFunctionNArguments
180
{
181
int
*
valid
;
182
void
*
geometryUserPtr
;
183
struct
RTCIntersectContext
*
context
;
184
struct
RTCRayN*
ray
;
185
struct
RTCHitN*
hit
;
186
unsigned
int
N
;
187
};
188
189
/* Filter callback function */
190
typedef
void
(*
RTCFilterFunctionN
)(
const
struct
RTCFilterFunctionNArguments
*
args
);
191
192
/* Intersection context passed to intersect/occluded calls */
193
struct
RTCIntersectContext
194
{
195
enum
RTCIntersectContextFlags
flags
;
// intersection flags
196
RTCFilterFunctionN
filter
;
// filter function to execute
197
198
#if RTC_MAX_INSTANCE_LEVEL_COUNT > 1
199
unsigned
int
instStackSize
;
// Number of instances currently on the stack.
200
#endif
201
unsigned
int
instID
[
RTC_MAX_INSTANCE_LEVEL_COUNT
];
// The current stack of instance ids.
202
203
#if RTC_MIN_WIDTH
204
float
minWidthDistanceFactor;
// curve radius is set to this factor times distance to ray origin
205
#endif
206
};
207
208
/* Initializes an intersection context. */
209
RTC_FORCEINLINE
void
rtcInitIntersectContext
(
struct
RTCIntersectContext
* context)
210
{
211
unsigned
l = 0;
212
context->
flags
=
RTC_INTERSECT_CONTEXT_FLAG_INCOHERENT
;
213
context->
filter
= NULL;
214
215
#if RTC_MAX_INSTANCE_LEVEL_COUNT > 1
216
context->
instStackSize
= 0;
217
#endif
218
for
(; l <
RTC_MAX_INSTANCE_LEVEL_COUNT
; ++l)
219
context->
instID
[l] =
RTC_INVALID_GEOMETRY_ID
;
220
221
#
if
RTC_MIN_WIDTH
222
context->minWidthDistanceFactor = 0.0f;
223
#endif
224
}
225
226
/* Point query structure for closest point query */
227
struct
RTC_ALIGN
(16) RTCPointQuery
228
{
229
float
x
;
// x coordinate of the query point
230
float
y
;
// y coordinate of the query point
231
float
z
;
// z coordinate of the query point
232
float
time
;
// time of the point query
233
float
radius;
// radius of the point query
234
};
235
236
/* Structure of a packet of 4 query points */
237
struct
RTC_ALIGN
(16) RTCPointQuery4
238
{
239
float
x
[4];
// x coordinate of the query point
240
float
y
[4];
// y coordinate of the query point
241
float
z
[4];
// z coordinate of the query point
242
float
time
[4];
// time of the point query
243
float
radius[4];
// radius of the point query
244
};
245
246
/* Structure of a packet of 8 query points */
247
struct
RTC_ALIGN
(32) RTCPointQuery8
248
{
249
float
x
[8];
// x coordinate of the query point
250
float
y
[8];
// y coordinate of the query point
251
float
z
[8];
// z coordinate of the query point
252
float
time
[8];
// time of the point query
253
float
radius[8];
// radius ofr the point query
254
};
255
256
/* Structure of a packet of 16 query points */
257
struct
RTC_ALIGN
(64) RTCPointQuery16
258
{
259
float
x
[16];
// x coordinate of the query point
260
float
y
[16];
// y coordinate of the query point
261
float
z
[16];
// z coordinate of the query point
262
float
time
[16];
// time of the point quey
263
float
radius[16];
// radius of the point query
264
};
265
266
struct
RTCPointQueryN;
267
268
struct
RTC_ALIGN
(16) RTCPointQueryContext
269
{
270
// accumulated 4x4 column major matrices from world space to instance space.
271
// undefined if size == 0.
272
float
world2inst[
RTC_MAX_INSTANCE_LEVEL_COUNT
][16];
273
274
// accumulated 4x4 column major matrices from instance space to world space.
275
// undefined if size == 0.
276
float
inst2world[
RTC_MAX_INSTANCE_LEVEL_COUNT
][16];
277
278
// instance ids.
279
unsigned
int
instID[
RTC_MAX_INSTANCE_LEVEL_COUNT
];
280
281
// number of instances currently on the stack.
282
unsigned
int
instStackSize;
283
};
284
285
/* Initializes an intersection context. */
286
RTC_FORCEINLINE
void
rtcInitPointQueryContext
(
struct
RTCPointQueryContext* context)
287
{
288
context->instStackSize = 0;
289
context->instID[0] =
RTC_INVALID_GEOMETRY_ID
;
290
}
291
292
struct
RTC_ALIGN
(16) RTCPointQueryFunctionArguments
293
{
294
// The (world space) query object that was passed as an argument of rtcPointQuery. The
295
// radius of the query can be decreased inside the callback to shrink the
296
// search domain. Increasing the radius or modifying the time or position of
297
// the query results in undefined behaviour.
298
struct
RTCPointQuery*
query
;
299
300
// Used for user input/output data. Will not be read or modified internally.
301
void
* userPtr;
302
303
// primitive and geometry ID of primitive
304
unsigned
int
primID;
305
unsigned
int
geomID;
306
307
// the context with transformation and instance ID stack
308
struct
RTCPointQueryContext* context;
309
310
// If the current instance transform M (= context->world2inst[context->instStackSize])
311
// is a similarity matrix, i.e there is a constant factor similarityScale such that,
312
// for all x,y: dist(Mx, My) = similarityScale * dist(x, y),
313
// The similarity scale is 0, if the current instance transform is not a
314
// similarity transform and vice versa. The similarity scale allows to compute
315
// distance information in instance space and scale the distances into world
316
// space by dividing with the similarity scale, for example, to update the
317
// query radius. If the current instance transform is not a similarity
318
// transform (similarityScale = 0), the distance computation has to be
319
// performed in world space to ensure correctness. if there is no instance
320
// transform (context->instStackSize == 0), the similarity scale is 1.
321
float
similarityScale;
322
};
323
324
typedef
bool (*
RTCPointQueryFunction
)(
struct
RTCPointQueryFunctionArguments*
args
);
325
326
RTC_NAMESPACE_END
RTC_MIN_WIDTH
#define RTC_MIN_WIDTH
Definition:
rtcore_config.h:15
rtcore_config.h
query
GLenum query
Definition:
glad.h:2772
RTC_FORMAT_UCHAR3
Definition:
rtcore_common.h:58
RTC_FORMAT_FLOAT6
Definition:
rtcore_common.h:109
RTC_INTERSECT_CONTEXT_FLAG_COHERENT
Definition:
rtcore_common.h:175
RTC_FORMAT_FLOAT10
Definition:
rtcore_common.h:113
RTC_FORMAT_FLOAT2X4_ROW_MAJOR
Definition:
rtcore_common.h:124
RTC_FORMAT_FLOAT4X2_ROW_MAJOR
Definition:
rtcore_common.h:128
RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR
Definition:
rtcore_common.h:141
RTC_FORMAT_INT
Definition:
rtcore_common.h:86
RTCFilterFunctionNArguments::valid
int * valid
Definition:
rtcore_common.h:181
RTC_FORMAT_FLOAT3X2_COLUMN_MAJOR
Definition:
rtcore_common.h:136
void
void
Definition:
png.h:1083
RTC_FORMAT_UCHAR2
Definition:
rtcore_common.h:57
GT_Names::time
GT_API const UT_StringHolder time
RTC_FORMAT_FLOAT3X4_ROW_MAJOR
Definition:
rtcore_common.h:127
RTC_FORMAT_FLOAT3X4_COLUMN_MAJOR
Definition:
rtcore_common.h:138
RTC_FORMAT_ULLONG4
Definition:
rtcore_common.h:95
RTC_BUILD_QUALITY_MEDIUM
Definition:
rtcore_common.h:151
RTC_FORMAT_FLOAT16
Definition:
rtcore_common.h:119
z
GLdouble GLdouble GLdouble z
Definition:
glcorearb.h:848
RTC_FORMAT_SHORT4
Definition:
rtcore_common.h:77
RTC_FORMAT_INT4
Definition:
rtcore_common.h:89
RTC_FORMAT_USHORT3
Definition:
rtcore_common.h:70
RTC_FORMAT_UINT2
Definition:
rtcore_common.h:81
RTC_FORMAT_FLOAT4X2_COLUMN_MAJOR
Definition:
rtcore_common.h:139
RTC_FORMAT_UCHAR4
Definition:
rtcore_common.h:59
RTC_FORMAT_FLOAT2X3_COLUMN_MAJOR
Definition:
rtcore_common.h:134
RTC_BUILD_QUALITY_HIGH
Definition:
rtcore_common.h:152
RTCFilterFunctionNArguments::N
unsigned int N
Definition:
rtcore_common.h:186
RTC_FORMAT_ULLONG2
Definition:
rtcore_common.h:93
RTCIntersectContext
Definition:
rtcore_common.h:193
RTC_FORMAT_UCHAR
Definition:
rtcore_common.h:56
RTC_FORMAT_FLOAT2X2_COLUMN_MAJOR
Definition:
rtcore_common.h:133
y
GLint y
Definition:
glcorearb.h:103
RTC_FORCEINLINE
#define RTC_FORCEINLINE
Definition:
rtcore_common.h:41
RTC_FORMAT_ULLONG3
Definition:
rtcore_common.h:94
RTC_FORMAT_CHAR2
Definition:
rtcore_common.h:63
RTCFilterFunctionNArguments::context
struct RTCIntersectContext * context
Definition:
rtcore_common.h:183
RTC_FORMAT_FLOAT4X4_ROW_MAJOR
Definition:
rtcore_common.h:130
RTCBuildQuality
RTCBuildQuality
Definition:
rtcore_common.h:148
RTCFilterFunctionNArguments::geometryUserPtr
void * geometryUserPtr
Definition:
rtcore_common.h:182
RTCFilterFunctionNArguments
Definition:
rtcore_common.h:179
RTC_INVALID_GEOMETRY_ID
#define RTC_INVALID_GEOMETRY_ID
Definition:
rtcore_common.h:45
RTC_FORMAT_UINT4
Definition:
rtcore_common.h:83
RTC_FORMAT_LLONG3
Definition:
rtcore_common.h:100
RTC_ALIGN
#define RTC_ALIGN(...)
Definition:
rtcore_common.h:25
RTCIntersectContext::flags
enum RTCIntersectContextFlags flags
Definition:
rtcore_common.h:195
RTCFilterFunctionNArguments::hit
struct RTCHitN * hit
Definition:
rtcore_common.h:185
RTC_FORMAT_USHORT4
Definition:
rtcore_common.h:71
rtcInitPointQueryContext
RTC_FORCEINLINE void rtcInitPointQueryContext(struct RTCPointQueryContext *context)
Definition:
rtcore_common.h:286
RTC_FORMAT_FLOAT4X3_ROW_MAJOR
Definition:
rtcore_common.h:129
RTC_BUILD_QUALITY_REFIT
Definition:
rtcore_common.h:153
RTC_FORMAT_FLOAT13
Definition:
rtcore_common.h:116
RTC_FORMAT_FLOAT3
Definition:
rtcore_common.h:106
RTC_FORMAT_FLOAT7
Definition:
rtcore_common.h:110
RTC_FORMAT_FLOAT12
Definition:
rtcore_common.h:115
RTC_FORMAT_LLONG4
Definition:
rtcore_common.h:101
RTCFilterFunctionN
void(* RTCFilterFunctionN)(const struct RTCFilterFunctionNArguments *args)
Definition:
rtcore_common.h:190
RTC_INTERSECT_CONTEXT_FLAG_NONE
Definition:
rtcore_common.h:173
RTCIntersectContextFlags
RTCIntersectContextFlags
Definition:
rtcore_common.h:171
RTC_FORMAT_CHAR4
Definition:
rtcore_common.h:65
RTC_FORMAT_FLOAT3X3_ROW_MAJOR
Definition:
rtcore_common.h:126
RTC_FORMAT_FLOAT5
Definition:
rtcore_common.h:108
RTC_FORMAT_FLOAT15
Definition:
rtcore_common.h:118
RTC_INTERSECT_CONTEXT_FLAG_INCOHERENT
Definition:
rtcore_common.h:174
RTC_FORMAT_SHORT3
Definition:
rtcore_common.h:76
RTC_FORMAT_LLONG
Definition:
rtcore_common.h:98
RTC_MAX_INSTANCE_LEVEL_COUNT
#define RTC_MAX_INSTANCE_LEVEL_COUNT
Definition:
rtcore_config.h:12
x
GLint GLenum GLint x
Definition:
glcorearb.h:409
RTC_FORMAT_FLOAT2X4_COLUMN_MAJOR
Definition:
rtcore_common.h:135
RTC_FORMAT_FLOAT14
Definition:
rtcore_common.h:117
RTC_FORMAT_FLOAT4X3_COLUMN_MAJOR
Definition:
rtcore_common.h:140
RTC_FORMAT_USHORT2
Definition:
rtcore_common.h:69
RTC_FORMAT_USHORT
Definition:
rtcore_common.h:68
RTC_FORMAT_INT2
Definition:
rtcore_common.h:87
RTC_FORMAT_FLOAT4
Definition:
rtcore_common.h:107
RTC_FORMAT_UINT
Definition:
rtcore_common.h:80
RTC_NAMESPACE_END
#define RTC_NAMESPACE_END
Definition:
rtcore_config.h:23
rtcInitIntersectContext
RTC_FORCEINLINE void rtcInitIntersectContext(struct RTCIntersectContext *context)
Definition:
rtcore_common.h:209
RTC_FORMAT_UINT3
Definition:
rtcore_common.h:82
RTC_FORMAT_CHAR3
Definition:
rtcore_common.h:64
RTC_FORMAT_FLOAT3X2_ROW_MAJOR
Definition:
rtcore_common.h:125
RTC_FORMAT_CHAR
Definition:
rtcore_common.h:62
RTC_FORMAT_FLOAT8
Definition:
rtcore_common.h:111
RTC_FORMAT_FLOAT2X3_ROW_MAJOR
Definition:
rtcore_common.h:123
RTC_FORMAT_FLOAT11
Definition:
rtcore_common.h:114
RTC_FORMAT_UNDEFINED
Definition:
rtcore_common.h:53
RTC_FORMAT_INT3
Definition:
rtcore_common.h:88
RTC_FORMAT_GRID
Definition:
rtcore_common.h:144
RTC_FORMAT_FLOAT2X2_ROW_MAJOR
Definition:
rtcore_common.h:122
RTC_FORMAT_FLOAT
Definition:
rtcore_common.h:104
RTCIntersectContext::instStackSize
unsigned int instStackSize
Definition:
rtcore_common.h:199
RTC_FORMAT_ULLONG
Definition:
rtcore_common.h:92
args
**If you just want to fire and args
Definition:
thread.h:609
RTCIntersectContext::instID
unsigned int instID[RTC_MAX_INSTANCE_LEVEL_COUNT]
Definition:
rtcore_common.h:201
RTCFormat
RTCFormat
Definition:
rtcore_common.h:51
RTC_FORMAT_FLOAT3X3_COLUMN_MAJOR
Definition:
rtcore_common.h:137
RTC_FORMAT_FLOAT2
Definition:
rtcore_common.h:105
RTC_FORMAT_SHORT
Definition:
rtcore_common.h:74
RTC_FORMAT_LLONG2
Definition:
rtcore_common.h:99
RTCFilterFunctionNArguments::ray
struct RTCRayN * ray
Definition:
rtcore_common.h:184
RTC_FORMAT_FLOAT9
Definition:
rtcore_common.h:112
RTCPointQueryFunction
bool(* RTCPointQueryFunction)(struct RTCPointQueryFunctionArguments *args)
Definition:
rtcore_common.h:324
RTCIntersectContext::filter
RTCFilterFunctionN filter
Definition:
rtcore_common.h:196
RTC_BUILD_QUALITY_LOW
Definition:
rtcore_common.h:150
RTC_NAMESPACE_BEGIN
#define RTC_NAMESPACE_BEGIN
Definition:
rtcore_config.h:22
RTC_FORMAT_SHORT2
Definition:
rtcore_common.h:75
embree3
rtcore_common.h
Generated on Sun Nov 17 2024 03:01:08 for HDK by
1.8.6