Havok `GetCollisionEvents()` fails if there are no collisions

I use HP_World_GetCollisionEvents() to query the world for collisions after a step in Havok. If there are collisions, Result.RESULT_OK === 0 as expected. However, if there are no collisions, Result.RESULT_FAIL === -2147467259.

I believe RESULT_FAIL is quite brutal. When querying the world for collisions, (1.) collisions present or (2.) no collisions present both seem like valid outcomes. For other Havok functions, RESULT_FAIL seems reserved for when invalid values are passed to the function, which is great.

Could we consider returning RESULT_OK for HP_World_GetCollisionEvents() if the world happens to have no collisions at a point in time? Thank you for your help!

Attached is a video showing this behavior:

On second thought, using RESULT_FAIL (as currently done) for no collisions could be better. If RESULT_OK is used for no collisions, then the returned number memory address would have to be set to an invalid value:

HP_World_GetCollisionEvents(world: HP_WorldId): [Result, number]

This would be a breaking change with a big B and a big C :see_no_evil:

3 Likes