Search Unity

Modify the engine by custom polar colliders

Discussion in 'Physics for ECS' started by Sab_Rango, Feb 18, 2021.

  1. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121
    Hey! I am trying to create custom collider detection!
    It's simple "polar collision" like ray marching mesh creating by ++, +-, behaviors meetpolarcolliders.png So - (negative) collider omits collision of neighbor collider.


    But, to me, the most hard part is to find a proper system to add this tech to DOTS physics.

    I know that collider shapes structs located in this direction\\\\
    com.unity.physics@0.6.0-preview.3\Unity.Physics\Collision
    and main collision response system scripts located somewhere here\\\\\\
    com.unity.physics@0.6.0-preview.3\Unity.Physics\Dynamics\Jacobians
    probable main physics controlling system located here\\\\\\
    com.unity.physics@0.6.0-preview.3\Unity.Physics\ECS\Base\Systems


    Right now, it's crucial to understand the engine architecture.

    My main question is How can I add simple custom collision shape say sphere, or box and implement the shape to the engine system? Which scripts should I embed and play around with to learn the engine systems?

    If I manage to comprehend DOTS physics architecture with this simple way then I will do my best to modify it with my "polar collision" system .
     
  2. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Have you seen our callbacks (your jobs need to implement IBodyPairsJob, IContactsJob or IJacobiansJob) and samples that use them?
    I'm not 100% sure I understand what needs to happen in "polar collisions", but it seems like you want to mark bodies with + or - and then affect the way they're colliding. Sounds like IJacobiansJob would do the trick, but if there's more to it please help me understand the use case better.
     
  3. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121
    Thx!
    Having seen all the specific samples I noticed any data can be accessed from the engine.

    Indeed, my aim is make these colliders from 2 spheres:
    - and +
    +-coll.png



    - and -
    --collider.png

    final results
    resulcollider.png



    If it works as it supposed to be, I will try to make complex colliders from multiple polar spheres and different polar shapes like capsule, box, plane, etc..
     
  4. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Ahaam, looks like you want to destroy the 2 colliding bodies and spawn a new one (shape type Convex Hull) that has the desired shape.
     
    Sab_Rango likes this.
  5. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121
    By the way, I am also trying to approach to create LOD system to my custom colliders like this way:

    At the beginning,
    LOD:01 simple Box collider

    LOD01.png


    next, if a collider triggers 1st LOD:01 collision, run second LOD:02 with physics response

    LOD:02

    LOD02.png

    What do you think, Is it better to create this LOD system inside the Unity Physics package scripts or
    outside the package with the engine callbacks?
     
  6. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Always better to do it inside, if you are not afraid of editing packages. Gives you more control and access to more data. But be careful, it can make you go fully wide and edit more than you aimed for. :)

    We haven't really prioritized LOD that much so far, although it's definitely possible to add a wrapper around the collider which is a collider itself, but gives you a different underlying collider depending on the LOD type currently set. At least that's how I would do it. :)
     
    Sab_Rango likes this.
  7. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    @Sab_Rango Just to clear things up a little, can I ask if you are talking about a specific custom implementation of a Signed Distance Field (SDF) shape for runtime collision detection and resolution, or are you talking about Constructive Solid Geometry operations to create new geometry for a Mesh Shape?
    I assume you are talking about the former (specific SDF implementation) as the Death Star-like +- result is concave and would not be very performant at runtime.
     
    Sab_Rango likes this.
  8. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121
    @steveeHavok Although I don't have a solid plan about it, but I want to make smth fast and precise tools to my physics based AI characters.;)
    Also, I should manage to built character joints manually, test consequent physics performance issues like skin, joint pressure that need to be fixed to achieve real time hyper realistic ML body interactions.

    So I need smth new tech anyway!:)