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.
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.
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
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.
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
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
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. */
/** 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
];
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: