Jump to content

What's your prefered physics engine these days?


max123
 Share

Recommended Posts

In short: every javascript 3D physics engine lacks something important. Or not performant, or both.


I'm using Cannon js now (not using babylon's physics plugins because I need physics bodies on sprites, continous collision detection, trigger objects, collision events, separate fixed-time game logic/physics step and a lot more)
Even Cannon DOES not have a good capsule collider.

I think it is not the best performance, but every other lacks something i need (Oimo is faster, but has no heightmaps, no collision events, no trigger objects etc)
Cannon is easy to use, hard to master (to provide a stabile and smooth simulation without hiccups, vibrations or jumps, it needs many tweaking)

I think I see where Cannon js's bottleneck is: it has a single axis broadphase separation, but no working grid or octree based broadphase.
And it is written in a non-performant object oriented "textbook" way.

Maybe Energy js will be more performant (transpiled from C++), but from the documentation It maybe will miss important elements in a game like collision events and trigger (collision only) bodies.

Maybe someone has other engine suggestions!?

 


 

 

 

Link to comment
Share on other sites

I am using cannon as well.  I started out using both interchangeably and was always having trouble with Oimo not working as I would expect.  I am very happy with cannon and looking forward adding the new physics lockstep integration where I can ensure the deterministic behaviour across different devices.  Here is the post by santarcade:

 

Link to comment
Share on other sites

There is CannonJS, Oimo, AmmoJS, and Goblin Physics, to name a few. And like BitOfGold said, each one has their own unique pros and cons.

Oimo performs the best, but there are no event callbacks and proper documentation (just examples). Goblin Physics doesn't have callbacks either. AmmoJS is suppose to be the best, and its what PlayCanvas uses - but its documentation is horrible. Maybe you can use the PlayCanvas engine on GitHub and work with that? I really want Oimo to have more, its runs so smooth.

CannonJS is what I ended using as well. Its not the best performance, but it has something I need: documentation and event callbacks. It was a hassle setting up callbacks to get the desired results, some ugly collision mask filtering, but it does the job. Just make sure you download the files from GitHub and build locally, don't just grab the latest build files on the GitHub page - they are out of date.

There isn't much else for 3d physic engines.

Link to comment
Share on other sites

@Samuel Girardin
Hi!

Yes, I need to have a collision callback when a body collides with another body.
Cannon has this event registration like this:

 physicsBody.addEventListener("collide", function (ev) {
     var otherBody = ev.body;
     ...
 }


And i also need objects that register this collision event, but do not modify any physics parameter. (I think they call it trigger objects in other game engines)
Cannon has the .collisionResponse = 0; for this.


I said "It maybe will miss important elements" because I do not know yet, I'm looking forward and excited to see it! :)
I'm waiting to use Energy js, and if it has everything I need, and it is more performant than cannon (I'm sure it will be more faster!) I will try re-working my engine.

I searched ODE documentation for callback, but only found this:

void dBodySetMovedCallback (dBodyID, void (*callback)(dBodyID));

 

Link to comment
Share on other sites

Hey lads, thanks for the input! 

Energy.js (http://www.visualiser.fr/page.php?id=Energy.js) looked promising, but it seems the project is in limbo.. I suppose I'll have to go with Cannon or Ammo.

What bothers me in most demos I've seen so far is that it appears the engines have hard time settling objects (finding rest position), e.g. if you have a bunch of stacked boxes, they keep trembling and shaking indefinitely without coming to rest. 

I used physics engine in Softimage XSI - what a joy it was!! Ah well...

Link to comment
Share on other sites

This is how I set up Cannon (low restitution and more solver iterations lower the vibrations that you mentioned):
Theese are kind of optimal settings for Cannon.js (copied from here and there)
Maybe this helps someone.


this.world = new CANNON.World();
this.world.defaultContactMaterial.contactEquationStiffness = 1e6;
this.world.defaultContactMaterial.contactEquationRegularizationTime = 3;
this.world.solver.iterations = 20;
this.world.gravity.set(this.gravity.x, this.gravity.y, this.gravity.z);
this.world.allowSleep = true;
this.world.broadphase = new CANNON.SAPBroadphase(this.world);


On bodies, I set:
body.allowSleep = true;
body.sleepSpeedLimit = 0.01;
body.sleepTimeLimit = 1.0;

On the material:
mass: 100 (or about the mass of the object in kilograms)
friction: 0.1
restitution: 0.3 

Link to comment
Share on other sites

I'm looking forward to trying out EnergyJS as well.

For the time being, I'm using CannonJS. OimoJS certainly has better performance, but lacks in features.

I originally chose CannonJS due to the heightfields, as I wasn't quite satisfied with the way OimoJS handles that.

The collisionResponse feature is another thing I think is important in a physics engine, as it allows easy implementation of waypoints, pickups etc. Another way of doing these might be possible, but with CannonJS, you simply won't have to implement other means of doing so. Another reason is, that CannonJS runs well on NodeJS, with only minor issues having to do with heightfields.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...