Repository navigation
Use predicted velocities in the narrow phase to fix compound tunneling - #429
Open
Nigel-Bess wants to merge 1 commit into
Open
Nigel-Bess wants to merge 1 commit into
Nigel-Bess wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the bug reported in #390, with a repro in #388.
Problem
PredictBoundingBoxesintegrates velocity up front to expand bounding boxes, but then throws the integrated velocity away. The broad phase finds the compound's overlap using the predicted velocity. The narrow phase's compound child overlap test then expands child bounds using the stored, pre-integration velocity. With a largedt * acceleration(the #388 repro usesdt = 0.12with gravity of 9807 mm/s²), the child bounds never reach the floor, so no child pair is created and the compound falls through. An identical non-compound box is unaffected.Fix
This is option 2 from your comment on #388:
PredictBoundingBoxesstores the integrated velocities inBodies.PredictedVelocities.NarrowPhase.HandleOverlapreads them throughGetVelocityForCollisionDetection, so the CCD sweep and the compound/mesh child bounds tests use the same velocity as the broad phase.Simulation.CollisionDetectionand wheneverRemoveFromActiveSetreorders the active set. Bodies added after prediction fall back to their stored velocity.The cost is one extra
BodyVelocitywrite per active body during prediction, plus the buffer.Testing
I ran a headless version of the #388 scene (compound vs. plain box,
dt = 0.12, 30 steps) across 1 and 4 substeps, Discrete/Passive/Continuous, with and without a thread dispatcher.All 12 configurations fail before the change and pass after it.