Floating origin with Havok

Hey everyone, I’m trying to get Havok to work when I keep the camera at the origin of the scene like here: Playground (use WASD or ZQSD to move around)

I think the disablePreStep thingy is making the sphere miss a few physics update when I move the scene around. The sphere seems to jitter a bit and sometimes goes through the ground. Is there another way to move everything at once that would be havok friendly?

Havok does continuous collision detection , the unity docs have a good write up on the concept. Unity - Manual: Continuous collision detection (CCD) . I suggest also looking at the typescript definitions of the havok wasm module inside node_modules (it actually has no dependency on or reference to anything babylon related). It’ll quickly help translate some abstract concepts, such as a joint just being a constraint variant.


It is really impressive that Havok can manage CCD while being so fast. I looked in the ts definitions of the wasm module, I will try HP_Body_SetQTransform and report if I am successful or not!

Alright I modified the playground quite a bit and reused some findings from "moveWithCollisions" with havoc? - #13 by Raggar

It works a lot better but there is still a small issue: Playground
I’m adding gravity in the linear velocity of the box and it makes it jitter for some reason.

For comparison when using Havok gravity: Playground the box behaves as expected.

Is there something about the way havok computes its own gravity, I guessed it would just be added to the linear velocity but it seems to be different :thinking:

Gravity is an acceleration so it has to be multiplied by time no? @Cedric

That would make sense indeed.
I tried it but the results are a bit underwhelming: Playground. And dividing the deltaTime by 1000 causes the box to not fall at all…

I think one possible issue is that setting the linear velocity might override other forces havok adds to the body. But it does not explain why it works here: Playground

Yes, so acceleration * deltaTime give the velocity.

1 Like