Search Unity

Ellipsoid colliders

Discussion in 'Physics for ECS' started by illinar, Sep 7, 2020.

  1. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Fortunately we might have the best people in physics engine building here who could definitely answer this question:

    Are ellipsoid collisions expensive to calculate?

    I would love to have ellipsoid colliders in DOTS for organic things, detailed ragdolls and soft body simulation. But I have no idea what math is involved there and if it is viable for the engine. Maybe it is viable for the described use cases. I want to do in DOTS what Obi Soft Body is doing in Unity PhysX.
     
    Last edited: Sep 7, 2020
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Let me split this into two parts.

    Rigid ellipsoid colliders could probably be done, not sure what the performance would be, but surely slower than capsules. Now I don't know what exactly is the use case for these, since in most cases simple capsules probably do the trick, but typically any new collider we would add needs to go through implementation of the ICollider interface, plus some work on the collision pipeline to handle this new shape. I suggest looking at one collider type in the code (say capsule) and seeing in which places inside the engine special code needs to exist.

    On the other hand, if you need ellipsoid collider only to deform a sphere in soft body simulation, then no luck. Our focus has always been rigid bodies and I expect that to remain the case.

    Let me know if there is a followup question, I'd be happy to answer.
     
    illinar, cultureulterior and Edy like this.
  3. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    You could largely fake an ellipsoid collider with a small convex hull and a relatively large bevel radius.

    The convex hulls in Unity Physics tend to shrink the original graphics geometry planes and add a numerical radius to push the collision surface back out. Corners and edges can be rounded but the performance improvements and a stability are worth it.

    Convex Radius Displacement.png
    So a sphere could be a Convex Hull with a single vertex and an appropriate bevel radius. A triangle could be considered as a convex hull with 3 vertices and no extra radius. A capsule could be a convex hull with 2 vertices and an appropriate radius.
    So a tapered capsule, or an ellipsoid could also be approximated with an basic underlying Convex Hull and an appropriately large radius.
     

    Attached Files:

  4. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    How good an elipsoid collider is for a rid body sim depends on it's performance. But it does describe flattish roundish geometry better than capsules and spheres. But, yes, it's best use is for some soft body sim.

    To replace it I would use a 4 triangle pyramid like colliders.

    upload_2020-9-18_11-3-57.png

    Maybe with even bigger bevel radius. But I'm not very optimistic about the performance.
     
    Last edited: Sep 18, 2020