Arcade physics: performance, scalability and internals?

Hi everyone,

I am trying to use the most performant physics library for a 2D game with simple physics where AABB collision detection are fine. Since Arcade is the simplest physics engine, I expect it to perform better than Matter.js or Ninja, is that right?

Then, I wonder if someone knows the time complexity of the physics engine as an input of the number of elements. Is it linear? or O(n * log n)?

Related to the latter, I wonder if internally it uses quadtrees, or a grid space representation, or otherwise how does it avoid having to compare every object against every other object for collisions, leading to O(n^2).

Thank you in advance!

It should be more performant than Matter, yes.

I’d guess movement time is linear with the number of dynamic bodies. There is one rtree for static bodies and one rtree for dynamic bodies (unless disabled). Some collision tests search the trees and some iterate each body–body pair. For sprite vs. group collisions there’s also a group contains check.

1 Like