I continue my merry way in Havok and its motorized constraints. I just noticed that an unused motor whose bodies are not moving enters into sleep mode quickly (about 250ms).
I made a small example that shows this. Depending on when the timer is triggered, the motor is running or not. Change the timer to 2000 at line 80 to reproduce the issue.
I couldn’t find an API function to explicitly wake the bodies attached to the constraint. The only reference to sleep mode appears in the constructor of PhysicsBody, at the time of its initialization, but this is not sufficient in my case.
Moreover, in the V1 physics engine, there was the PhysicsPlugin.wakeUpBody() function to do this.
We can’t manually wake up a body as that’s supposed to be controlled by the physics engine only, but it’s weird the motor is not moving @eoin do you have an idea of what’s going on?
Oh sorry! I totally missed this last week; was pulled into some projects which took a bunch of my time. The upcoming version of the WASM will have additional functions for sleep control, but looks like you’ve found a bug; changing some of the constraint params don’t send an activation request to the attached bodies. I’ll be sure to get this fixed up too, but Raggar’s workaround should hold you over 'til then. Thanks Raggar!
Hi @eoin ! I was wondering if you were still planning on adding these additional sleep control functions to the WASM? That would be awesome, and thank you
That’s right; we have exposed a bunch of functions in the WASM for sleep control (we call it activation/deactivation, rather than sleeping):
/** Try to set the activation state of a body. */
HP_Body_SetActivationState(bodyId: HP_BodyId, activationState: ActivationState): Result;
/** Get the current activation state of a body. */
HP_Body_GetActivationState(bodyId: HP_BodyId): [Result, ActivationState];
/** Set the activation behavior of a body. See `ActivationControl` for more details. */
HP_Body_SetActivationControl(bodyId: HP_BodyId, activationControl: ActivationControl): Result;
/** Set the activation priority of a body. `priority` should be in the range [-127, 127]. Defaults to 0.
* A body with simulation controlled activation will only be activated by interactions from other bodies
* whose priority is >= `priority` */
HP_Body_SetActivationPriority(bodyId: HP_BodyId, priority: number): Result;
These just need to be exposed in the HavokPlugin. The last two methods do offer more control than other physics engines do, though, so need to be careful we’re not adding an interface which doesn’t make sense for those potential other engines.
(Also, the havok package v1.3.0 fixed the reporter’s bug where changing the constraint parameters didn’t activate attached bodies)
Thank you so much for your help, @HiGreg and @eoin
I was also wondering if Havok has a function to set the sleep kinetic energy threshold of bodies? (Similar to PhysX’s setSleepThreshold() and Bullet’s setSleepingThresholds())