X Tutup
Skip to content

Fix CCD bodies adding multiple contact manifolds when using Jolt#110914

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
mihe:jolt/multiple-contact-callbacks
Sep 26, 2025
Merged

Fix CCD bodies adding multiple contact manifolds when using Jolt#110914
Repiteo merged 1 commit intogodotengine:masterfrom
mihe:jolt/multiple-contact-callbacks

Conversation

@mihe
Copy link
Contributor

@mihe mihe commented Sep 25, 2025

Fixes #110757.

The code in JoltContactListener3D::_try_add_contacts, as called by Jolt through its JPH::ContactListener callback interface, does not currently take into account that CCD collisions can cause it to be called multiple times in a single physics step for the same shape pair. This means that a RigidBody3D with continuous_cd enabled, as well as a non-zero max_contacts_reported, can end up with a list of contacts that actually make up two different contact manifolds, which is bad.

In 4.5-stable this also resulted in an error about reserve() called with a capacity smaller than the current size, but which has since been relegated to a --verbose warning as of #110826.

This PR fixes all that by simply doing an early-out from JoltContactListener3D::_try_add_contacts if the shape pair in question already has a set of contacts.

@MajorMcDoom
Copy link
Contributor

Tested locally, and it seems to have fixed the errors in my game. :)

@Repiteo Repiteo merged commit e9cd9a9 into godotengine:master Sep 26, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Sep 26, 2025

Thanks!

@MajorMcDoom
Copy link
Contributor

Thank you!
Just wondering, how/when does the 4.5 cherrypick happen?

@mihe mihe deleted the jolt/multiple-contact-callbacks branch September 27, 2025 09:15
@Repiteo
Copy link
Contributor

Repiteo commented Sep 30, 2025

It happens… Now!

Cherry-picked to 4.5

@Repiteo Repiteo removed the cherrypick:4.5 Considered for cherry-picking into a future 4.5.x release label Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LocalVector::reserve() errors during collisions when using continuous collision detection with Jolt physics

4 participants

X Tutup