Skip to content

Bug + Fix: Contact between Shape and Composite Shape Issues #387

@dog-molecule

Description

@dog-molecule

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions