1 | // Copyright 2009-2021 Intel Corporation |
2 | // SPDX-License-Identifier: Apache-2.0 |
3 | |
4 | #pragma once |
5 | |
6 | #include "rtcore_device.h" |
7 | |
8 | RTC_NAMESPACE_BEGIN |
9 | |
10 | /* Forward declarations for ray structures */ |
11 | struct RTCRayHit; |
12 | struct RTCRayHit4; |
13 | struct RTCRayHit8; |
14 | struct RTCRayHit16; |
15 | struct RTCRayHitNp; |
16 | |
17 | /* Scene flags */ |
18 | enum 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. */ |
28 | RTC_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. */ |
32 | RTC_API RTCDevice rtcGetSceneDevice(RTCScene hscene); |
33 | |
34 | /* Retains the scene (increments the reference count). */ |
35 | RTC_API void rtcRetainScene(RTCScene scene); |
36 | |
37 | /* Releases the scene (decrements the reference count). */ |
38 | RTC_API void rtcReleaseScene(RTCScene scene); |
39 | |
40 | |
41 | /* Attaches the geometry to a scene. */ |
42 | RTC_API unsigned int rtcAttachGeometry(RTCScene scene, RTCGeometry geometry); |
43 | |
44 | /* Attaches the geometry to a scene using the specified geometry ID. */ |
45 | RTC_API void rtcAttachGeometryByID(RTCScene scene, RTCGeometry geometry, unsigned int geomID); |
46 | |
47 | /* Detaches the geometry from the scene. */ |
48 | RTC_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. */ |
51 | RTC_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. */ |
54 | RTC_API RTCGeometry rtcGetGeometryThreadSafe(RTCScene scene, unsigned int geomID); |
55 | |
56 | |
57 | /* Commits the scene. */ |
58 | RTC_API void rtcCommitScene(RTCScene scene); |
59 | |
60 | /* Commits the scene from multiple threads. */ |
61 | RTC_API void rtcJoinCommitScene(RTCScene scene); |
62 | |
63 | |
64 | /* Progress monitor callback function */ |
65 | typedef bool (*RTCProgressMonitorFunction)(void* ptr, double n); |
66 | |
67 | /* Sets the progress monitor callback function of the scene. */ |
68 | RTC_API void rtcSetSceneProgressMonitorFunction(RTCScene scene, RTCProgressMonitorFunction progress, void* ptr); |
69 | |
70 | /* Sets the build quality of the scene. */ |
71 | RTC_API void rtcSetSceneBuildQuality(RTCScene scene, enum RTCBuildQuality quality); |
72 | |
73 | /* Sets the scene flags. */ |
74 | RTC_API void rtcSetSceneFlags(RTCScene scene, enum RTCSceneFlags flags); |
75 | |
76 | /* Returns the scene flags. */ |
77 | RTC_API enum RTCSceneFlags rtcGetSceneFlags(RTCScene scene); |
78 | |
79 | /* Returns the axis-aligned bounds of the scene. */ |
80 | RTC_API void rtcGetSceneBounds(RTCScene scene, struct RTCBounds* bounds_o); |
81 | |
82 | /* Returns the linear axis-aligned bounds of the scene. */ |
83 | RTC_API void rtcGetSceneLinearBounds(RTCScene scene, struct RTCLinearBounds* bounds_o); |
84 | |
85 | |
86 | /* Perform a closest point query of the scene. */ |
87 | RTC_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. */ |
90 | RTC_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. */ |
93 | RTC_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. */ |
96 | RTC_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. */ |
99 | RTC_API void rtcIntersect1(RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHit* rayhit); |
100 | |
101 | /* Intersects a packet of 4 rays with the scene. */ |
102 | RTC_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. */ |
105 | RTC_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. */ |
108 | RTC_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. */ |
111 | RTC_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. */ |
114 | RTC_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. */ |
117 | RTC_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. */ |
120 | RTC_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. */ |
123 | RTC_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. */ |
126 | RTC_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. */ |
129 | RTC_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. */ |
132 | RTC_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. */ |
135 | RTC_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. */ |
138 | RTC_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. */ |
141 | RTC_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. */ |
144 | RTC_API void rtcOccludedNp(RTCScene scene, struct RTCIntersectContext* context, const struct RTCRayNp* ray, unsigned int N); |
145 | |
146 | /*! collision callback */ |
147 | struct RTCCollision { unsigned int geomID0; unsigned int primID0; unsigned int geomID1; unsigned int primID1; }; |
148 | typedef void (*RTCCollideFunc) (void* userPtr, struct RTCCollision* collisions, unsigned int num_collisions); |
149 | |
150 | /*! Performs collision detection of two scenes */ |
151 | RTC_API void rtcCollide (RTCScene scene0, RTCScene scene1, RTCCollideFunc callback, void* userPtr); |
152 | |
153 | #if defined(__cplusplus) |
154 | |
155 | /* Helper for easily combining scene flags */ |
156 | inline RTCSceneFlags operator|(RTCSceneFlags a, RTCSceneFlags b) { |
157 | return (RTCSceneFlags)((size_t)a | (size_t)b); |
158 | } |
159 | |
160 | #endif |
161 | |
162 | RTC_NAMESPACE_END |
163 | |
164 | |