Optimizing physics

Hmm. Here’s a recreation of my simple box example, using native AmmoJS calls:

The box goes to sleep after the (I believe) default 3 second sleep timer

1 Like

I found a pg prepared that shows the problem, i think.

(settings related to this comment)
scene.getPhysicsEngine().setSubTimeStep(5);
scene.getPhysicsEngine().setGravity(new Babylon.Vector(0,-1,0);

For this first example, it seems like it could be considered a bug in babylon, it’s just a bad default value though. It could be that setting the default value to 1 would cause buggy behavior elsewhere. In the second example with the cylinder on the ground.

see line 15:

scene.getPhysicsEngine().setSubTimeStep(8);

Now, try commenting it out out and change the values around.
(note) commenting it out is the default babylon behavior (perhaps should be changed).

try each of these and replay:

//scene.getPhysicsEngine().setSubTimeStep(8);
scene.getPhysicsEngine().setSubTimeStep(1);
scene.getPhysicsEngine().setSubTimeStep(0.1);

The behavior when you comment out line 15 is buggy and inconsistent. It seems setting this value to some value but greater than 0 by default could fix some issues for falling objects. It doesn’t help for rolling objects though (see ex below)

@Panuchka

I made the same changes to your pg, using 5 as a default value seems pretty good. But, thats mainly because it doesn’t fall over.

i added a timeout to modify setting the settings after 5 seconds to show the difference here. It still doesnt settle though. It starts to behave nicely, but then it’s like there is some constant acceleration and vibration that leads to catastrophic resonance. is there some dampening setting? maybe that could stop it going apeshit after like 30 seconds.

setting the timestamp to 1 in the settimeout callback in this example caused a halo-like super jump. I googled about that, and it said its caused by the player (cylinder here) falling through the level and the engine applying a a very strong impulse to counter-act it. maybe something similar is happening?

related:

1 Like

Things are looking a bit grim it seems… No good to have an engine with some bugs that can’t be fixed :frowning: Also it seems that Ammo.js has been a bit abandoned so… Time to invest creating that RapierPlugin for Babylon? :smiley:

2 Likes

As far as I’ve seen Rapier could be the best alternative.

2 Likes

@Cedric and @RaananW, I guess we should dig into this ? this is so sad Physix engines gets abandoned like this :frowning:

cc @Deltakosh

3 Likes

A Rapier plugin could be a very nice addition, I agree

2 Likes