Skip to content

Commit

Permalink
use rtcJoinCommit only if available
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminum committed Aug 29, 2023
1 parent c5a62b2 commit 557ccd4
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions cpp/open3d/t/geometry/RaycastingScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <bool LINE_INTERSECTION>
void CastRays(const float* const rays,
const size_t num_rays,
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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<size_t>& range) {
for (size_t i = range.begin(); i < range.end(); ++i) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 557ccd4

Please sign in to comment.