Search Unity

Lower-Fidelity Rigid Bodies (Havok)

Discussion in 'Physics for ECS' started by argibaltzi, Nov 5, 2020.

  1. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    Hello
    I was looking at the Unite Copenhagen video again and i noticed some talk about these lower-fidelity rigid bodies which can be used to speed things up

    Is this feature currently available and if so how to use it?

    Thanks!
     
  2. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    We are working on exposing those from the Havok Physics for Unity plugin at the minute. We are also looking at ways to match behavior of the secondary bodies in the Unity Physics simulation backend.

    Can I ask what your use case for them will be?
     
  3. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    they are small and medium size debris from breakable objects, they are in large numbers and i need improved performance on them if possible

    Although i understand both unity and havok need to operate the same way.... being able to add a HavokLowerFidelity component data on an entity is not the end of the world

    Being 99% the same is good enough and those who choose one engine over the other, a few extra features should be available to them

    I have a small twitter video you can see
    https://twitter.com/ArgiBaltzi/status/1322292555011235840
     
    steveeHavok likes this.
  4. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Good to know your needs. Its worth noting that the following caveats come with the secondary body performance benefits:

    • Secondary Bodies don't effect Primary Bodies
    • Secondary Bodies all have the same mass (lets call is 1kg)
    • Secondary Bodies can't have an offset center of mass
    • Secondary Bodies don't support joints
    • Secondary Bodies use a single simple convex hull for collision with Primary Bodies (i.e. no compounds)
    • Secondary Bodies use a sphere representation for collisions with other Secondary Bodies
    • Secondary Bodies have their own query tree for raycasts etc.

    In the meantime, do your debris pieces need to collide with each other? Could you get away with spheres that have a higher rotational damping?
     
    florianhanke and NotaNaN like this.
  5. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    128
    Sounds perfect for my use case as well if it would be in Unity Physics, not only Havok.
     
  6. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    I am using boxes for everything, i was not sure how lower-fidelity functioned so i thought i ask. Only the larger debris have debris-debris collision because its too expensive to enable for all, but i do want them to collide with primary colliders.

    I seperate them in 2 groups
    Smaller Size Debris
    Larger Size Debris

    So i guess this lower-fidelity colliders are only good for colliding with each other then

    Is sphere collider the fastest collider in the engine? how does it compare with a box?
     
  7. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Yes, sphere collider is the fastest, it only solves 1 contact point, while box solves 4. They are pretty much the same in the first couple of phases, but then "BuildJacobians" and "SolveJacobians" differ because of the 4 times less contact points.
     
    WAYNGames likes this.
  8. gmentat

    gmentat

    Joined:
    Nov 12, 2012
    Posts:
    15
    @argibaltzi Great video!

    I'm wondering what are possible ways to make compound physics bodies which you could dynamically decompose at runtime?

    My guess was to add PhysicsShapes and remove them later, but they get merged during conversion to entity. Another idea is to use fixed joints...

    And @steveeHavok mentioned secondary bodies. Is there are way to use them currently (or maybe skip the shape merging)?
     
    Last edited: Nov 9, 2020
  9. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Secondary bodies are not there yet, we are working on them.

    Regarding skipping of shape merging. Although they are merged into compound, you still get individual colliders as child colliders. You can use them as colliders to instantiate new entities when you want to split the thing.
     
    gmentat likes this.
  10. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    @gmentat all physics work is done in code(no conversions)
    i create a new entity with a new dynamic body and new compound collider and then move the renderers from one entity to another, this is one long expensive function....

    secondary bodies will help a with physics "particle" type geometry like i have, hope they come soon
     
    petarmHavok and gmentat like this.