Search Unity

Question Collision and intersection points

Discussion in 'Physics for ECS' started by Blackfire-Studio, Aug 25, 2022.

  1. Blackfire-Studio

    Blackfire-Studio

    Joined:
    Dec 17, 2013
    Posts:
    185
    Hi there,

    I'm completely new to DOTS and DOTS Physics but I'm wondering if this system would allow to compute points of intersecting shapes (primitives, mesh, convex hull).
    If possible, any clue on how to achieve this would be awesome.
    Here's a great example coming from : https://github.com/jeffvella/UnityNativeCollision

    Thanks a lot !
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,975
    The project you linked to already does what you ask for and is DOTS enabled (uses Burst, native containers and so on).

    Applying that to physics should just be a matter of converting those shapes to physics colliders.
     
  3. Blackfire-Studio

    Blackfire-Studio

    Joined:
    Dec 17, 2013
    Posts:
    185
    Thanks for the answer.
    I achieved to get something interesting without having to jump onto integrating that library. But I still have a few wonders.

    To get those intersecting points, I am using a mesh as a collider, a
    PointDistanceJob
    and collects results using
    DistanceHits
    . I am able able to collect every intersecting point between the mesh and any other shape.
    If I switch from using a mesh and use a primitive, I am only able to get one intersecting point. Is there a way to get multiple points using primitives ?
    Also, I can get intersecting/hit points main properties (position and surface normal) but I would like to be able to retrieve other properties such as :
    • point velocity on contact
    • point normal (not hit surface normal but point on mesh used for the query)
    • object velocity
    Could I get those properties using that approach ? Or maybe there's an other approach that could help me get these points with those properties ?
    Thanks !
     
  4. Blackfire-Studio

    Blackfire-Studio

    Joined:
    Dec 17, 2013
    Posts:
    185
    I think that the most useful thing would be to be able to get data from the points on the collider mesh (vertex index, triangle index, etc.) not only from the colliding/hit mesh.
    But for the moment I can only get the original position using the hit position, hit normal and distance.