Ammo / Bullet never rests

This is a bit of a physics question, but I have cylinders laying on a box and they always seem to jiggle permanently, never coming to rest. Has anyone else using bullet / ammo ever encountered this? Also they seem to penetrate each other pretty hideously when they collide.

It’s a very very very very simple reproduction.

I also found a mild unrelated bug in the ammo plugin where objects with 0 mass aren’t properly specified as static, the internal collision flag is ALSO still marked as ‘kinetic’ as well as static. I’ve had to manually remove the kinetic flag in my project for static impostors.

Seems to be related to the CylinderImpostor? When changing to the box imp[ostor it works as expected. Maybe @Cedric has a a better answer?

I always have the sames answer for this type of issue: need more precision! :slight_smile:
The physics engine tries to compensate the inter penetration because the delta time is to big for the scene to be stable. Add Substeps and it solves it. See line 15
Concerning your second issue, do you have a PG to repro that? I’d be curious to take a look


Here’s the repro for the second issue.

The collision flags are ‘3’ and here is that enum from bullet


A static object should be simply static and not kinematic right? I guess it depends on your interpretation of the documents. I do get an issue where my ground ‘sinks’ by 0.01 y every 1 hour and I think this may be related.

Thanks for the help! I have some work to do before I can increase the substep because I manually implemented collisonStart and collisionEnd which would break if I increase the substep. I check to see which objects are colliding / no longer colliding every frame but plan to replace that with bullet’s manifold event API.

Apparently, this is done on purpose : Babylon.js/ammoJSPlugin.ts at 5dffdfe98795ff9de6e4a8c55cce13fdbbe59be5 · BabylonJS/Babylon.js · GitHub

I forget, how but you can force them into a rest state and also set sleep thresholds if you look at the bullet/ammo github stuff you should be able to hunt that down.

You are close with the flags you are doing, but you are missing one that handles how the entity rest or if it is able to (if im not mistaken).

I know to stay away from the kinematic stuff though for sure as some of that is essentially broken (at least with the kinematic character controller for sure)

If you are not able to figure it out ping me I worked this out before just cant off the top of my head remember the answer right this second.

I just want to say thank you, it took me awhile to implement my own physics manager to handle bullet manifold events. I ran into a lot of problems and I think the community would benefit with a tutorial on how to get past these problems. I’d love to write one soon.

I wanted to post my PhysicsManager implementation for anyone else coming through here, which is still WIP but in production physicsManager.ts · GitHub

Issues I ran into:

  • Cylinder manifolds appear to “come to rest” but have their manifolds created / destroyed infinitely in Bullet. This does not occur with box rigid bodies.
  • Babylon does not preserve btRigidBody.userIndex when destroying and re-creating rigid bodies
  • runRenderLoop in node causes physics to be slow in node (because it defaults to setTimeout(16) to queue new frames but using setInterval(…, 0) causes the physics to simulate at the proper speed.

I would make a playground of the cylinder manifolds but the ammo that’s in the sandbox isn’t the latest built version I think with Ammo.addFunction and the manifold event callbacks. I had to build it myself locally because their repo’s builds are out-dated.

1 Like