Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/geode/model/helpers/ray_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include <geode/model/helpers/ray_tracing.hpp>

#include <absl/synchronization/mutex.h>

#include <geode/basic/pimpl_impl.hpp>

#include <geode/geometry/aabb.hpp>
Expand All @@ -41,7 +43,7 @@
namespace
{
constexpr geode::index_t NUMBER_2D_DIRECTIONS = 9;
const std::array< geode::Vector2D, NUMBER_2D_DIRECTIONS >& directions_2D()

Check warning on line 46 in src/geode/model/helpers/ray_tracing.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/helpers/ray_tracing.cpp:46:64 [readability-identifier-naming]

invalid case style for function 'directions_2D'
{
static const std::array< geode::Vector2D, NUMBER_2D_DIRECTIONS >
directions = { {
Expand All @@ -59,7 +61,7 @@
}

constexpr geode::index_t NUMBER_3D_DIRECTIONS = 13;
const std::array< geode::Vector3D, NUMBER_3D_DIRECTIONS >& directions_3D()

Check warning on line 64 in src/geode/model/helpers/ray_tracing.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/helpers/ray_tracing.cpp:64:64 [readability-identifier-naming]

invalid case style for function 'directions_3D'
{
static const std::array< geode::Vector3D, NUMBER_3D_DIRECTIONS >
directions = { {
Expand Down Expand Up @@ -298,10 +300,14 @@
private:
const AABBTree3D& surface_aabb( const Surface3D& surface )
{
if( aabb_trees_.contains( surface.id() ) )
{
return aabb_trees_.at( surface.id() );
absl::ReaderMutexLock read_lock{ mutex_ };
if( aabb_trees_.contains( surface.id() ) )
{
return aabb_trees_.at( surface.id() );
}
}
absl::MutexLock lock{ mutex_ };
return aabb_trees_
.emplace( surface.id(), create_aabb_tree( surface.mesh() ) )
.first->second;
Expand All @@ -310,6 +316,7 @@
private:
const BRep& brep_;
absl::flat_hash_map< uuid, AABBTree3D > aabb_trees_;
absl::Mutex mutex_;
};

BRepRayTracing::BRepRayTracing( const BRep& brep ) : impl_{ brep } {}
Expand Down
Loading