1// Copyright 2009-2021 Intel Corporation
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5
6#include "rtcore_device.h"
7
8RTC_NAMESPACE_BEGIN
9
10/* Forward declarations for ray structures */
11struct RTCRayHit;
12struct RTCRayHit4;
13struct RTCRayHit8;
14struct RTCRayHit16;
15struct RTCRayHitNp;
16
17/* Scene flags */
18enum RTCSceneFlags
19{
20 RTC_SCENE_FLAG_NONE = 0,
21 RTC_SCENE_FLAG_DYNAMIC = (1 << 0),
22 RTC_SCENE_FLAG_COMPACT = (1 << 1),
23 RTC_SCENE_FLAG_ROBUST = (1 << 2),
24 RTC_SCENE_FLAG_CONTEXT_FILTER_FUNCTION = (1 << 3)
25};
26
27/* Creates a new scene. */
28RTC_API RTCScene rtcNewScene(RTCDevice device);
29
30/* Returns the device the scene got created in. The reference count of
31 * the device is incremented by this function. */
32RTC_API RTCDevice rtcGetSceneDevice(RTCScene hscene);
33
34/* Retains the scene (increments the reference count). */
35RTC_API void rtcRetainScene(RTCScene scene);
36
37/* Releases the scene (decrements the reference count). */
38RTC_API void rtcReleaseScene(RTCScene scene);
39
40
41/* Attaches the geometry to a scene. */
42RTC_API unsigned int rtcAttachGeometry(RTCScene scene, RTCGeometry geometry);
43
44/* Attaches the geometry to a scene using the specified geometry ID. */
45RTC_API void rtcAttachGeometryByID(RTCScene scene, RTCGeometry geometry, unsigned int geomID);
46
47/* Detaches the geometry from the scene. */
48RTC_API void rtcDetachGeometry(RTCScene scene, unsigned int geomID);
49
50/* Gets a geometry handle from the scene. This function is not thread safe and should get used during rendering. */
51RTC_API RTCGeometry rtcGetGeometry(RTCScene scene, unsigned int geomID);
52
53/* Gets a geometry handle from the scene. This function is thread safe and should NOT get used during rendering. */
54RTC_API RTCGeometry rtcGetGeometryThreadSafe(RTCScene scene, unsigned int geomID);
55
56
57/* Commits the scene. */
58RTC_API void rtcCommitScene(RTCScene scene);
59
60/* Commits the scene from multiple threads. */
61RTC_API void rtcJoinCommitScene(RTCScene scene);
62
63
64/* Progress monitor callback function */
65typedef bool (*RTCProgressMonitorFunction)(void* ptr, double n);
66
67/* Sets the progress monitor callback function of the scene. */
68RTC_API void rtcSetSceneProgressMonitorFunction(RTCScene scene, RTCProgressMonitorFunction progress, void* ptr);
69
70/* Sets the build quality of the scene. */
71RTC_API void rtcSetSceneBuildQuality(RTCScene scene, enum RTCBuildQuality quality);
72
73/* Sets the scene flags. */
74RTC_API void rtcSetSceneFlags(RTCScene scene, enum RTCSceneFlags flags);
75
76/* Returns the scene flags. */
77RTC_API enum RTCSceneFlags rtcGetSceneFlags(RTCScene scene);
78
79/* Returns the axis-aligned bounds of the scene. */
80RTC_API void rtcGetSceneBounds(RTCScene scene, struct RTCBounds* bounds_o);
81
82/* Returns the linear axis-aligned bounds of the scene. */
83RTC_API void rtcGetSceneLinearBounds(RTCScene scene, struct RTCLinearBounds* bounds_o);
84
85
86/* Perform a closest point query of the scene. */
87RTC_API bool rtcPointQuery(RTCScene scene, struct RTCPointQuery* query, struct RTCPointQueryContext* context, RTCPointQueryFunction queryFunc, void* userPtr);
88
89/* Perform a closest point query with a packet of 4 points with the scene. */
90RTC_API bool rtcPointQuery4(const int* valid, RTCScene scene, struct RTCPointQuery4* query, struct RTCPointQueryContext* context, RTCPointQueryFunction queryFunc, void** userPtr);
91
92/* Perform a closest point query with a packet of 4 points with the scene. */
93RTC_API bool rtcPointQuery8(const int* valid, RTCScene scene, struct RTCPointQuery8* query, struct RTCPointQueryContext* context, RTCPointQueryFunction queryFunc, void** userPtr);
94
95/* Perform a closest point query with a packet of 4 points with the scene. */
96RTC_API bool rtcPointQuery16(const int* valid, RTCScene scene, struct RTCPointQuery16* query, struct RTCPointQueryContext* context, RTCPointQueryFunction queryFunc, void** userPtr);
97
98/* Intersects a single ray with the scene. */
99RTC_API void rtcIntersect1(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit* rayhit);
100
101/* Intersects a packet of 4 rays with the scene. */
102RTC_API void rtcIntersect4(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit4* rayhit);
103
104/* Intersects a packet of 8 rays with the scene. */
105RTC_API void rtcIntersect8(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit8* rayhit);
106
107/* Intersects a packet of 16 rays with the scene. */
108RTC_API void rtcIntersect16(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit16* rayhit);
109
110/* Intersects a stream of M rays with the scene. */
111RTC_API void rtcIntersect1M(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit* rayhit, unsigned int M, size_t byteStride);
112
113/* Intersects a stream of pointers to M rays with the scene. */
114RTC_API void rtcIntersect1Mp(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit** rayhit, unsigned int M);
115
116/* Intersects a stream of M ray packets of size N in SOA format with the scene. */
117RTC_API void rtcIntersectNM(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHitN* rayhit, unsigned int N, unsigned int M, size_t byteStride);
118
119/* Intersects a stream of M ray packets of size N in SOA format with the scene. */
120RTC_API void rtcIntersectNp(RTCScene scene, struct RTCIntersectContext* context, const struct RTCRayHitNp* rayhit, unsigned int N);
121
122/* Tests a single ray for occlusion with the scene. */
123RTC_API void rtcOccluded1(RTCScene scene, struct RTCIntersectContext* context, struct RTCRay* ray);
124
125/* Tests a packet of 4 rays for occlusion occluded with the scene. */
126RTC_API void rtcOccluded4(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRay4* ray);
127
128/* Tests a packet of 8 rays for occlusion with the scene. */
129RTC_API void rtcOccluded8(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRay8* ray);
130
131/* Tests a packet of 16 rays for occlusion with the scene. */
132RTC_API void rtcOccluded16(const int* valid, RTCScene scene, struct RTCIntersectContext* context, struct RTCRay16* ray);
133
134/* Tests a stream of M rays for occlusion with the scene. */
135RTC_API void rtcOccluded1M(RTCScene scene, struct RTCIntersectContext* context, struct RTCRay* ray, unsigned int M, size_t byteStride);
136
137/* Tests a stream of pointers to M rays for occlusion with the scene. */
138RTC_API void rtcOccluded1Mp(RTCScene scene, struct RTCIntersectContext* context, struct RTCRay** ray, unsigned int M);
139
140/* Tests a stream of M ray packets of size N in SOA format for occlusion with the scene. */
141RTC_API void rtcOccludedNM(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayN* ray, unsigned int N, unsigned int M, size_t byteStride);
142
143/* Tests a stream of M ray packets of size N in SOA format for occlusion with the scene. */
144RTC_API void rtcOccludedNp(RTCScene scene, struct RTCIntersectContext* context, const struct RTCRayNp* ray, unsigned int N);
145
146/*! collision callback */
147struct RTCCollision { unsigned int geomID0; unsigned int primID0; unsigned int geomID1; unsigned int primID1; };
148typedef void (*RTCCollideFunc) (void* userPtr, struct RTCCollision* collisions, unsigned int num_collisions);
149
150/*! Performs collision detection of two scenes */
151RTC_API void rtcCollide (RTCScene scene0, RTCScene scene1, RTCCollideFunc callback, void* userPtr);
152
153#if defined(__cplusplus)
154
155/* Helper for easily combining scene flags */
156inline RTCSceneFlags operator|(RTCSceneFlags a, RTCSceneFlags b) {
157 return (RTCSceneFlags)((size_t)a | (size_t)b);
158}
159
160#endif
161
162RTC_NAMESPACE_END
163
164

source code of qtquick3d/src/3rdparty/embree/include/embree3/rtcore_scene.h