Skip to content
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::overlaps false negative for edge cases #435

Open
jallmenroeder opened this issue May 8, 2024 · 0 comments
Open

AABB::overlaps false negative for edge cases #435

jallmenroeder opened this issue May 8, 2024 · 0 comments

Comments

@jallmenroeder
Copy link

jallmenroeder commented May 8, 2024

The AABB::overlaps function misses overlaps when one of the AABBs is 0 in one dimension.
Example:

AABB a(float3(-1, -1, -1), float3(1, 1, 1));
AABB b(float3(-1, -1, 0), float3(1, 1, 0));
assert(a.overlaps(b));

Since the overlaps function relies on the volume of the intersection of the two AABBs, which is 0 in this case, the assert fails.
This can happen in practice, if you have an axis aligned triangle, create its AABB and use it to "early out" of an intersection test.

One solution could be to only check if the intersection AABB is valid.

/// Returns true if the two AABBs have any overlap.
bool overlaps(AABB b)
{
    b.intersection(*this);
    return b.valid();
}

However, this would return true for "touching" AABBs. Depending on the definition of "overlaps", this might be a problem.

Would love to hear your thoughts on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant