Hey,
Cool demo! Just to address your points/questions:
Heightfield accuracy
A heightfield shouldn’t be any less accurate than a triangle mesh, but since it hasn’t (yet) been exposed in Babylon, it’s possible that there’s a bug in how it’s constructed inside the WASM. It might help to use the debug display of the shape to see if this is the case:
need a function to get current state ( sleeping, notSleep ) and a function to force a state
Havok has a bunch of functionality here, but the only part which is exposed is the sleep state when adding a body to a world. I’d prefer to keep the sleeping interface as simple as possible, because it’s quite easy to make mistakes which cause the physics to look bad and it’s sometimes hard to understand when a body would be woken by the simulation - personally, I much prefer when the simulation always does the right thing automatically. Will defer to the Babylon team here to see if there’s any kind of additional functionality they’d like to see here.
if( b.isKinematic ) havok.HP_Body_SetTargetQTransform( b, [ b.pos, b.quat ] )
else havok.HP_Body_SetQTransform( b, [ b.pos, b.quat ] )but that create bug with multiple substep
HP_Body_SetTargetQTransform will set the body’s velocity so that it gets to the target in the next HP_World_Step() - if you’re using multiple substeps with smaller delta times, you should be able to use HP_Body_SetTargetQTransform in between each substep, but just interpolate the target. I would definitely recommend setting the target, rather than just changing the transform, as changing the transform directly can have a negative impact on simulation accuracy (unless your’e genuinely teleporting the body).
anyway tunneling is very good in havok ( speed vs collision )
Cool! All bodies in Havok always use continuous collision detection, so fast moving bodies should be pretty robust