Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Can we use DOTS Physics just for spatial queries (without physics)?

Discussion in 'Physics for ECS' started by Mike37, Jul 28, 2022.

  1. Mike37

    Mike37

    Joined:
    Oct 21, 2018
    Posts:
    26
    I have a bunch of AABBs and I'm looking for a solution to speed up queries against them, but I don't actually need any physics simulation. Is this something that could be done easily with Unity Physics? Is there an example anywhere?
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    That is DOTS physics primary purpose - spatial queries, and it is very good at them. Search Unity's github for samples.
     
  3. insectivore

    insectivore

    Joined:
    Apr 30, 2021
    Posts:
    1
    Dots physics says it is stateless

    Stateless
    Modern physics engines maintain large amounts of cached state in order to achieve high performance and simulation robustness. This comes at the cost of added complexity in the simulation pipeline which can be a barrier to modifying code. It also complicates use cases like networking where you may want to roll back and forward physics state. Unity Physics forgoes this caching in favor of simplicity and control.
    Does that mean that the entire bounding volume hierarchy is rebuilt each simulation step? In which case if the number of queries is small compared to the log of the number of volumes (times constant factors) it would be cheaper to check against every volume than to `BuildPhysicsWorld` for one spatial query.