Find specific *index* of point from convex hull (not just Position) invlolved in a collision

Hello,

I am designing a physics engine that utilizes Unity Physics for its excellent collision detection implementation. I have hulls created from a dataset of vertices. I’d like to identify which vertex of the hull was involved in the collision without searching with comparison using the ModifiableContactPoint.Position to find the vertex in the dataset that was involved in the collision (it would be nice to have the index into the hull’s vertices). Is there any way to use an index of some sort as output from Unity Physics to get insight about which vertex in the hull was responsible for the collision?

Thanks a lot, I am looking for feedback on this problem.

1 Like

It seems what I am interested in is ModifiableContactPoint.Index but I’m not sure precisely what this represents. Can anyone help my understanding?
Edit: (new thread about ModifiableContactPoint.Index):

I don’t think there is a well defined answer. The manifold query used to make contact points has two steps:

  1. Find the closest points on the colliding shapes. This might be a vertex from each shape, but it might also be a vertex from one shape and a point in the middle of a face on the other shape, or even a point in the middle of an edge on each shape, among other possibilities. So it’s possible that both, one, or neither of the closest points is a convex hull vertex.

  2. Find intersections from a pair of faces containing the closest points. Without getting into the details, it’s possible for the contact points to include no vertices, one vertex, or many vertices from each shape.

If you explain more about what you’re trying to do, I might be able to make a suggestion.

2 Likes

This makes sense now, thank you for the clarification. Where is the manifold query code located (what file)? I’d like to examine it. Perhaps what I need is the faces or vertices involved? This could suit my needs.

Thanks a lot for your help.

See ConvexConvexManifoldQueries.ConvexConvex() in ConvexConvexManifold.cs. It uses ConvexConvexDistanceQueries.ConvexConvex() to get the closest points, then ConvexHull.GetSupportingFace() to find the faces containing those points with minimum angle from the separating normal. Hope that works for you!

1 Like

Thanks a lot! I’m thinking about maybe modifying the ModifiableContactPoint/ModifiableContactHeader to simplify and only consider the closest points.

So I’m assuming I have to remove EPA from the collision system as I explicitly only need closest points.