I programmed Mesh Boolean operations, which are very similar to CSG operations (like Union, Intersect, and Difference) but can work on any type of mesh input. For example this is the intersection (union and difference do both work as well, but for examples sake) between a torus and a box:
For reference, this is how they are intersecting at the start
Here is the cube being manually moved with real time updates:
Here is the cube automatically rotating with real time updates:
There are two main issues for now, how to get rid of the artifacts and how to make the performance faster. I haven’t really optimized it at all, so I think there is a lot of room for improvement on that regard (spatial datastructures, mesh-connectivity caching, general caching stuff more, cleaning up code). The artifacts only happen here and there, so I’ve been having a hard time debugging it. But I’ll update when I do either of the two above ^^^
Sorry for the visual clutter in the background, I was working on a few different projects at once
Lmk if anyone has a suggestion for a project to use this on, I was thinking of something to do with maybe blacksmithing or procedurally fracturing an object along a pattern
I based the mesh boolean algorithm off of a simplified model of this paper: Interactive and Robust Mesh Booleanshttps://arxiv.org/pdf/2205.14151 (simplified in that it doesnt use intermediate representations of intersections)
In brief
The algorithm finds the intersections of every triangle pair within the two input meshes (Detect intersections step)
From those intersection points, I insert them into a mesh connectivity structure that has references between elements (like triangles, vertices, edges). (Insert point step)
I then constrain the edges from those intersection points, updating the mesh as I go. (insert segments)
When both shapes do not intersect at any point, then I fire a ray upwards from every single new triangle to see whether it should be kept or destroyed (Jordan Curve theorem)
Sorry that it is a bad explanation that doesn’t get into the technical side, but once I clear up the code and fix some of the edge cases I’d be happy to go FOSS or explain in more detail
Thanks for the interest! I was planning on releasing it, but around a month after I posted Roblox uploaded their Creator Roadmap: 2025 End of Year Recap that included
that should release early 2026. So its probably best just to wait for that to upload, rather than taking my design for it.
If you want to start this project back up, id be happy to help you. But I’m not going to share the code since there are some architectural liberties I took that I should not have taken (my method is an approximation since it uses floating point numbers, so not robust. If I were to redo it, I’d use exact predicates & floating point filters)