Conversation
claytonwramsey
left a comment
There was a problem hiding this comment.
slightly confused on how the collision-checking kernel works but everything else looks OK
| auto dist = dot_3(p.nx[i], p.ny[i], p.nz[i], cx, cy, cz) - p.d[i] - r; | ||
| max_dist = max_dist.max(dist); | ||
|
|
||
| if (max_dist.test_zero()) |
There was a problem hiding this comment.
I'm not sure I understand why this test_zero is here -- it seems unlikely for a sphere to be perfectly tangent to the plane?
There was a problem hiding this comment.
See above - checking if all distances from planes is above zero.
| for (auto i = 0U; i < p.num_planes; ++i) | ||
| { | ||
| // dist = n.C - d - r (positive = separated) | ||
| auto dist = dot_3(p.nx[i], p.ny[i], p.nz[i], cx, cy, cz) - p.d[i] - r; |
There was a problem hiding this comment.
If I'm reading this correctly, this means that we compute max_dist as the maximum projected distance to any surface plane of the polytope. I think that would yield incorrect results when the nearest point on the polytope to the sphere is a vertex, rather than on one of the planes.
I think the correct algorithm would be to iteratively project the center
Did I miss something?
There was a problem hiding this comment.
I think a completely correct approach would be something iterative as you describe, but I didn't have the time to think about how to do this properly in SIMD. Instead I did a conservative approach which does "fail" near the vertices as you say. I'm checking for the separation of the sphere with any of the halfspaces defining the polytope, if the sphere is separated by any of them (i.e., the distance is positive) we aren't in collision with the polytope. This is also what the test_zero check is for, it's the poorly named "check if first bit is zero" function to see if all spheres have a maximum distance that is positive.
Adds basic polytope obstacle avoidance with OBB broadphase and then checking separation with halfspaces (no GJK yet...). Adds a CPM dependency on cddlib to compute convex hulls and convert between vertex/halfspace representations.
2026-02-12.12-09-36.mov