Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hole Detection #10

Open
wtaisto opened this issue Dec 12, 2021 · 1 comment
Open

Hole Detection #10

wtaisto opened this issue Dec 12, 2021 · 1 comment

Comments

@wtaisto
Copy link

wtaisto commented Dec 12, 2021

I'm looking at using your lib to modify 2d texture maps on 3d meshes based on where the meshes are pressed against each other (anti-coplanar faces.) After performing an operation which returns a polygon with multiple Regions, is there a way to know if the Regions refer to holes vs freestanding polygons? In the example below, when subtracting blue from red, both scenarios return 3 Regions. From my experimenting, it appears that the first Region returned tends to be "the biggest outermost Region", but the remainder being holes or not is unclear. I tried testing to see if the vertex winding order is opposite for outlines / holes, but it did not seem to be. I've read through tutorials on this algorithm, and have a vague sense that the notion of "a RegionIS a hole or not" might itself be loosely defined.

image

Ultimately, I really just need to be able to take the regions that pop out of an intersection operation, and apply an earcut / tessellating algorithm to them to get a triangularized mesh. The only earcut implementations I've found specifically ask for information on where the holes are; do you know of any implementations which would work using the output of your lib?

@wtaisto
Copy link
Author

wtaisto commented Dec 12, 2021

Since the result of a boolean operation would never return regions with overlapping edges, the regions should be parseable as a "contains" tree. So a region being a hole is the same as it's node depth being even. Tessellating gets easier then; traverse the tree from the root non-hole, and if it has a hole, just combine the edges with the edges of the hole, cutting an O into a C, then tessellate that normally. Keep doing that recursively down the containment tree, voila. Maybe i'll get enthusiastic and suggest a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants