Skip to content

Fix contacts being removed due to incorrect AABB usage#952

Merged
Jondolf merged 3 commits into
mainfrom
fix-aabbs
Mar 14, 2026
Merged

Fix contacts being removed due to incorrect AABB usage#952
Jondolf merged 3 commits into
mainfrom
fix-aabbs

Conversation

@Jondolf

@Jondolf Jondolf commented Mar 13, 2026

Copy link
Copy Markdown
Member

Objective

Right now, the broad phase queries trees using the tight-fitting AABB. The narrow phase also removes contact pairs when ColliderAabbs no longer overlap. However, the actual trees use enlarged AABBs. You can thus get a situation where a contact pair is created because the collider overlaps an enlarged AABB, and then immediately removed by the narrow phase. Not good!

There's also some inconsistent usage of margins and tolerances for AABB updates that need to be fixed.

Solution

Use enlarged AABBs in broad phase tree queries and the narrow phase. This also matches what Box2D does.

This also lets us get rid of ColliderTreeProxy::aabb, making proxies much more lightweight.

I also fixed and cleaned up some AABB update margins.

Testing

Ran some examples. Also ran a user-provided reproduction of an issue caused by this; it now works like expected.

@Jondolf Jondolf added this to the 0.6 milestone Mar 13, 2026
@Jondolf Jondolf added C-Bug Something isn't working A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Mar 13, 2026
@Jondolf Jondolf merged commit 94ce50d into main Mar 14, 2026
6 checks passed
@Jondolf Jondolf deleted the fix-aabbs branch March 14, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality C-Bug Something isn't working D-Straightforward Simple bug fixes and API improvements, docs, test and examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant