Skip to content

Commit 49e5042

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 2eb5405 commit 49e5042

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
@@ -107,6 +107,14 @@ RTC_API void rtcAttachGeometryByID(RTCScene scene, RTCGeometry geometry, unsigne
107107
/* Detaches the geometry from the scene. */
108108
RTC_API void rtcDetachGeometry(RTCScene scene, unsigned int geomID);
109109

110+
/* 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. */
111+
RTC_API size_t rtcGetNumAttachedGeometryIDs(RTCScene scene);
112+
RTC_API void rtcGetAttachedGeometryIDs(RTCScene scene, size_t* numGeomIDs, unsigned int* geomIDs RTC_DEFAULT_VALUE(nullptr));
113+
114+
/* 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. */
115+
RTC_API size_t rtcGetNumAttachedGeometries(RTCScene scene);
116+
RTC_API void rtcGetAttachedGeometries(RTCScene scene, size_t* numGeoms, RTCGeometry* geometries RTC_DEFAULT_VALUE(nullptr));
117+
110118
/* Gets a geometry handle from the scene. This function is not thread safe and should get used during rendering. */
111119
RTC_API RTCGeometry rtcGetGeometry(RTCScene scene, unsigned int geomID);
112120

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

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

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

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

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

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

kernels/common/rtcore.cpp

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,32 @@ RTC_NAMESPACE_BEGIN;
398398
RTC_CATCH_END2(scene);
399399
}
400400

401+
RTC_API RTCProgressMonitorFunction rtcGetSceneProgressMonitorFunction(RTCScene hscene)
402+
{
403+
Scene* scene = (Scene*) hscene;
404+
RTC_CATCH_BEGIN;
405+
RTC_TRACE(rtcGetSceneProgressMonitorFunction);
406+
RTC_VERIFY_HANDLE(hscene);
407+
RTC_ENTER_DEVICE(hscene);
408+
Lock<MutexSys> lock(g_mutex);
409+
return scene->getProgressMonitorFunction();
410+
RTC_CATCH_END2(scene);
411+
return nullptr;
412+
}
413+
414+
RTC_API void* rtcGetSceneProgressMonitorFunctionUserPtr(RTCScene hscene)
415+
{
416+
Scene* scene = (Scene*) hscene;
417+
RTC_CATCH_BEGIN;
418+
RTC_TRACE(rtcGetSceneProgressMonitorFunctionUserPtr);
419+
RTC_VERIFY_HANDLE(hscene);
420+
RTC_ENTER_DEVICE(hscene);
421+
Lock<MutexSys> lock(g_mutex);
422+
return scene->getProgressMonitorFunctionUserPtr();
423+
RTC_CATCH_END2(scene);
424+
return nullptr;
425+
}
426+
401427
RTC_API void rtcSetSceneBuildQuality (RTCScene hscene, RTCBuildQuality quality)
402428
{
403429
Scene* scene = (Scene*) hscene;
@@ -412,6 +438,18 @@ RTC_NAMESPACE_BEGIN;
412438
RTC_CATCH_END2(scene);
413439
}
414440

441+
RTC_API RTCBuildQuality rtcGetSceneBuildQuality (RTCScene hscene)
442+
{
443+
Scene* scene = (Scene*) hscene;
444+
RTC_CATCH_BEGIN;
445+
RTC_TRACE(rtcGetSceneBuildQuality);
446+
RTC_VERIFY_HANDLE(hscene);
447+
RTC_ENTER_DEVICE(hscene);
448+
return scene->getBuildQuality();
449+
RTC_CATCH_END2(scene);
450+
return RTC_BUILD_QUALITY_MEDIUM;
451+
}
452+
415453
RTC_API void rtcSetSceneFlags (RTCScene hscene, RTCSceneFlags flags)
416454
{
417455
Scene* scene = (Scene*) hscene;
@@ -462,6 +500,18 @@ RTC_NAMESPACE_BEGIN;
462500
RTC_CATCH_END2(scene);
463501
}
464502

503+
RTC_API bool rtcIsSceneModified(RTCScene hscene)
504+
{
505+
Scene* scene = (Scene*) hscene;
506+
RTC_CATCH_BEGIN;
507+
RTC_TRACE(rtcIsSceneModified);
508+
RTC_VERIFY_HANDLE(hscene);
509+
RTC_ENTER_DEVICE(hscene);
510+
return scene->isModified();
511+
RTC_CATCH_END2(scene);
512+
return false;
513+
}
514+
465515
RTC_API void rtcGetSceneBounds(RTCScene hscene, RTCBounds* bounds_o)
466516
{
467517
Scene* scene = (Scene*) hscene;
@@ -2361,6 +2411,84 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
23612411
RTC_CATCH_END2(geometry);
23622412
}
23632413

2414+
RTC_API size_t rtcGetNumAttachedGeometryIDs (RTCScene hscene)
2415+
{
2416+
Scene* scene = (Scene*) hscene;
2417+
RTC_CATCH_BEGIN;
2418+
RTC_TRACE(rtcGetNumAttachedGeometryIDs);
2419+
RTC_VERIFY_HANDLE(hscene);
2420+
RTC_ENTER_DEVICE(hscene);
2421+
unsigned int numGeomIDs = scene->size();
2422+
for (unsigned int i = 0; i < scene->size(); ++i) {
2423+
Geometry* ptr = scene->get(i);
2424+
if (!ptr) {
2425+
numGeomIDs -= 1;
2426+
}
2427+
}
2428+
return numGeomIDs;
2429+
RTC_CATCH_END2(scene);
2430+
return 0;
2431+
}
2432+
2433+
RTC_API void rtcGetAttachedGeometryIDs (RTCScene hscene, size_t* numGeomIDs, unsigned int* geomIDs)
2434+
{
2435+
Scene* scene = (Scene*) hscene;
2436+
RTC_CATCH_BEGIN;
2437+
RTC_TRACE(rtcGetAttachedGeometryIDs);
2438+
RTC_VERIFY_HANDLE(hscene);
2439+
RTC_VERIFY_HANDLE(numGeomIDs);
2440+
RTC_ENTER_DEVICE(hscene);
2441+
*numGeomIDs = scene->size();
2442+
for (unsigned int i = 0; i < scene->size(); ++i) {
2443+
Geometry* ptr = scene->get(i);
2444+
if (!ptr) {
2445+
*numGeomIDs -= 1;
2446+
} else if (geomIDs) {
2447+
*geomIDs++ = i;
2448+
}
2449+
}
2450+
RTC_CATCH_END2(scene);
2451+
}
2452+
2453+
RTC_API size_t rtcGetNumAttachedGeometries (RTCScene hscene)
2454+
{
2455+
Scene* scene = (Scene*) hscene;
2456+
RTC_CATCH_BEGIN;
2457+
RTC_TRACE(rtcGetNumAttachedGeometryIDs);
2458+
RTC_VERIFY_HANDLE(hscene);
2459+
RTC_ENTER_DEVICE(hscene);
2460+
unsigned int numGeomIDs = scene->size();
2461+
for (unsigned int i = 0; i < scene->size(); ++i) {
2462+
Geometry* ptr = scene->get(i);
2463+
if (!ptr) {
2464+
numGeomIDs -= 1;
2465+
}
2466+
}
2467+
return numGeomIDs;
2468+
RTC_CATCH_END2(scene);
2469+
return 0;
2470+
}
2471+
2472+
RTC_API void rtcGetAttachedGeometries (RTCScene hscene, size_t* numGeoms, RTCGeometry* geometries)
2473+
{
2474+
Scene* scene = (Scene*) hscene;
2475+
RTC_CATCH_BEGIN;
2476+
RTC_TRACE(rtcGetAttachedGeometries);
2477+
RTC_VERIFY_HANDLE(hscene);
2478+
RTC_VERIFY_HANDLE(numGeoms);
2479+
RTC_ENTER_DEVICE(hscene);
2480+
*numGeoms = scene->size();
2481+
for (unsigned int i = 0; i < scene->size(); ++i) {
2482+
Geometry* ptr = scene->get(i);
2483+
if (!ptr) {
2484+
*numGeoms -= 1;
2485+
} else if (geometries) {
2486+
*geometries++ = (RTCGeometry) ptr;
2487+
}
2488+
}
2489+
RTC_CATCH_END2(scene);
2490+
}
2491+
23642492
RTC_API RTCGeometry rtcGetGeometry (RTCScene hscene, unsigned int geomID)
23652493
{
23662494
Scene* scene = (Scene*) hscene;

kernels/common/scene.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,16 @@ namespace embree
10891089
progress_monitor_ptr = ptr;
10901090
}
10911091

1092+
RTCProgressMonitorFunction Scene::getProgressMonitorFunction() const
1093+
{
1094+
return progress_monitor_function;
1095+
}
1096+
1097+
void* Scene::getProgressMonitorFunctionUserPtr() const
1098+
{
1099+
return progress_monitor_ptr;
1100+
}
1101+
10921102
void Scene::progressMonitor(double dn)
10931103
{
10941104
if (progress_monitor_function) {

kernels/common/scene.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ namespace embree
383383
std::atomic<size_t> progress_monitor_counter;
384384
void progressMonitor(double nprims);
385385
void setProgressMonitorFunction(RTCProgressMonitorFunction func, void* ptr);
386+
RTCProgressMonitorFunction getProgressMonitorFunction() const;
387+
void* getProgressMonitorFunctionUserPtr() const;
386388

387389
private:
388390
GeometryCounts world; //!< counts for geometry

0 commit comments

Comments
 (0)