25-12-2017, 08:15 PM
(This post was last modified: 26-12-2017, 10:32 AM by josemendez.)
(24-12-2017, 03:55 AM)writer51 Wrote: I was wondering if there is documentation anywhere regarding the performance of obi on primitive vs mesh colliders. I seem to be getting a very noticeable performance drop in editor from subscribing to collisions on a mesh collider vs primitive colliders (tested boxes, capsules - all seem fine). Is this just a natural consequence of using mesh colliders- just seem strange, I go from 135 fps with primitives down to 40 fps with mesh collider, everything else being the same.
MeshColliders are extremely costly compared to primitive colliders. This is always the case, however when it comes to collision detection against hundreds of particles (which is what Obi does) the problem is exacerbated. Even though Obi uses a hierarchical data structure to prune collisions against most of the collider's triangles, each triangle in the mesh collider costs roughly the same as single primitive collider.
The next update will feature adaptive signed distance fields. These are basically large arrays that store the distance from any point in space to the surface of the MeshCollider. At runtime, each particle simply has to read a value from this array, and check its sign to see how far from the collider it is or if it has collided or not. These are much faster than regular MeshColliders, and incredibly robust. However they cannot be created at runtime (well they can, but it takes a lot of time) and they consume more memory than regular colliders.