Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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

Discussion in 'Physics for ECS' started by Mr-Mechanical, Dec 8, 2019.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    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.
     
    MNNoxMortem likes this.
  2. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
  3. MaxAbernethy

    MaxAbernethy

    Joined:
    Mar 16, 2019
    Posts:
    53
    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.
     
    florianhanke and Mr-Mechanical like this.
  4. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    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.
     
  5. MaxAbernethy

    MaxAbernethy

    Joined:
    Mar 16, 2019
    Posts:
    53
    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!
     
    Mr-Mechanical likes this.
  6. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    Thanks a lot! I'm thinking about maybe modifying the ModifiableContactPoint/ModifiableContactHeader to simplify and only consider the closest points.
     
  7. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    So I'm assuming I have to remove EPA from the collision system as I explicitly only need closest points.