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
14 changes: 6 additions & 8 deletions src/impl/vamp/collision/capt.hh
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ namespace vamp::collision
// Returns `true` if in collision and `false` if not.
[[nodiscard]] auto collides(const Point &center, float r) const noexcept -> bool
{
if (aabb_top.distsq_to(center) > r * r)
// Pad query radii by radius of points.
r = r + r_point;
const float radius_sq = r * r;
if (aabb_top.distsq_to(center) > radius_sq)
{
return false;
}
Expand All @@ -383,8 +386,6 @@ namespace vamp::collision

const std::size_t z = test_idx - tests.size();

r += r_point;
const float radius_sq = r * r;
if (aabbs[z].distsq_to(center) > radius_sq)
{
return false;
Expand Down Expand Up @@ -423,6 +424,8 @@ namespace vamp::collision
// - `radii`: SIMD vector of the radii of each sphere.
auto collides_simd(const std::array<FVectorT, 3> &centers, FVectorT radii) const noexcept -> bool
{
// Padd radii by radius of points.
radii = radii + r_point;
// Test against top AABB
FVectorT inbounds =
(centers[0] + radii >= aabb_top.lower[0]) & (centers[0] - radii <= aabb_top.upper[0]);
Expand Down Expand Up @@ -453,11 +456,6 @@ namespace vamp::collision

const IVectorT zs = idxs - tests.size();

// Test whether points are in the AABBs
// NOTE: Now is when we need to add r_point, since these AABBs are really "point volume AABBs" -
// we can't just test if the query is in the AABB, but rather if it's in the AABB when fattened by
// the radius of the points the AABB contains
radii = radii + r_point;
IVectorT zs6 = zs * 6;
const float *const aabb_ptr = &aabbs.front().lower.front();

Expand Down
Loading