Is there any libraries for realtime concave shapes collision detection?

Hello, I need maximum precision for concave object collision (or is it correct to call this “mesh collision”?) detection and would like to know if there is any way to detect concave (or mesh?) intersections fast enough (if it is even possible for realtime detection)? It is assumed that there will not be many objects and they don’t have many polygons, what can you advice for me? Thanks)

In this example, I use cannon.
RNG - Three.js Tutorials (sbcode.net)
The larger sphere is a container of smaller spheres.

It is a cannon trimesh with its faces facing inwards.

But I think it would be easier to just write a distance function if your concave is perfectly spherical.

4 Likes

If you’re just looking for whether two geometries intersect the three-mesh-bvh library I maintain supports this using the intersectsGeometry function. In the shape intersection demo you can select the option to see two torus knot geometry intersection detected.

If you’re looking for collisions for physics there are a number of physics library options listed on the plugins and libraries docs page.

2 Likes

I don’t need physics, just collision detection and there will be no spheres in my scene, there are will be “panels” (as pictured: Screenshot-2 — ImgBB) with curve shape and kinks, but thanks for your reply)

Thanks, your lib looks like what I need (I don’t need physics, just collisions), I’ll try it, appreciate you

1 Like

Um, what’s a BVH? I went to your repo, expected a reference/link, but none found.

@jgg BVH stands for Bounding Volume Hierarchy, a kind of tree structure (or spatial partitioning/indexing system broadly thinking) that aims for eficiently store the relation between leafs based on proxy representations of minimal -bounding- volume that wraps them.

Cheers to @gkjohnson for writing -and sharing!- his project, implementing SAH is veery valuable on it own, congrats!

Thanks!

@jgg
As @Antonio said BVH stands for “Bounding Volume Hierarchy”.

Cheers to @gkjohnson for writing -and sharing!- his project, implementing SAH is veery valuable on it own, congrats!

Thank you! FWIW the SAH setting is in a sorry state at the moment in part because of how long it takes to generate so it doesn’t get much use. Now that you can generate the BVH in a WebWorker there may be more value in it though. It’s on the list to improve but both CENTER and AVERAGE generation techniques are more than good enough in most cases.