parry icon indicating copy to clipboard operation
parry copied to clipboard

Bug + Fix: Contact between Shape and Composite Shape Issues

Open dog-molecule opened this issue 2 months ago • 1 comments

I'm using Parry via the Rapier physics engine plugin for Godot. I noticed that shapecasts cast against composite shapes were returning bogus results, and on drilling down, I believe I've found the root cause.

It seems that in this case (composite shape/shape contact), an extra inversion is being performed on the vector that defines the relative positions of the two bodies. To illustrate, here's an image from Godot:

Image

The circle is casting a shapecast down, which is hitting a composite shape. However, the relative positional vector is being inverted, so the AABB that is being checked for contacts between the two shapes (drawn as a red square here) is exactly opposite (relative to the composite shape's origin) to where it should be. The fix is very simple; it's just a modification to line 58 of src/query/contact/contact_composite_shape_shape.rs:

    CompositeShapeRef(g1)
        //OLD: .contact_with_shape(dispatcher, &pose12.inverse(), g2, prediction) 
        .contact_with_shape(dispatcher, &pose12, g2, prediction) // NEW
        .map(|c| c.1)
}

It seems to fix the issue for me, but someone with Parry experience, please take a look at this and let me know if: A) you can replicate the issue in a non-Godot-Rapier environment and B) if I'm barking up the wrong tree with the solution :)

PR inbound with the fix.

dog-molecule avatar Oct 19 '25 14:10 dog-molecule

PR: https://github.com/dimforge/parry/pull/388

dog-molecule avatar Oct 19 '25 14:10 dog-molecule