Performance Issues in Havok Mesh Collision Detection

Hello,
I want to check for interference between complex meshes using Havok.
However, even when setting them as triggers, the performance drops significantly when the meshes come into contact.
Is there any solution to this issue?

  • I suspect that this happens because the trigger event is being called continuously.
    Is it possible to adjust the physics update cycle or interpolation settings to resolve this?
  • I am currently using body.setTargetTransform to move the objects, but is there a more suitable method?

The reproduction code below uses simple shapes, but in the actual case, the shapes are concave, so BABYLON.PhysicsShapeType needs to be set to MESH.

Hello and welcome to the Babylon forum!

Pinging our physics guru @Cedric

Dynamic PhysicsShapeType Mesh collision detection is very costly performance wise because of it computational complexity. Use if for static geometry like a game level for example. For dynamic bodies, use other shapes like convex hull, spheres,… It’s possible to make a compound of these convexe shapes to build a concave one.

Thank you.
I understand that mesh collision is computationally expensive, but I still want to use it.
Before the triggers make contact, the performance is very light, but the moment they touch, the load increases significantly. Why does this happen?
Since they are triggers, I assume that penetration or bouncing calculations are not performed.

I suspect that the frequent invocation of events is causing this issue, and I would like to know if there is a solution.

  • Is this behavior an intended specification? Is there anything wrong with my movement code? Am I unintentionally causing excessive event triggers?
  • Can this be avoided by controlling when events occur or adjusting their frequency?
  • Are there specific mesh shapes that cause heavier performance issues? For example, does a higher vertex count contribute to the problem?

I appreciate your help.

You can try to use this : Analyze runtime performance  |  Chrome DevTools  |  Chrome for Developers
to get a better diagnosis maybe something is wrong in the engine.
Anyways, using mesh as dynamic physics shape will give performance issues at some point.
You can try to use a less dense mesh, with less vertices but it will be slower than decomposing the mesh with convex hull for example.
Physics mesh are good for a racing game terrain, or a fps level but not as a dynamic object (and many other cases. You get the idea :slight_smile: ) . You will have to decompose to simpler shapes.

1 Like