-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AABB.intersectSegment returns NaN in hit collider response object #9
Comments
@noonat I hate to be a pest but, any thoughts on this? |
@noonat I figured out the problem. It's possible for the fix in #10 is pretty simple, we just check to see if I also added a unit test to reproduce this problem. |
I also ran into this issue. Collision detections fail when The work-around is to set the near and far values to infinity in such cases. This can lead to false-positives ("ghost collisions") so you also need to add a broad-phase check. Unfortunately @mreinstein's fix did not work for me; I think some edge-cases are missing. I got things working in my own code-base. Here is a snippet, which isn't compatible with this repo, but hopefully gives the idea: // ....
if delta.X = 0.0f
then
xEntry <- Single.NegativeInfinity
xExit <- Single.PositiveInfinity
else
xEntry <- xInvEntry / delta.X
xExit <- xInvExit / delta.X
if delta.Y = 0.0f
then
yEntry <- Single.NegativeInfinity
yExit <- Single.PositiveInfinity
else
yEntry <- yInvEntry / delta.Y
yExit <- yInvExit / delta.Y
// ... Note the And this is the extra broad-phase check that removes ghost collisions: let computeBroadphaseBox (delta : Vector2) (box : AABB) =
// TODO: Make this more efficient
let nextBox = { box with Center = box.Center + delta }
let l = min (AABB.left box) (AABB.left nextBox)
let r = max (AABB.right box) (AABB.right nextBox)
let t = min (AABB.top box) (AABB.top nextBox)
let b = max (AABB.bottom box) (AABB.bottom nextBox)
{
Center = box.Center + delta * 0.5f
HalfSize = Vector2.create (r - l) (b - t) * 0.5f
}
let sweepAABBWithBroadphase (dynamicBox : AABB) (staticBox : AABB) (delta : Vector2) : SweepResult option =
let broadphaseBox = computeBroadphaseBox delta dynamicBox
if aabbCheck broadphaseBox staticBox
then
sweepAABB dynamicBox staticBox delta
else
None |
@njlr thanks for providing more details! ❤️ It would be helpful if you can submit test(s) that demonstrate what other broken cases you've discovered, using the actual API that
That makes me a little nervous, because It sounds like this workaround is trading one problem for another. A broadphase collision check shouldn't be required to filter out bad results, that doesn't feel right to me. |
my setup data:
Any ideas what's going on here? When I look at the internal implementation I see
nearTimeY
is being set toNaN
The text was updated successfully, but these errors were encountered: