Improve mesh intersect detection

By default, my mesh bounds looks something like this:

I tried to use CSG to split the mesh into smaller sections, and use those meshes to detect collisions

PG: Babylon.js Playground

It works very well for some meshes but very badly for others. And it seems like a pretty inefficient way of doing it, but I can’t think of another way

Ok:

Not good:


I think this is because the front and back of the mesh is split into separate elements to have different materials.

Is there a better method to get more accurate mesh intersection detection?

This one seems ok to me?

Maybe I did not understand, but you should create small meshes that correspond to the boxes in your picture and make the glasses not collisionable, only the boxes.

Those small boxes are created by creating large boxes and then using CSG to intersect with the original mesh (like the PG I posted).

This works very well on some meshes (like the one you mentioned) but very poorly on other meshes, so I’m trying to find another more reliable method of creating the small boxes

Maybe this blog post can help:

1 Like

Thanks. I was just about to post my own solution, using getFacetLocalPositions and manually calculating the bounds

3 Likes