Skip to content

Commit 54cbdf1

Browse files
committed
Added getters for if the scene is modified, the progress monitor function, the progress user pointer, and the scene build quality. Also added getters for getting the number of attached geometries as well as the array of geometries attached to the scene. All of these are available in the C API.
1 parent 63b71d1 commit 54cbdf1

File tree

4 files changed

+160
-0
lines changed

4 files changed

+160
-0
lines changed

include/embree4/rtcore_scene.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ RTC_API void rtcAttachGeometryByID(RTCScene scene, RTCGeometry geometry, unsigne
102102
/* Detaches the geometry from the scene. */
103103
RTC_API void rtcDetachGeometry(RTCScene scene, unsigned int geomID);
104104

105+
/* Gets the number of geometry IDs attached to the scene. To get the array of valid IDs allocate an array of the correct size and pass it as geomIDs. */
106+
RTC_API size_t rtcGetNumAttachedGeometryIDs(RTCScene scene);
107+
RTC_API void rtcGetAttachedGeometryIDs(RTCScene scene, size_t* numGeomIDs, unsigned int* geomIDs RTC_DEFAULT_VALUE(nullptr));
108+
109+
/* Gets the number of geometries attached to the scene. To get the array of valid geometries allocate an array of the correct size and pass it as geometries. */
110+
RTC_API size_t rtcGetNumAttachedGeometries(RTCScene scene);
111+
RTC_API void rtcGetAttachedGeometries(RTCScene scene, size_t* numGeoms, RTCGeometry* geometries RTC_DEFAULT_VALUE(nullptr));
112+
105113
/* Gets a geometry handle from the scene. This function is not thread safe and should get used during rendering. */
106114
RTC_API RTCGeometry rtcGetGeometry(RTCScene scene, unsigned int geomID);
107115

@@ -121,16 +129,28 @@ RTC_API void rtcCommitScene(RTCScene scene);
121129
/* Commits the scene from multiple threads. */
122130
RTC_API void rtcJoinCommitScene(RTCScene scene);
123131

132+
/* Returns if the scene has been modified since it was last committed. */
133+
RTC_API bool rtcIsSceneModified(RTCScene scene);
134+
124135

125136
/* Progress monitor callback function */
126137
typedef bool (*RTCProgressMonitorFunction)(void* ptr, double n);
127138

128139
/* Sets the progress monitor callback function of the scene. */
129140
RTC_API void rtcSetSceneProgressMonitorFunction(RTCScene scene, RTCProgressMonitorFunction progress, void* ptr);
130141

142+
/* Gets the progress monitor callback function of the scene. */
143+
RTC_API RTCProgressMonitorFunction rtcGetSceneProgressMonitorFunction(RTCScene scene);
144+
145+
/* Gets the progress monitor callback function user pointer of the scene. */
146+
RTC_API void* rtcGetSceneProgressMonitorFunctionUserPtr(RTCScene scene);
147+
131148
/* Sets the build quality of the scene. */
132149
RTC_API void rtcSetSceneBuildQuality(RTCScene scene, enum RTCBuildQuality quality);
133150

151+
/* Gets the build quality of the scene. */
152+
RTC_API enum RTCBuildQuality rtcGetSceneBuildQuality(RTCScene scene);
153+
134154
/* Sets the scene flags. */
135155
RTC_API void rtcSetSceneFlags(RTCScene scene, enum RTCSceneFlags flags);
136156

kernels/common/rtcore.cpp

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,32 @@ RTC_NAMESPACE_BEGIN;
333333
RTC_CATCH_END2(scene);
334334
}
335335

336+
RTC_API RTCProgressMonitorFunction rtcGetSceneProgressMonitorFunction(RTCScene hscene)
337+
{
338+
Scene* scene = (Scene*) hscene;
339+
RTC_CATCH_BEGIN;
340+
RTC_TRACE(rtcGetSceneProgressMonitorFunction);
341+
RTC_VERIFY_HANDLE(hscene);
342+
RTC_ENTER_DEVICE(hscene);
343+
Lock<MutexSys> lock(g_mutex);
344+
return scene->getProgressMonitorFunction();
345+
RTC_CATCH_END2(scene);
346+
return nullptr;
347+
}
348+
349+
RTC_API void* rtcGetSceneProgressMonitorFunctionUserPtr(RTCScene hscene)
350+
{
351+
Scene* scene = (Scene*) hscene;
352+
RTC_CATCH_BEGIN;
353+
RTC_TRACE(rtcGetSceneProgressMonitorFunctionUserPtr);
354+
RTC_VERIFY_HANDLE(hscene);
355+
RTC_ENTER_DEVICE(hscene);
356+
Lock<MutexSys> lock(g_mutex);
357+
return scene->getProgressMonitorFunctionUserPtr();
358+
RTC_CATCH_END2(scene);
359+
return nullptr;
360+
}
361+
336362
RTC_API void rtcSetSceneBuildQuality (RTCScene hscene, RTCBuildQuality quality)
337363
{
338364
Scene* scene = (Scene*) hscene;
@@ -348,6 +374,18 @@ RTC_NAMESPACE_BEGIN;
348374
RTC_CATCH_END2(scene);
349375
}
350376

377+
RTC_API RTCBuildQuality rtcGetSceneBuildQuality (RTCScene hscene)
378+
{
379+
Scene* scene = (Scene*) hscene;
380+
RTC_CATCH_BEGIN;
381+
RTC_TRACE(rtcGetSceneBuildQuality);
382+
RTC_VERIFY_HANDLE(hscene);
383+
RTC_ENTER_DEVICE(hscene);
384+
return scene->getBuildQuality();
385+
RTC_CATCH_END2(scene);
386+
return RTC_BUILD_QUALITY_MEDIUM;
387+
}
388+
351389
RTC_API void rtcSetSceneFlags (RTCScene hscene, RTCSceneFlags flags)
352390
{
353391
Scene* scene = (Scene*) hscene;
@@ -400,6 +438,18 @@ RTC_NAMESPACE_BEGIN;
400438
RTC_CATCH_END2(scene);
401439
}
402440

441+
RTC_API bool rtcIsSceneModified(RTCScene hscene)
442+
{
443+
Scene* scene = (Scene*) hscene;
444+
RTC_CATCH_BEGIN;
445+
RTC_TRACE(rtcIsSceneModified);
446+
RTC_VERIFY_HANDLE(hscene);
447+
RTC_ENTER_DEVICE(hscene);
448+
return scene->isModified();
449+
RTC_CATCH_END2(scene);
450+
return false;
451+
}
452+
403453
RTC_API void rtcGetSceneBounds(RTCScene hscene, RTCBounds* bounds_o)
404454
{
405455
Scene* scene = (Scene*) hscene;
@@ -2109,6 +2159,84 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
21092159
RTC_CATCH_END2(geometry);
21102160
}
21112161

2162+
RTC_API size_t rtcGetNumAttachedGeometryIDs (RTCScene hscene)
2163+
{
2164+
Scene* scene = (Scene*) hscene;
2165+
RTC_CATCH_BEGIN;
2166+
RTC_TRACE(rtcGetNumAttachedGeometryIDs);
2167+
RTC_VERIFY_HANDLE(hscene);
2168+
RTC_ENTER_DEVICE(hscene);
2169+
unsigned int numGeomIDs = scene->size();
2170+
for (unsigned int i = 0; i < scene->size(); ++i) {
2171+
Geometry* ptr = scene->get(i);
2172+
if (!ptr) {
2173+
numGeomIDs -= 1;
2174+
}
2175+
}
2176+
return numGeomIDs;
2177+
RTC_CATCH_END2(scene);
2178+
return 0;
2179+
}
2180+
2181+
RTC_API void rtcGetAttachedGeometryIDs (RTCScene hscene, size_t* numGeomIDs, unsigned int* geomIDs)
2182+
{
2183+
Scene* scene = (Scene*) hscene;
2184+
RTC_CATCH_BEGIN;
2185+
RTC_TRACE(rtcGetAttachedGeometryIDs);
2186+
RTC_VERIFY_HANDLE(hscene);
2187+
RTC_VERIFY_HANDLE(numGeomIDs);
2188+
RTC_ENTER_DEVICE(hscene);
2189+
*numGeomIDs = scene->size();
2190+
for (unsigned int i = 0; i < scene->size(); ++i) {
2191+
Geometry* ptr = scene->get(i);
2192+
if (!ptr) {
2193+
*numGeomIDs -= 1;
2194+
} else if (geomIDs) {
2195+
*geomIDs++ = i;
2196+
}
2197+
}
2198+
RTC_CATCH_END2(scene);
2199+
}
2200+
2201+
RTC_API size_t rtcGetNumAttachedGeometries (RTCScene hscene)
2202+
{
2203+
Scene* scene = (Scene*) hscene;
2204+
RTC_CATCH_BEGIN;
2205+
RTC_TRACE(rtcGetNumAttachedGeometryIDs);
2206+
RTC_VERIFY_HANDLE(hscene);
2207+
RTC_ENTER_DEVICE(hscene);
2208+
unsigned int numGeomIDs = scene->size();
2209+
for (unsigned int i = 0; i < scene->size(); ++i) {
2210+
Geometry* ptr = scene->get(i);
2211+
if (!ptr) {
2212+
numGeomIDs -= 1;
2213+
}
2214+
}
2215+
return numGeomIDs;
2216+
RTC_CATCH_END2(scene);
2217+
return 0;
2218+
}
2219+
2220+
RTC_API void rtcGetAttachedGeometries (RTCScene hscene, size_t* numGeoms, RTCGeometry* geometries)
2221+
{
2222+
Scene* scene = (Scene*) hscene;
2223+
RTC_CATCH_BEGIN;
2224+
RTC_TRACE(rtcGetAttachedGeometries);
2225+
RTC_VERIFY_HANDLE(hscene);
2226+
RTC_VERIFY_HANDLE(numGeoms);
2227+
RTC_ENTER_DEVICE(hscene);
2228+
*numGeoms = scene->size();
2229+
for (unsigned int i = 0; i < scene->size(); ++i) {
2230+
Geometry* ptr = scene->get(i);
2231+
if (!ptr) {
2232+
*numGeoms -= 1;
2233+
} else if (geometries) {
2234+
*geometries++ = (RTCGeometry) ptr;
2235+
}
2236+
}
2237+
RTC_CATCH_END2(scene);
2238+
}
2239+
21122240
RTC_API RTCGeometry rtcGetGeometry (RTCScene hscene, unsigned int geomID)
21132241
{
21142242
Scene* scene = (Scene*) hscene;

kernels/common/scene.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,16 @@ namespace embree
10331033
progress_monitor_ptr = ptr;
10341034
}
10351035

1036+
RTCProgressMonitorFunction Scene::getProgressMonitorFunction() const
1037+
{
1038+
return progress_monitor_function;
1039+
}
1040+
1041+
void* Scene::getProgressMonitorFunctionUserPtr() const
1042+
{
1043+
return progress_monitor_ptr;
1044+
}
1045+
10361046
void Scene::progressMonitor(double dn)
10371047
{
10381048
if (progress_monitor_function) {

kernels/common/scene.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ namespace embree
328328
std::atomic<size_t> progress_monitor_counter;
329329
void progressMonitor(double nprims);
330330
void setProgressMonitorFunction(RTCProgressMonitorFunction func, void* ptr);
331+
RTCProgressMonitorFunction getProgressMonitorFunction() const;
332+
void* getProgressMonitorFunctionUserPtr() const;
331333

332334
private:
333335
GeometryCounts world; //!< counts for geometry

0 commit comments

Comments
 (0)