Search Unity

Feature Request Performance improvement for massive amount of colliders

Discussion in 'Physics for ECS' started by optimise, Feb 2, 2023.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    @JosepMariaPujol Not really sure but is that currently have something called incremental update bounding volume hierarchy or something similar that only that will change so basically those static collider that will never will be excluded from bounding volume hierarchy update since most of the colliders are static.
     
    lilacsky824, JMPM-UNITY and Kmsxkuse like this.
  2. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    If I understand correctly, looks like the current implementation is static and dynamic physics collider are splitted as separate chunk to process. What if we combine both of them into same single chunk and do incremental bounding volume hierarchy update for the physics collider that actually moving i.e. change position/rotation. Looks like it will much more faster that we process all the physics colliders in one single chunk no matter it's static or dynamic physics collider?
     
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    Currently due to new transform systems statics will rebuild every frame due to LocalToWorld change filter triggering. I'm sure this is just an oversight due to transform V2 reworks and it'll eventually be solved.

    I believe you can fix this I believe by changing this line

    Code (CSharp):
    1. chunk.DidChange(ref LocalToWorldType, m_LastSystemVersion) ||
    To something like,
    Code (CSharp):
    1. (!chunk.Has(ref LocalTransformType) && chunk.DidChange(ref LocalToWorldType, m_LastSystemVersion)) ||
    To only do the local to world change filter check if it oesn't have local transform (in which case it'll rely on localtransform type change filter instead)

    Not thoroughly tested, I just randomly looked into why statics were updating every frame a few weeks ago.
     
  4. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Unifikation likes this.
  5. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    277
    In a test with the recent version of Unity Physics this condition does not always lead to true. So I guess if this issue existed it is now resolved.
    From what I can tell the CheckStaticBodyChangesJob works as expected at the moment. Let me know if you are observing issues here.
     
  6. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    277
    The idea of incremental bounding volume update in the collision detection, specifically for use cases with massive number of static colliders, is definitely on our radar. At this time, we can unfortunately not provide any specific timeline or guarantee that we are moving ahead with an implementation though.
     
  7. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    Yeah it was fixed in one of the earlier previews

    From discord,

    https://discord.com/channels/489222168727519232/1072222747192721589/1076186844892508251
     
    daniel-holz likes this.
  8. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Hi. Any new update for this feature request?
     
  9. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    277
    We've been looking into the details surrounding this feature and it's next in line.
    Again, I can unfortunately not give any outlook yet at this stage as to if and when this is gonna land in a release.
    I hope you understand.
     
    Kmsxkuse and optimise like this.