ncollide icon indicating copy to clipboard operation
ncollide copied to clipboard

Add a CollisionWorld method that checks if two colliders are touching.

Open sebcrozet opened this issue 7 years ago • 4 comments

The current way of doing this is collision_world.contact_pair(handle1, handle2).unwrap_or(false).num_contacts() > 0 but it is verbose and does not cover cases where the collision query is a proximity.

sebcrozet avatar Dec 19 '18 13:12 sebcrozet

Hi, I can take this issue if it's still open.

ChinYing-Li avatar Jun 21 '20 14:06 ChinYing-Li

@ChinYing-Li Thanks! Yes, this is still open.

sebcrozet avatar Jun 21 '20 15:06 sebcrozet

I wonder if branch ISSUE252 looks like what you have in mind?

ChinYing-Li avatar Jun 23 '20 01:06 ChinYing-Li

Thank you for your suggestion. It would be best to open a PR with your issue252 branch so simplify the review process. Whether or not this looks like what I had in mind, a PR will allow me (or someone else) to add comments and suggestions.

To answer your question: I was thinking of reusing the preexisting information available in the contact graph and proximity graph, i.e., do a check similar to

let (_, _, interaction) = self.interaction_pair(false).unwrap_or(false);
match interaction {
    Interaction::Contact(_, manifold) => {
        // If the deepest contact multiplied by -1 of the manifold is smaller than 0, return Proximity::Penetrating
        // If it is smaller than the sum of the linear prediction (obtained from the collider's `GeometricQueryType`), return Proximity::WithinMargin.
        // Other wise return Proximity::Disjoin.
    }
    Interaction::Proximity(_, prox) => prox
}

sebcrozet avatar Jun 23 '20 08:06 sebcrozet