From a05d7c604df5359881b449da2c233fb07a34307c Mon Sep 17 00:00:00 2001 From: Saibal De Date: Thu, 27 Jun 2024 19:13:43 -0700 Subject: [PATCH] Switch back to strict comparisons for overlaps --- examples/spheres/collision_sphere.hpp | 11 ++++++++--- src/bvh/kdop.hpp | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/spheres/collision_sphere.hpp b/examples/spheres/collision_sphere.hpp index 70daa55..f3cc855 100644 --- a/examples/spheres/collision_sphere.hpp +++ b/examples/spheres/collision_sphere.hpp @@ -56,7 +56,8 @@ class CollisionSphere { : global_id_(s.global_id()), radius_(s.radius()), centroid_(s.position()), - bounds_(bvh::bphase_kdop::from_sphere(s.position(), s.radius())) {} + bounds_(bvh::bphase_kdop::from_sphere(s.position(), + (1.0 + buffer_) * s.radius())) {} KOKKOS_INLINE_FUNCTION CollisionSphere & operator=(const CollisionSphere &) = default; @@ -69,7 +70,8 @@ class CollisionSphere { global_id_ = s.global_id(); radius_ = s.radius(); centroid_ = s.position(); - bounds_ = bvh::bphase_kdop::from_sphere(s.position(), s.radius()); + bounds_ = bvh::bphase_kdop::from_sphere(s.position(), + (1.0 + buffer_) * s.radius()); return *this; } @@ -91,7 +93,7 @@ class CollisionSphere { bool is_colliding_with(const CollisionSphere &other) const { return bvh::m::length(centroid_ - other.centroid_) <= - radius_ + other.radius_; + (1 + buffer_) * (radius_ + other.radius_); } private: @@ -99,6 +101,9 @@ class CollisionSphere { double radius_; bvh::m::vec3d centroid_; bvh::bphase_kdop bounds_; + +private: + static constexpr double buffer_ = 0.01; }; #endif diff --git a/src/bvh/kdop.hpp b/src/bvh/kdop.hpp index f75b07d..a91b76c 100644 --- a/src/bvh/kdop.hpp +++ b/src/bvh/kdop.hpp @@ -121,7 +121,7 @@ namespace bvh BVH_INLINE constexpr bool overlap( const extent< T > &_lhs, const extent< T > &_rhs ) noexcept { - return _lhs.min <= _rhs.max && _rhs.min <= _lhs.max; + return _lhs.min < _rhs.max && _rhs.min < _lhs.max; } /**