diff --git a/cpp/open3d/t/geometry/RaycastingScene.cpp b/cpp/open3d/t/geometry/RaycastingScene.cpp index b16d2596c8f..412d6130862 100644 --- a/cpp/open3d/t/geometry/RaycastingScene.cpp +++ b/cpp/open3d/t/geometry/RaycastingScene.cpp @@ -267,6 +267,19 @@ struct RaycastingScene::Impl { geometry_ptrs_; core::Device tensor_device_; // cpu + bool devprop_join_commit; + + void CommitScene() { + if (!scene_committed_) { + if (devprop_join_commit) { + rtcJoinCommitScene(scene_); + } else { + rtcCommitScene(scene_); + } + scene_committed_ = true; + } + } + template void CastRays(const float* const rays, const size_t num_rays, @@ -276,10 +289,7 @@ struct RaycastingScene::Impl { float* primitive_uvs, float* primitive_normals, const int nthreads) { - if (!scene_committed_) { - rtcJoinCommitScene(scene_); - scene_committed_ = true; - } + CommitScene(); struct RTCIntersectContext context; rtcInitIntersectContext(&context); @@ -365,10 +375,7 @@ struct RaycastingScene::Impl { const float tfar, int8_t* occluded, const int nthreads) { - if (!scene_committed_) { - rtcJoinCommitScene(scene_); - scene_committed_ = true; - } + CommitScene(); struct RTCIntersectContext context; rtcInitIntersectContext(&context); @@ -420,10 +427,7 @@ struct RaycastingScene::Impl { const size_t num_rays, int* intersections, const int nthreads) { - if (!scene_committed_) { - rtcJoinCommitScene(scene_); - scene_committed_ = true; - } + CommitScene(); memset(intersections, 0, sizeof(int) * num_rays); @@ -486,10 +490,7 @@ struct RaycastingScene::Impl { float* primitive_uvs, float* primitive_normals, const int nthreads) { - if (!scene_committed_) { - rtcJoinCommitScene(scene_); - scene_committed_ = true; - } + CommitScene(); auto LoopFn = [&](const tbb::blocked_range& range) { for (size_t i = range.begin(); i < range.end(); ++i) { @@ -552,6 +553,9 @@ RaycastingScene::RaycastingScene(int64_t nthreads) impl_->scene_, RTC_SCENE_FLAG_ROBUST | RTC_SCENE_FLAG_CONTEXT_FILTER_FUNCTION); + impl_->devprop_join_commit = rtcGetDeviceProperty( + impl_->device_, RTC_DEVICE_PROPERTY_JOIN_COMMIT_SUPPORTED); + impl_->scene_committed_ = false; }