Fastest Physics Engine

Hi!

What is the fastest physics engine? I am using cannon but wondering if oimo or ammo would be better. I have a lot of physics impostors (1000 ish) and would like to have the best performance.

Thanks!

The two main issues of your voxel-like project seem to be:

  1. The physics engine. You need a proper broadphase when using that amount of bodies. If you don’t care about dynamics, do your own basic physics. AABBvsAABB collisions using SAP are Very cheap and Very easy to do. When it comes to broadphases, a simple grid should suffice, otherwise there are plenty of AABB trees or quat trees to choose from. Something to think about here as well is taking multiple voxels and group them under a single body. Then whenever a voxel is removed, recalculate the bodies affected.

  2. The rendering. 1000 instances are quite a lot. I can easily render 10000 boxes with the SPS, but adding and removing meshes might be a bottleneck, as it takes about 80ms to create said 10000 particle mesh.
    Look at what different voxel engines do. They usually split geometry into chunks of voxels. 10x10x10 would be a decent start. Now you have to figure out how exclude certain meshes from rendering. A 10x10x10 chunks only has a small percentage of the actual voxels visible, and everything between visible voxels should be excluded. People usually do this by checking all 6 sides of a box/voxel. If any of the sides are Not populated by another voxel, it should be rendered. This can be done when you initialize the map/engine, and then again whenever you add/remove a voxel - but this time the calculations are only needed for the added/removed voxels and the nearest neighbors.

If you really want to use a bigger engine, Oimo and Ammo have the best broadphases for this scale. I would say Ammo, as I’m a bit of a fanboii. But you’ll get the best performance out of doing it yourself, as long as you don’t need contact points, manifolds, dynamic objects and the more advanced physics features in general.

Cool! Thanks for the detailed response. I’ll look into using a proper broadphase and renderer

If you need inspiration, take a look at Noa Engine:

Or maybe just use that?
It’s the engine behind:
https://nesh108.github.io/babylon-voxel-demo/
https://classic.minecraft.net

The whole reinventing the wheel, you know.

1 Like

+1 for @fenomas’s awesome NOA engine! Andy did such an awesome job on this project, and Mojang loves his engine!

2 Likes

Haha, no evidence of that but it’s very nice of you to say!

@givo: are you doing something voxel-based? If so then I can definitely answer questions, and you might find my engine useful. But it looks like you’re not doing anything voxel-ey, in which case here’s general advice:

  1. Physics engines all do fairly similar things under the hood, and my experience is that they tend to perform similarly for typical cases. So if the engine you’re currently using is working so far, I’d stick with it. A different engine might perform a little better, but it’s unlikely to be 2x or anything - and as your game changes in the future, which engine performs best may change as well.

  2. If possible, either make a game or make an engine, don’t try to make both at once. As such, I strongly suggest not to roll your own engine. It’s really fun to do, but it’s not a good way to make a game. (now if only I could take my own advice…)

  3. Even if you don’t roll your own physics you’ll probably need some kind of broadphase AABB tests (e.g. to find all the entities in a given room). If so, use this library. It’s crazy fast (the blog posts linked from the readme explain the algorithms involved).

Hope this helps!

4 Likes

Yeah I am making something voxel-ey https://playground.babylonjs.com/#D1Z1VL#21 on a good pc it performs well.

It’s just a little coding practice before NYNS. :wink: It would be cool to replicate minecraft though.

Ah, I see. So the basic thing with voxels is that even a tiny world has way too many voxels to treat them as regular cubes the physics engine or rendering engine. The fix is, on the physics side to treat voxel terrain as one big meta-object, and collide it with bodies via custom logic. On the rendering side, the fix iso to preprocess voxel terrain into larger meshes, rather than using separate polys for each voxel face.

Regarding the former, I don’t know any good resources, but for source code this is my engine (I don’t know of any others). For rendering, this article is where I got my start.

Oh. Thanks for the article and the source code.