From 11cb074f9576bbd31bedd0ec6890428e0c5a2f02 Mon Sep 17 00:00:00 2001 From: MarieENSG Date: Wed, 3 Jun 2026 10:23:34 +0200 Subject: [PATCH] feat(MedialBallsExtractor): mutex in ray tracing --- src/geode/model/helpers/ray_tracing.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/geode/model/helpers/ray_tracing.cpp b/src/geode/model/helpers/ray_tracing.cpp index 4aabbd998..7076e9a0e 100644 --- a/src/geode/model/helpers/ray_tracing.cpp +++ b/src/geode/model/helpers/ray_tracing.cpp @@ -23,6 +23,8 @@ #include +#include + #include #include @@ -298,10 +300,14 @@ namespace geode 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; @@ -310,6 +316,7 @@ namespace geode private: const BRep& brep_; absl::flat_hash_map< uuid, AABBTree3D > aabb_trees_; + absl::Mutex mutex_; }; BRepRayTracing::BRepRayTracing( const BRep& brep ) : impl_{ brep } {}