Search Unity

Accessing broadphase AABBs

Discussion in 'Physics for ECS' started by WildMaN, Oct 9, 2020.

  1. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    128
    As far as I understand, AABBs are calculated during the broadphase for each colliding body. Is there a way to access that data using entity id, BodyIndex or such ?
     
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Unfortunately, they are only produced during the process of the bounding volume hierarchy build. You can take a look at PrepareDynamicBodyDataJob and PrepareStaticBodyDataJob to see how they are calculated and recalculate them wherever you need them.

    Leaves of the bounding volume hierarchy do contain these AABBs, and there is data in them to point at the rigid body index, but you don't get direct access, you'd have to iterate through all of them. Check DisplayBroadphaseSystem for that, but it seems like it doesn't fit that well in what you need.