Contact point in Impostor.applyForce() is handled differently with ammo and cannon plugin

Documentation says (at least for impulses, but I expect it to be the same for forces):

Applying an impulse requires a vector giving the magnitude and direction of the impulse and the position vector of the contact point of the impulse. The contact point of the impulse is given in world coordinates.

This seems to be true for CannonJSPlugin, whereas AmmoJSPlugin wants it in body coordinates.

Playground: https://playground.babylonjs.com/#FD65RR#28

Pinging @Cedric

Hi @Joerg_Plewe

The conversion is present in the code :

And I changed your PG to try it:
https://playground.babylonjs.com/#FD65RR#29

In my case, I apply a force at the box position. With cannon or ammojs, they both go upward. If the force position was only local with ammojs, the cube would spin.

Thx for the quick answer. In your PG of course nothing rotates for the force directly hits CG.

But when you push boxCollider a small step aside (x = 2) the contact point. so that torque is actually created, cannon and ammo behave very differently. Ammo results in an ondulating, swinging turn because the contact point wanders from side to side due to rotation, whereas cannon creates the (expected and correct?) constant increase in angular velocity.

https://playground.babylonjs.com/#FD65RR#30

In any case, only one behaviour should be the correct one and the other is a bug?

I’ll change it to using applyImpuls() and see what Oimo delivers.

1 Like

Did it. Omio behaves as Cannon.

https://playground.babylonjs.com/#FD65RR#31

Somehow … does Omio handle the inertia tensor differently (spins much faster) … is this worth another bug?

ok, I see it now. oimo/cannon behave correctly. There is an issue with ammo. I debugging now to see why it’s wrong.

1 Like

PR is live

3 Likes