It looks like your approach is similiar to mine. I separate faces and edges, then find the intersections, whereas you use the faces to find intersections with other face’s edges. That’s more work for your intersection detection loop as it will find stuff twice, but on the other hand I think it makes it more easy to build the new edges. (avoiding a case I have of four nested loops that I am trying to reduce somehow) The math used is a little different… your intersection detection I think may be a little more efficient since you detect if it is inside the mesh rect/triangle early on by handling things one axis at a time. (though to me to, just on intuition, it seems that shouldn’t work…maybe I’ll have to think about it more) Otherwise the only significant difference I guess is that I keep track of what is inside and outside to do the actual boolean part.
Interesting…filling was not a priority for me. Like you mentioned, it gets complicated when you introduce shapes with holes in them and such. Though your filling is better it seems than mine. I’ll have to look into what you are doing, as maybe I can work with it. Unfortunately your function names aren’t all that descriptive to me, and I can’t read the comments. Could you maybe elaborate on it?
Basically my filling is:
If there are holes, pass it on to blender’s intenal fill function.
If not, use mine.
Find which verticies are part of the inside or outside (in all cases, these would be the cut up edges of the original face), and make another set of verticies on edges shared by inside and outside parts. (new edges cut into the face from the intersecting object)
These separate lists are no encourage it to make it so that when all the intersection points are select, no actual faces should be selected. The goal is to make the mesh more manageable for modelling afterwards using extrusions and such. This way either the outside or inside parts of the new mesh can be cleanly selected.
The face is subdivided by connecting one vertex from one set to a vertex of the other set, making sure that the subdivision is valid (doesn’t go outside the new face). It tries to make the subdivision where two verticies are closest together. This is in an attempt to produce cleaner meshes by avoiding creating an edge for two verticies that are far appart and then needing to have a bunch of little edges cramed into a small space because they can’t cross the big edge added earlier. (If there is anything wrong with that logic, let me know)
Then the function calls itself recusively on the two subdivided parts. If it can create two sets of edges that are inside/outside and both, it just uses all edges. If it hits a list of 3 verticies or 4 convex verticies, it stops and makes a face.