Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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:
    1,687
    @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.
     
    JosepMariaPujol and Kmsxkuse like this.
  2. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    1,687
    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,509
    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.