Skip to content

Commit

Permalink
Switch back to strict comparisons for overlaps
Browse files Browse the repository at this point in the history
  • Loading branch information
saibalde committed Sep 18, 2024
1 parent 8619709 commit a05d7c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions examples/spheres/collision_sphere.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -91,14 +93,17 @@ 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:
int global_id_;
double radius_;
bvh::m::vec3d centroid_;
bvh::bphase_kdop bounds_;

private:
static constexpr double buffer_ = 0.01;
};

#endif
2 changes: 1 addition & 1 deletion src/bvh/kdop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit a05d7c6

Please sign in to comment.