Skip to content

Commit b38dfdc

Browse files
committed
test
1 parent de680f8 commit b38dfdc

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

src/geode/model/helpers/ray_tracing.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <geode/model/helpers/ray_tracing.hpp>
2525

2626
#include <absl/base/call_once.h>
27-
#include <absl/synchronization/mutex.h>
2827

2928
#include <geode/basic/pimpl_impl.hpp>
3029

@@ -238,7 +237,15 @@ namespace geode
238237
class BRepRayTracing::Impl
239238
{
240239
public:
241-
explicit Impl( const BRep& brep ) : brep_( brep ) {}
240+
explicit Impl( const BRep& brep ) : brep_( brep )
241+
{
242+
aabb_trees_.reserve( brep.nb_surfaces() );
243+
for( const auto& surface : brep.surfaces() )
244+
{
245+
aabb_trees_.emplace(
246+
surface.id(), std::make_unique< CachedTree >() );
247+
}
248+
}
242249

243250
BoundarySurfaceIntersections find_intersections_with_boundaries(
244251
const InfiniteLine3D& infinite_line, const Block3D& block )
@@ -307,26 +314,16 @@ namespace geode
307314

308315
const AABBTree3D& surface_aabb( const Surface3D& surface )
309316
{
310-
auto& entry = cached_tree( surface.id() );
317+
auto& entry = *aabb_trees_.at( surface.id() );
311318
absl::call_once( entry.built, [&surface, &entry] {
312319
entry.tree = create_aabb_tree( surface.mesh() );
313320
} );
314321
return entry.tree;
315322
}
316323

317-
CachedTree& cached_tree( const uuid& surface_id )
318-
{
319-
absl::MutexLock lock{ mutex_ };
320-
return *aabb_trees_
321-
.try_emplace(
322-
surface_id, std::make_unique< CachedTree >() )
323-
.first->second;
324-
}
325-
326324
private:
327325
const BRep& brep_;
328326
absl::flat_hash_map< uuid, std::unique_ptr< CachedTree > > aabb_trees_;
329-
absl::Mutex mutex_;
330327
};
331328

332329
BRepRayTracing::BRepRayTracing( const BRep& brep ) : impl_{ brep } {}

0 commit comments

Comments
 (0)