Meshes falling (irregularly) through ground created from height map

Hey there.
Any idea why some meshes would fall through the ground created by heightmap… but only if they’re moved quickly? And moreover, how to prevent that case?

Two screenshots here where you can see the behavior.

All good here.

Oops! Where are you going pink brick??? Right to the bottom of the sea, it seems.

And video here: Dropbox - fallingthrough.mov - Simplify your life

Key bit of the code is is:

  g.ground1 = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "/assets/textures/water.jpg", 200, 200, 10, 0, 10, g.scene, false, function() {
    g.ground1.physicsImpostor = new BABYLON.PhysicsImpostor(g.ground1, BABYLON.PhysicsImpostor.MeshImpostor, { mass:0, restitution: 0.1, friction: 0.5 }, g.scene);
  });
      g.bricks.forEach(brick => {
        brick.physicsImpostor = new BABYLON.PhysicsImpostor(brick, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 13, restitution: 0.2, friction: 12 });
      });
1 Like

Yes, it happens when objects move too fast: a box in on one side of the terrain and the frame after, the box is way under the terrain so no contact point can be computed.
To fix that, increase the steps for physic engine ticks.
Are you using AmmoJS?

Yes, using Ammo.
Ground doesn’t seem to work at all in Cannon (meshes fall through)
And in Oimo, the ground seems to float incorrectly.
So it’s only Ammo that seems to do the trick.

What does “increase the steps for physic engine ticks.” mean?

I’m found this PG that uses Cannon : https://www.babylonjs-playground.com/#1RKZXB#98

yes, increase the step count : AmmoJSPlugin - Babylon.js Documentation

Great example! Thx so much.