About Havok feature

Hello i’m a physics user
i know many engine oimo, ammo , physx

I currently test havok and i need some option
I want help to improve havok and have more info about havok
tell me if is possible or not

for Rigidbody

need a function to get current state ( sleeping, notSleep )
and a function to force a state

a option to make ghost ( trigger ) body
no collision with other body, only collision callback

a function to lock linear and angular axis (usefull for character simulation)

1 Like

welcome to the Babylon community!

It’s only possible to suggest a body to start asleep or not, but after startup it’s not possible to change its state, it’s all in the simulation hands and it will wake up or put asleep bodies as it’s more suited. About the trigger body, the closest thing we’d have would be a body with an animated motion type. From the docs:

The final motion type is animated - bodies with this motion type are similar to dynamic bodies; you can change their velocities and the physics engine will update the body positions. However, the difference is that bodies with an animated motion type won’t be affected by any other bodies. Animated bodies will still push dynamic bodies out of the way and pull on constraints but the animated body won’t be affected by those collisions. This is useful for important objects where you need them to reach a particular goal - e.g. an elevator which should always reach the correct floor, no matter how many other bodies are inside the elevator.

You have the option to set limits on the linear/angular axis of the 6DOF constraint: Constraints | Babylon.js Documentation (babylonjs.com)

ok thanks carolhmj

i have to test collision callback so i will see

other thing about terrain ( currentlly not include in plugins )
i test by
scale is vector3 and divid is number of square x , z
havok.HP_Shape_CreateHeightField( divid[0], divid[1], scale, heightData.byteOffset )[1]

that work but is not verry accurate ( less than use direct tri mesh )
do you have info on that is maybe a optimization ?

What do you mean exactly by “less accurate”? Do you mean the collision response? I haven’t used the Heightfield yet, but I imagine it will depend on the subdivision level.

here object collision is not exact
I paid attention to my values but there is always the gap,
it can be a bad heightdata format i use Float32Array

1 Like

cc @Cedric and @Evgeni_Popov . I believe 3th is the author of oimo and phy . so nice to see you here :partying_face:

1 Like

it’s exact Jeremy :smiley:, thank’s

Whoa, sorry for the off-topic, though this is an amazing demo @3th :open_mouth:

1 Like

terrain demo

yes Float32Array is the only one work mm

raycast, collision callback, compound work great

for character is just lock inertia to [0,0,0]

i have question about substep
in physics engine to improve stability i use substep
that make multiple pass instead of one

let n = substep;
while( n-- ) root.world.step( timestep / substep );

but in havok this seem not change simulation like expected ?
to have good stacking i have to use 40 substep instead of 4
someone have info to do substep in havok to improve stability of stacking

Hi @3th :slightly_smiling_face: , have you seen that in the api :


Maybe you can do something with that ?

1 Like

Amazing Demo! :raised_hands::raised_hands::raised_hands:

1 Like

for the moment i disable substep because to update kinematic object we have to use

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

anyway tunneling is very good in havok ( speed vs collision )
so is more to find a way to improve stacking of objects


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 :slight_smile:


for terrain i think is not the good array and should be change in wasm
on physx and ammo height value should be Uint32Array.

yes changing direct position give bad result even on the kinematic
thanks for info about HP_Body_SetTargetQTransform that make sense.

force sleep can help a lot to optimise stacking with many objects
here i use velocity length to see if sleep or not (gray is sleep)
but is not accurate
i think is important to get access to sleep interface ( maybe as option )
sometime is also useful to disable sleep on some object

someone know full list of collision event

havok.EventType.COLLISION_STARTED // 1
havok.EventType.COLLISION_CONTINUED // 2

havok.EventType.COLLISION_FINISHED // 4

maybe something here for trigger

1 Like

from the API, it looks like setting a filter could be a solution, but maybe that would ignore the collision all together? my hunch is that a trigger IS a collision as havok is concerned, but just a collision with no reaction.

/** Sets the collision info for the shape to the information in filterInfo. This can prevent collisions between shapes and queries, depending on how you have configured the filter. */

HP_Shape_SetFilterInfo(shapeId : HP_ShapeId, filterInfo: FilterInfo): Result;

Or, maybe this is how its done?

/** Convert a collision event ID to a concrete type */
HP_Event_AsCollision(eventId : number): [Result, CollisionEvent];

where the collision event is of this shape:

export type CollisionEvent = [
/* Type / EventType,
Contact on body A / ContactPoint,
Contact on body B / ContactPoint,
Impulse applied */ number

possibly 0 out the impulse applied ?

I watched this video Leveraging DOTS-powered physics - Unity at GDC 2019 - YouTube and maybe another possibility is to clone the physics world? intuitively that seems wasteful, but that is the strategy they used for the demo around 19 mins

1 Like

I tried using collision filters a few days ago. They ignore collision checks entirely between shapes, so not suited for triggers


We haven’t exposed any of the trigger functionality via the WASM because Babylon has additional trigger functionality, which works with all kinds of objects, not just physics bodies: