HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rtcore_geometry.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 "rtcore_buffer.h"
7 #include "rtcore_quaternion.h"
8 
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 */
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 
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 };
53 
54 /* Interpolation modes for subdivision surfaces */
56 {
62 };
63 
64 /* Curve segment flags */
66 {
67  RTC_CURVE_FLAG_NEIGHBOR_LEFT = (1 << 0), // left segments exists
68  RTC_CURVE_FLAG_NEIGHBOR_RIGHT = (1 << 1) // right segment exists
69 };
70 
71 /* Arguments for RTCBoundsFunction */
73 {
75  unsigned int primID;
76  unsigned int timeStep;
77  struct RTCBounds* bounds_o;
78 };
79 
80 /* Bounding callback function */
82 
83 /* Arguments for RTCIntersectFunctionN */
85 {
86  int* valid;
88  unsigned int primID;
90  struct RTCRayHitN* rayhit;
91  unsigned int N;
92  unsigned int geomID;
93 };
94 
95 /* Intersection callback function */
97 
98 /* Arguments for RTCOccludedFunctionN */
100 {
101  int* valid;
103  unsigned int primID;
105  struct RTCRayN* ray;
106  unsigned int N;
107  unsigned int geomID;
108 };
109 
110 /* Occlusion callback function */
112 
113 /* Arguments for RTCDisplacementFunctionN */
115 {
118  unsigned int primID;
119  unsigned int timeStep;
120  const float* u;
121  const float* v;
122  const float* Ng_x;
123  const float* Ng_y;
124  const float* Ng_z;
125  float* P_x;
126  float* P_y;
127  float* P_z;
128  unsigned int N;
129 };
130 
131 /* Displacement mapping callback function */
133 
134 /* Creates a new geometry of specified type. */
136 
137 /* Retains the geometry (increments the reference count). */
139 
140 /* Releases the geometry (decrements the reference count) */
142 
143 /* Commits the geometry. */
145 
146 
147 /* Enables the geometry. */
149 
150 /* Disables the geometry. */
152 
153 
154 /* Sets the number of motion blur time steps of the geometry. */
155 RTC_API void rtcSetGeometryTimeStepCount(RTCGeometry geometry, unsigned int timeStepCount);
156 
157 /* Sets the motion blur time range of the geometry. */
158 RTC_API void rtcSetGeometryTimeRange(RTCGeometry geometry, float startTime, float endTime);
159 
160 /* Sets the number of vertex attributes of the geometry. */
161 RTC_API void rtcSetGeometryVertexAttributeCount(RTCGeometry geometry, unsigned int vertexAttributeCount);
162 
163 /* Sets the ray mask of the geometry. */
165 
166 /* Sets the build quality of the geometry. */
168 
169 /* Sets the maximal curve or point radius scale allowed by min-width feature. */
170 RTC_API void rtcSetGeometryMaxRadiusScale(RTCGeometry geometry, float maxRadiusScale);
171 
172 
173 /* Sets a geometry buffer. */
174 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);
175 
176 /* Sets a shared geometry buffer. */
177 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);
178 
179 /* Creates and sets a new geometry buffer. */
180 RTC_API void* rtcSetNewGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount);
181 
182 /* Returns the pointer to the data of a buffer. */
184 
185 /* Updates a geometry buffer. */
187 
188 
189 /* Sets the intersection filter callback function of the geometry. */
191 
192 /* Sets the occlusion filter callback function of the geometry. */
194 
195 /* Sets the user-defined data pointer of the geometry. */
197 
198 /* Gets the user-defined data pointer of the geometry. */
200 
201 /* Set the point query callback function of a geometry. */
203 
204 /* Sets the number of primitives of a user geometry. */
205 RTC_API void rtcSetGeometryUserPrimitiveCount(RTCGeometry geometry, unsigned int userPrimitiveCount);
206 
207 /* Sets the bounding callback function to calculate bounding boxes for user primitives. */
209 
210 /* Set the intersect callback function of a user geometry. */
212 
213 /* Set the occlusion callback function of a user geometry. */
215 
216 /* Invokes the intersection filter from the intersection callback function. */
218 
219 /* Invokes the occlusion filter from the occlusion callback function. */
220 RTC_API void rtcFilterOcclusion(const struct RTCOccludedFunctionNArguments* args, const struct RTCFilterFunctionNArguments* filterArgs);
221 
222 
223 /* Sets the instanced scene of an instance geometry. */
225 
226 /* Sets the transformation of an instance for the specified time step. */
227 RTC_API void rtcSetGeometryTransform(RTCGeometry geometry, unsigned int timeStep, enum RTCFormat format, const void* xfm);
228 
229 /* Sets the transformation quaternion of an instance for the specified time step. */
230 RTC_API void rtcSetGeometryTransformQuaternion(RTCGeometry geometry, unsigned int timeStep, const struct RTCQuaternionDecomposition* qd);
231 
232 /* Returns the interpolated transformation of an instance for the specified time. */
234 
235 
236 /* Sets the uniform tessellation rate of the geometry. */
237 RTC_API void rtcSetGeometryTessellationRate(RTCGeometry geometry, float tessellationRate);
238 
239 /* Sets the number of topologies of a subdivision surface. */
240 RTC_API void rtcSetGeometryTopologyCount(RTCGeometry geometry, unsigned int topologyCount);
241 
242 /* Sets the subdivision interpolation mode. */
244 
245 /* Binds a vertex attribute to a topology of the geometry. */
246 RTC_API void rtcSetGeometryVertexAttributeTopology(RTCGeometry geometry, unsigned int vertexAttributeID, unsigned int topologyID);
247 
248 /* Sets the displacement callback function of a subdivision surface. */
250 
251 /* Returns the first half edge of a face. */
252 RTC_API unsigned int rtcGetGeometryFirstHalfEdge(RTCGeometry geometry, unsigned int faceID);
253 
254 /* Returns the face the half edge belongs to. */
255 RTC_API unsigned int rtcGetGeometryFace(RTCGeometry geometry, unsigned int edgeID);
256 
257 /* Returns next half edge. */
258 RTC_API unsigned int rtcGetGeometryNextHalfEdge(RTCGeometry geometry, unsigned int edgeID);
259 
260 /* Returns previous half edge. */
261 RTC_API unsigned int rtcGetGeometryPreviousHalfEdge(RTCGeometry geometry, unsigned int edgeID);
262 
263 /* Returns opposite half edge. */
264 RTC_API unsigned int rtcGetGeometryOppositeHalfEdge(RTCGeometry geometry, unsigned int topologyID, unsigned int edgeID);
265 
266 
267 /* Arguments for rtcInterpolate */
269 {
271  unsigned int primID;
272  float u;
273  float v;
275  unsigned int bufferSlot;
276  float* P;
277  float* dPdu;
278  float* dPdv;
279  float* ddPdudu;
280  float* ddPdvdv;
281  float* ddPdudv;
282  unsigned int valueCount;
283 };
284 
285 /* Interpolates vertex data to some u/v location and optionally calculates all derivatives. */
287 
288 /* Interpolates vertex data to some u/v location. */
289 RTC_FORCEINLINE void rtcInterpolate0(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float* P, unsigned int valueCount)
290 {
291  struct RTCInterpolateArguments args;
292  args.geometry = geometry;
293  args.primID = primID;
294  args.u = u;
295  args.v = v;
296  args.bufferType = bufferType;
297  args.bufferSlot = bufferSlot;
298  args.P = P;
299  args.dPdu = NULL;
300  args.dPdv = NULL;
301  args.ddPdudu = NULL;
302  args.ddPdvdv = NULL;
303  args.ddPdudv = NULL;
304  args.valueCount = valueCount;
305  rtcInterpolate(&args);
306 }
307 
308 /* Interpolates vertex data to some u/v location and calculates first order derivatives. */
309 RTC_FORCEINLINE void rtcInterpolate1(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot,
310  float* P, float* dPdu, float* dPdv, unsigned int valueCount)
311 {
312  struct RTCInterpolateArguments args;
313  args.geometry = geometry;
314  args.primID = primID;
315  args.u = u;
316  args.v = v;
317  args.bufferType = bufferType;
318  args.bufferSlot = bufferSlot;
319  args.P = P;
320  args.dPdu = dPdu;
321  args.dPdv = dPdv;
322  args.ddPdudu = NULL;
323  args.ddPdvdv = NULL;
324  args.ddPdudv = NULL;
325  args.valueCount = valueCount;
326  rtcInterpolate(&args);
327 }
328 
329 /* Interpolates vertex data to some u/v location and calculates first and second order derivatives. */
330 RTC_FORCEINLINE void rtcInterpolate2(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot,
331  float* P, float* dPdu, float* dPdv, float* ddPdudu, float* ddPdvdv, float* ddPdudv, unsigned int valueCount)
332 {
333  struct RTCInterpolateArguments args;
334  args.geometry = geometry;
335  args.primID = primID;
336  args.u = u;
337  args.v = v;
338  args.bufferType = bufferType;
339  args.bufferSlot = bufferSlot;
340  args.P = P;
341  args.dPdu = dPdu;
342  args.dPdv = dPdv;
343  args.ddPdudu = ddPdudu;
344  args.ddPdvdv = ddPdvdv;
345  args.ddPdudv = ddPdudv;
346  args.valueCount = valueCount;
347  rtcInterpolate(&args);
348 }
349 
350 /* Arguments for rtcInterpolateN */
352 {
354  const void* valid;
355  const unsigned int* primIDs;
356  const float* u;
357  const float* v;
358  unsigned int N;
360  unsigned int bufferSlot;
361  float* P;
362  float* dPdu;
363  float* dPdv;
364  float* ddPdudu;
365  float* ddPdvdv;
366  float* ddPdudv;
367  unsigned int valueCount;
368 };
369 
370 /* Interpolates vertex data to an array of u/v locations. */
372 
373 /* RTCGrid primitive for grid mesh */
374 struct RTCGrid
375 {
376  unsigned int startVertexID;
377  unsigned int stride;
378  unsigned short width,height; // max is a 32k x 32k grid
379 };
380 
382 
383 
RTC_API void rtcSetGeometryOccludedFilterFunction(RTCGeometry geometry, RTCFilterFunctionN filter)
RTC_API void rtcFilterOcclusion(const struct RTCOccludedFunctionNArguments *args, const struct RTCFilterFunctionNArguments *filterArgs)
RTC_API void rtcDisableGeometry(RTCGeometry geometry)
RTC_API void rtcSetGeometryTimeRange(RTCGeometry geometry, float startTime, float endTime)
RTC_API void rtcEnableGeometry(RTCGeometry geometry)
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)
void(* RTCOccludedFunctionN)(const struct RTCOccludedFunctionNArguments *args)
RTCCurveFlags
RTC_FORCEINLINE void rtcInterpolate1(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float *P, float *dPdu, float *dPdv, unsigned int valueCount)
struct RTCBounds * bounds_o
RTC_API void rtcSetGeometryUserData(RTCGeometry geometry, void *ptr)
void
Definition: png.h:1083
enum RTCBufferType bufferType
GT_API const UT_StringHolder time
RTC_API void rtcSetGeometryIntersectFunction(RTCGeometry geometry, RTCIntersectFunctionN intersect)
RTC_API void * rtcSetNewGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount)
RTC_API void rtcSetGeometryTransform(RTCGeometry geometry, unsigned int timeStep, enum RTCFormat format, const void *xfm)
RTC_API unsigned int rtcGetGeometryFirstHalfEdge(RTCGeometry geometry, unsigned int faceID)
RTC_API void rtcSetGeometryUserPrimitiveCount(RTCGeometry geometry, unsigned int userPrimitiveCount)
RTC_API void rtcInterpolateN(const struct RTCInterpolateNArguments *args)
RTC_API void rtcSetGeometryIntersectFilterFunction(RTCGeometry geometry, RTCFilterFunctionN filter)
#define RTC_FORCEINLINE
Definition: rtcore_common.h:41
RTC_API void * rtcGetGeometryBufferData(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot)
#define RTC_API
Definition: rtcore_config.h:55
typedefRTC_NAMESPACE_BEGIN struct RTCDeviceTy * RTCDevice
Definition: rtcore_device.h:11
RTC_API void rtcFilterIntersection(const struct RTCIntersectFunctionNArguments *args, const struct RTCFilterFunctionNArguments *filterArgs)
RTCBuildQuality
RTC_API unsigned int rtcGetGeometryOppositeHalfEdge(RTCGeometry geometry, unsigned int topologyID, unsigned int edgeID)
struct RTCIntersectContext * context
unsigned short height
RTC_FORCEINLINE void rtcInterpolate0(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float *P, unsigned int valueCount)
struct RTCGeometryTy * RTCGeometry
RTC_API void rtcSetGeometryVertexAttributeCount(RTCGeometry geometry, unsigned int vertexAttributeCount)
Definition: core.h:760
RTC_API void rtcSetGeometrySubdivisionMode(RTCGeometry geometry, unsigned int topologyID, enum RTCSubdivisionMode mode)
enum RTCBufferType bufferType
RTC_API void rtcSetGeometryOccludedFunction(RTCGeometry geometry, RTCOccludedFunctionN occluded)
RTCSubdivisionMode
GLint GLuint mask
Definition: glcorearb.h:124
RTC_API void rtcSetGeometryDisplacementFunction(RTCGeometry geometry, RTCDisplacementFunctionN displacement)
const GLdouble * v
Definition: glcorearb.h:837
void(* RTCFilterFunctionN)(const struct RTCFilterFunctionNArguments *args)
unsigned int startVertexID
RTC_API void rtcSetGeometryPointQueryFunction(RTCGeometry geometry, RTCPointQueryFunction pointQuery)
RTC_API void rtcCommitGeometry(RTCGeometry geometry)
RTC_API void * rtcGetGeometryUserData(RTCGeometry geometry)
RTC_API void rtcSetGeometryTransformQuaternion(RTCGeometry geometry, unsigned int timeStep, const struct RTCQuaternionDecomposition *qd)
void(* RTCIntersectFunctionN)(const struct RTCIntersectFunctionNArguments *args)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297
RTC_API unsigned int rtcGetGeometryFace(RTCGeometry geometry, unsigned int edgeID)
const unsigned int * primIDs
struct RTCIntersectContext * context
RTC_API void rtcInterpolate(const struct RTCInterpolateArguments *args)
unsigned int stride
GLenum mode
Definition: glcorearb.h:99
RTC_API void rtcRetainGeometry(RTCGeometry geometry)
RTC_API unsigned int rtcGetGeometryNextHalfEdge(RTCGeometry geometry, unsigned int edgeID)
void(* RTCDisplacementFunctionN)(const struct RTCDisplacementFunctionNArguments *args)
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
#define RTC_NAMESPACE_END
Definition: rtcore_config.h:23
void(* RTCBoundsFunction)(const struct RTCBoundsFunctionArguments *args)
RTC_API void rtcReleaseGeometry(RTCGeometry geometry)
RTC_API void rtcSetGeometryMask(RTCGeometry geometry, unsigned int mask)
IMATH_CONSTEXPR14 bool intersect(const Line3< T > &line, const Vec3< T > &v0, const Vec3< T > &v1, const Vec3< T > &v2, Vec3< T > &pt, Vec3< T > &barycentric, bool &front) IMATH_NOEXCEPT
Definition: ImathLineAlgo.h:80
typedefRTC_NAMESPACE_BEGIN struct RTCSceneTy * RTCScene
auto ptr(T p) -> const void *
Definition: format.h:2448
RTC_API void rtcSetGeometryBuildQuality(RTCGeometry geometry, enum RTCBuildQuality quality)
RTC_API unsigned int rtcGetGeometryPreviousHalfEdge(RTCGeometry geometry, unsigned int edgeID)
**If you just want to fire and args
Definition: thread.h:609
RTC_API void rtcSetGeometryBoundsFunction(RTCGeometry geometry, RTCBoundsFunction bounds, void *userPtr)
RTC_API void rtcSetGeometryTopologyCount(RTCGeometry geometry, unsigned int topologyCount)
RTCFormat
Definition: rtcore_common.h:51
RTC_API void rtcSetGeometryVertexAttributeTopology(RTCGeometry geometry, unsigned int vertexAttributeID, unsigned int topologyID)
RTC_API RTCGeometry rtcNewGeometry(RTCDevice device, enum RTCGeometryType type)
RTC_API void rtcSetGeometryMaxRadiusScale(RTCGeometry geometry, float maxRadiusScale)
struct RTCBufferTy * RTCBuffer
Definition: rtcore_buffer.h:34
type
Definition: core.h:1059
RTC_API void rtcGetGeometryTransform(RTCGeometry geometry, float time, enum RTCFormat format, void *xfm)
RTC_API void rtcSetGeometryInstancedScene(RTCGeometry geometry, RTCScene scene)
RTC_API void rtcSetGeometryTessellationRate(RTCGeometry geometry, float tessellationRate)
bool(* RTCPointQueryFunction)(struct RTCPointQueryFunctionArguments *args)
RTC_API void rtcSetGeometryTimeStepCount(RTCGeometry geometry, unsigned int timeStepCount)
RTC_FORCEINLINE void rtcInterpolate2(RTCGeometry geometry, unsigned int primID, float u, float v, enum RTCBufferType bufferType, unsigned int bufferSlot, float *P, float *dPdu, float *dPdv, float *ddPdudu, float *ddPdvdv, float *ddPdudv, unsigned int valueCount)
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)
RTCGeometryType
unsigned short width
#define RTC_NAMESPACE_BEGIN
Definition: rtcore_config.h:22
RTCBufferType
Definition: rtcore_buffer.h:11
RTC_API void rtcUpdateGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot)