Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/embree/include/embree4/rtcore_geometry.h
9905 views
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include "rtcore_buffer.h"
7
#include "rtcore_quaternion.h"
8
9
RTC_NAMESPACE_BEGIN
10
11
/* Opaque scene type */
12
typedef struct RTCSceneTy* RTCScene;
13
14
/* Opaque geometry type */
15
typedef struct RTCGeometryTy* RTCGeometry;
16
17
/* Types of geometries */
18
enum RTCGeometryType
19
{
20
RTC_GEOMETRY_TYPE_TRIANGLE = 0, // triangle mesh
21
RTC_GEOMETRY_TYPE_QUAD = 1, // quad (triangle pair) mesh
22
RTC_GEOMETRY_TYPE_GRID = 2, // grid mesh
23
24
RTC_GEOMETRY_TYPE_SUBDIVISION = 8, // Catmull-Clark subdivision surface
25
26
RTC_GEOMETRY_TYPE_CONE_LINEAR_CURVE = 15, // Cone linear curves - discontinuous at edge boundaries
27
RTC_GEOMETRY_TYPE_ROUND_LINEAR_CURVE = 16, // Round (rounded cone like) linear curves
28
RTC_GEOMETRY_TYPE_FLAT_LINEAR_CURVE = 17, // flat (ribbon-like) linear curves
29
30
RTC_GEOMETRY_TYPE_ROUND_BEZIER_CURVE = 24, // round (tube-like) Bezier curves
31
RTC_GEOMETRY_TYPE_FLAT_BEZIER_CURVE = 25, // flat (ribbon-like) Bezier curves
32
RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_BEZIER_CURVE = 26, // flat normal-oriented Bezier curves
33
34
RTC_GEOMETRY_TYPE_ROUND_BSPLINE_CURVE = 32, // round (tube-like) B-spline curves
35
RTC_GEOMETRY_TYPE_FLAT_BSPLINE_CURVE = 33, // flat (ribbon-like) B-spline curves
36
RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_BSPLINE_CURVE = 34, // flat normal-oriented B-spline curves
37
38
RTC_GEOMETRY_TYPE_ROUND_HERMITE_CURVE = 40, // round (tube-like) Hermite curves
39
RTC_GEOMETRY_TYPE_FLAT_HERMITE_CURVE = 41, // flat (ribbon-like) Hermite curves
40
RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_HERMITE_CURVE = 42, // flat normal-oriented Hermite curves
41
42
RTC_GEOMETRY_TYPE_SPHERE_POINT = 50,
43
RTC_GEOMETRY_TYPE_DISC_POINT = 51,
44
RTC_GEOMETRY_TYPE_ORIENTED_DISC_POINT = 52,
45
46
RTC_GEOMETRY_TYPE_ROUND_CATMULL_ROM_CURVE = 58, // round (tube-like) Catmull-Rom curves
47
RTC_GEOMETRY_TYPE_FLAT_CATMULL_ROM_CURVE = 59, // flat (ribbon-like) Catmull-Rom curves
48
RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_CATMULL_ROM_CURVE = 60, // flat normal-oriented Catmull-Rom curves
49
50
RTC_GEOMETRY_TYPE_USER = 120, // user-defined geometry
51
RTC_GEOMETRY_TYPE_INSTANCE = 121, // scene instance
52
RTC_GEOMETRY_TYPE_INSTANCE_ARRAY = 122, // scene instance array
53
};
54
55
/* Interpolation modes for subdivision surfaces */
56
enum RTCSubdivisionMode
57
{
58
RTC_SUBDIVISION_MODE_NO_BOUNDARY = 0,
59
RTC_SUBDIVISION_MODE_SMOOTH_BOUNDARY = 1,
60
RTC_SUBDIVISION_MODE_PIN_CORNERS = 2,
61
RTC_SUBDIVISION_MODE_PIN_BOUNDARY = 3,
62
RTC_SUBDIVISION_MODE_PIN_ALL = 4,
63
};
64
65
/* Curve segment flags */
66
enum RTCCurveFlags
67
{
68
RTC_CURVE_FLAG_NEIGHBOR_LEFT = (1 << 0), // left segments exists
69
RTC_CURVE_FLAG_NEIGHBOR_RIGHT = (1 << 1) // right segment exists
70
};
71
72
/* Arguments for RTCBoundsFunction */
73
struct RTCBoundsFunctionArguments
74
{
75
void* geometryUserPtr;
76
unsigned int primID;
77
unsigned int timeStep;
78
struct RTCBounds* bounds_o;
79
};
80
81
/* Bounding callback function */
82
typedef void (*RTCBoundsFunction)(const struct RTCBoundsFunctionArguments* args);
83
84
/* Arguments for RTCIntersectFunctionN */
85
struct RTCIntersectFunctionNArguments
86
{
87
int* valid;
88
void* geometryUserPtr;
89
unsigned int primID;
90
struct RTCRayQueryContext* context;
91
struct RTCRayHitN* rayhit;
92
unsigned int N;
93
unsigned int geomID;
94
};
95
96
/* Arguments for RTCOccludedFunctionN */
97
struct RTCOccludedFunctionNArguments
98
{
99
int* valid;
100
void* geometryUserPtr;
101
unsigned int primID;
102
struct RTCRayQueryContext* context;
103
struct RTCRayN* ray;
104
unsigned int N;
105
unsigned int geomID;
106
};
107
108
/* Arguments for RTCDisplacementFunctionN */
109
struct RTCDisplacementFunctionNArguments
110
{
111
void* geometryUserPtr;
112
RTCGeometry geometry;
113
unsigned int primID;
114
unsigned int timeStep;
115
const float* u;
116
const float* v;
117
const float* Ng_x;
118
const float* Ng_y;
119
const float* Ng_z;
120
float* P_x;
121
float* P_y;
122
float* P_z;
123
unsigned int N;
124
};
125
126
/* Displacement mapping callback function */
127
typedef void (*RTCDisplacementFunctionN)(const struct RTCDisplacementFunctionNArguments* args);
128
129
/* Creates a new geometry of specified type. */
130
RTC_API RTCGeometry rtcNewGeometry(RTCDevice device, enum RTCGeometryType type);
131
132
/* Retains the geometry (increments the reference count). */
133
RTC_API void rtcRetainGeometry(RTCGeometry geometry);
134
135
/* Releases the geometry (decrements the reference count) */
136
RTC_API void rtcReleaseGeometry(RTCGeometry geometry);
137
138
/* Commits the geometry. */
139
RTC_API void rtcCommitGeometry(RTCGeometry geometry);
140
141
142
/* Enables the geometry. */
143
RTC_API void rtcEnableGeometry(RTCGeometry geometry);
144
145
/* Disables the geometry. */
146
RTC_API void rtcDisableGeometry(RTCGeometry geometry);
147
148
149
/* Sets the number of motion blur time steps of the geometry. */
150
RTC_API void rtcSetGeometryTimeStepCount(RTCGeometry geometry, unsigned int timeStepCount);
151
152
/* Sets the motion blur time range of the geometry. */
153
RTC_API void rtcSetGeometryTimeRange(RTCGeometry geometry, float startTime, float endTime);
154
155
/* Sets the number of vertex attributes of the geometry. */
156
RTC_API void rtcSetGeometryVertexAttributeCount(RTCGeometry geometry, unsigned int vertexAttributeCount);
157
158
/* Sets the ray mask of the geometry. */
159
RTC_API void rtcSetGeometryMask(RTCGeometry geometry, unsigned int mask);
160
161
/* Sets the build quality of the geometry. */
162
RTC_API void rtcSetGeometryBuildQuality(RTCGeometry geometry, enum RTCBuildQuality quality);
163
164
/* Sets the maximal curve or point radius scale allowed by min-width feature. */
165
RTC_API void rtcSetGeometryMaxRadiusScale(RTCGeometry geometry, float maxRadiusScale);
166
167
168
/* Sets a geometry buffer. */
169
RTC_API void rtcSetGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, RTCBuffer buffer, size_t byteOffset, size_t byteStride, size_t itemCount);
170
171
/* Sets a shared geometry buffer. */
172
RTC_API void rtcSetSharedGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, const void* ptr, size_t byteOffset, size_t byteStride, size_t itemCount);
173
174
/* Sets a shared host/device geometry buffer pair. */
175
RTC_API void rtcSetSharedGeometryBufferHostDevice(RTCGeometry geometry, enum RTCBufferType bufferType, unsigned int slot, enum RTCFormat format, const void* ptr, const void* dptr, size_t byteOffset, size_t byteStride, size_t itemCount);
176
177
/* Creates and sets a new geometry buffer. */
178
RTC_API void* rtcSetNewGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount);
179
180
/* Creates and sets a new host/device geometry buffer pair. */
181
RTC_API void rtcSetNewGeometryBufferHostDevice(RTCGeometry geometry, enum RTCBufferType bufferType, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount, void** ptr, void** dptr);
182
183
/* Returns the pointer to the data of a buffer. */
184
RTC_API void* rtcGetGeometryBufferData(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot);
185
186
/* Returns a pointer to the buffer data on the device. Returns the same pointer as
187
rtcGetGeometryBufferData if the device is no SYCL device or if Embree is executed on a
188
system with unified memory (e.g., iGPUs). */
189
RTC_API void* rtcGetGeometryBufferDataDevice(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot);
190
191
/* Updates a geometry buffer. */
192
RTC_API void rtcUpdateGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot);
193
194
/* Sets the intersection filter callback function of the geometry. */
195
RTC_API void rtcSetGeometryIntersectFilterFunction(RTCGeometry geometry, RTCFilterFunctionN filter);
196
197
/* Sets the occlusion filter callback function of the geometry. */
198
RTC_API void rtcSetGeometryOccludedFilterFunction(RTCGeometry geometry, RTCFilterFunctionN filter);
199
200
/* Enables argument version of intersection or occlusion filter function. */
201
RTC_API void rtcSetGeometryEnableFilterFunctionFromArguments(RTCGeometry geometry, bool enable);
202
203
/* Sets the user-defined data pointer of the geometry. */
204
RTC_API void rtcSetGeometryUserData(RTCGeometry geometry, void* ptr);
205
206
/* Gets the user-defined data pointer of the geometry. */
207
RTC_API void* rtcGetGeometryUserData(RTCGeometry geometry);
208
209
/* Set the point query callback function of a geometry. */
210
RTC_API void rtcSetGeometryPointQueryFunction(RTCGeometry geometry, RTCPointQueryFunction pointQuery);
211
212
/* Sets the number of primitives of a user geometry. */
213
RTC_API void rtcSetGeometryUserPrimitiveCount(RTCGeometry geometry, unsigned int userPrimitiveCount);
214
215
/* Sets the bounding callback function to calculate bounding boxes for user primitives. */
216
RTC_API void rtcSetGeometryBoundsFunction(RTCGeometry geometry, RTCBoundsFunction bounds, void* userPtr);
217
218
/* Set the intersect callback function of a user geometry. */
219
RTC_API void rtcSetGeometryIntersectFunction(RTCGeometry geometry, RTCIntersectFunctionN intersect);
220
221
/* Set the occlusion callback function of a user geometry. */
222
RTC_API void rtcSetGeometryOccludedFunction(RTCGeometry geometry, RTCOccludedFunctionN occluded);
223
224
/* Invokes the intersection filter from the intersection callback function. */
225
RTC_SYCL_API void rtcInvokeIntersectFilterFromGeometry(const struct RTCIntersectFunctionNArguments* args, const struct RTCFilterFunctionNArguments* filterArgs);
226
227
/* Invokes the occlusion filter from the occlusion callback function. */
228
RTC_SYCL_API void rtcInvokeOccludedFilterFromGeometry(const struct RTCOccludedFunctionNArguments* args, const struct RTCFilterFunctionNArguments* filterArgs);
229
230
/* Sets the instanced scene of an instance geometry. */
231
RTC_API void rtcSetGeometryInstancedScene(RTCGeometry geometry, RTCScene scene);
232
233
/* Sets the instanced scenes of an instance array geometry. */
234
RTC_API void rtcSetGeometryInstancedScenes(RTCGeometry geometry, RTCScene* scenes, size_t numScenes);
235
236
/* Sets the transformation of an instance for the specified time step. */
237
RTC_API void rtcSetGeometryTransform(RTCGeometry geometry, unsigned int timeStep, enum RTCFormat format, const void* xfm);
238
239
/* Sets the transformation quaternion of an instance for the specified time step. */
240
RTC_API void rtcSetGeometryTransformQuaternion(RTCGeometry geometry, unsigned int timeStep, const struct RTCQuaternionDecomposition* qd);
241
242
/* Returns the interpolated transformation of an instance for the specified time. */
243
RTC_API void rtcGetGeometryTransform(RTCGeometry geometry, float time, enum RTCFormat format, void* xfm);
244
245
/*
246
* Returns the interpolated transformation of the instPrimID'th instance of an
247
* instance array for the specified time. If geometry is an regular instance,
248
* instPrimID must be 0.
249
*/
250
RTC_API void rtcGetGeometryTransformEx(RTCGeometry geometry, unsigned int instPrimID, float time, enum RTCFormat format, void* xfm);
251
252
/* Sets the uniform tessellation rate of the geometry. */
253
RTC_API void rtcSetGeometryTessellationRate(RTCGeometry geometry, float tessellationRate);
254
255
/* Sets the number of topologies of a subdivision surface. */
256
RTC_API void rtcSetGeometryTopologyCount(RTCGeometry geometry, unsigned int topologyCount);
257
258
/* Sets the subdivision interpolation mode. */
259
RTC_API void rtcSetGeometrySubdivisionMode(RTCGeometry geometry, unsigned int topologyID, enum RTCSubdivisionMode mode);
260
261
/* Binds a vertex attribute to a topology of the geometry. */
262
RTC_API void rtcSetGeometryVertexAttributeTopology(RTCGeometry geometry, unsigned int vertexAttributeID, unsigned int topologyID);
263
264
/* Sets the displacement callback function of a subdivision surface. */
265
RTC_API void rtcSetGeometryDisplacementFunction(RTCGeometry geometry, RTCDisplacementFunctionN displacement);
266
267
/* Returns the first half edge of a face. */
268
RTC_API unsigned int rtcGetGeometryFirstHalfEdge(RTCGeometry geometry, unsigned int faceID);
269
270
/* Returns the face the half edge belongs to. */
271
RTC_API unsigned int rtcGetGeometryFace(RTCGeometry geometry, unsigned int edgeID);
272
273
/* Returns next half edge. */
274
RTC_API unsigned int rtcGetGeometryNextHalfEdge(RTCGeometry geometry, unsigned int edgeID);
275
276
/* Returns previous half edge. */
277
RTC_API unsigned int rtcGetGeometryPreviousHalfEdge(RTCGeometry geometry, unsigned int edgeID);
278
279
/* Returns opposite half edge. */
280
RTC_API unsigned int rtcGetGeometryOppositeHalfEdge(RTCGeometry geometry, unsigned int topologyID, unsigned int edgeID);
281
282
283
/* Arguments for rtcInterpolate */
284
struct RTCInterpolateArguments
285
{
286
RTCGeometry geometry;
287
unsigned int primID;
288
float u;
289
float v;
290
enum RTCBufferType bufferType;
291
unsigned int bufferSlot;
292
float* P;
293
float* dPdu;
294
float* dPdv;
295
float* ddPdudu;
296
float* ddPdvdv;
297
float* ddPdudv;
298
unsigned int valueCount;
299
};
300
301
/* Interpolates vertex data to some u/v location and optionally calculates all derivatives. */
302
RTC_API void rtcInterpolate(const struct RTCInterpolateArguments* args);
303
304
/* Interpolates vertex data to some u/v location. */
305
RTC_FORCEINLINE void rtcInterpolate0(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float* P, unsigned int valueCount)
306
{
307
struct RTCInterpolateArguments args;
308
args.geometry = geometry;
309
args.primID = primID;
310
args.u = u;
311
args.v = v;
312
args.bufferType = bufferType;
313
args.bufferSlot = bufferSlot;
314
args.P = P;
315
args.dPdu = NULL;
316
args.dPdv = NULL;
317
args.ddPdudu = NULL;
318
args.ddPdvdv = NULL;
319
args.ddPdudv = NULL;
320
args.valueCount = valueCount;
321
rtcInterpolate(&args);
322
}
323
324
/* Interpolates vertex data to some u/v location and calculates first order derivatives. */
325
RTC_FORCEINLINE void rtcInterpolate1(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot,
326
float* P, float* dPdu, float* dPdv, unsigned int valueCount)
327
{
328
struct RTCInterpolateArguments args;
329
args.geometry = geometry;
330
args.primID = primID;
331
args.u = u;
332
args.v = v;
333
args.bufferType = bufferType;
334
args.bufferSlot = bufferSlot;
335
args.P = P;
336
args.dPdu = dPdu;
337
args.dPdv = dPdv;
338
args.ddPdudu = NULL;
339
args.ddPdvdv = NULL;
340
args.ddPdudv = NULL;
341
args.valueCount = valueCount;
342
rtcInterpolate(&args);
343
}
344
345
/* Interpolates vertex data to some u/v location and calculates first and second order derivatives. */
346
RTC_FORCEINLINE void rtcInterpolate2(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot,
347
float* P, float* dPdu, float* dPdv, float* ddPdudu, float* ddPdvdv, float* ddPdudv, unsigned int valueCount)
348
{
349
struct RTCInterpolateArguments args;
350
args.geometry = geometry;
351
args.primID = primID;
352
args.u = u;
353
args.v = v;
354
args.bufferType = bufferType;
355
args.bufferSlot = bufferSlot;
356
args.P = P;
357
args.dPdu = dPdu;
358
args.dPdv = dPdv;
359
args.ddPdudu = ddPdudu;
360
args.ddPdvdv = ddPdvdv;
361
args.ddPdudv = ddPdudv;
362
args.valueCount = valueCount;
363
rtcInterpolate(&args);
364
}
365
366
/* Arguments for rtcInterpolateN */
367
struct RTCInterpolateNArguments
368
{
369
RTCGeometry geometry;
370
const void* valid;
371
const unsigned int* primIDs;
372
const float* u;
373
const float* v;
374
unsigned int N;
375
enum RTCBufferType bufferType;
376
unsigned int bufferSlot;
377
float* P;
378
float* dPdu;
379
float* dPdv;
380
float* ddPdudu;
381
float* ddPdvdv;
382
float* ddPdudv;
383
unsigned int valueCount;
384
};
385
386
/* Interpolates vertex data to an array of u/v locations. */
387
RTC_API void rtcInterpolateN(const struct RTCInterpolateNArguments* args);
388
389
/* RTCGrid primitive for grid mesh */
390
struct RTCGrid
391
{
392
unsigned int startVertexID;
393
unsigned int stride;
394
unsigned short width,height; // max is a 32k x 32k grid
395
};
396
397
RTC_NAMESPACE_END
398
399
400
401