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

Mesh Simplification is incomplete after one pass #675

Open
zalo opened this issue Dec 27, 2023 · 7 comments
Open

Mesh Simplification is incomplete after one pass #675

zalo opened this issue Dec 27, 2023 · 7 comments

Comments

@zalo
Copy link
Contributor

zalo commented Dec 27, 2023

@elalish It seems like there's room for additional simplification after one pass; perhaps topology should be simplified until no changes are made?

    general_offset = nonConvex.minkowski_sum(nonConvex.scale([0.5, 0.5, 0.5]))
    for i in range(5):
        save_mesh(general_offset, "general_offset_"+str(i), "stl")
        general_offset = general_offset.as_original()

Pass 0:
image

Pass 1:
image

Pass 2:
image

@elalish
Copy link
Owner

elalish commented Dec 27, 2023

Yeah, that's probably a good idea for a stand-alone Simplify method - the internal one is aimed more at being fast dealing with what a single Boolean op creates.

@pca006132
Copy link
Collaborator

This is due to the order in which we perform edge collapses. We currently only do one pass over the list of halfedges in the order in the vector, but collapsing a halfedge with index i can cause halfedge j < i to be eligible for further simplification. Ideally we should have some kind of a worklist/set, when an edge is collapsed we check its neighbors to discover edges that can be further simplified. A worklist will be more efficient when the number of edges require collapsing is low (comparing with the total number of edges). I think this can combine with the optimization we mention in #679, i.e. only look for edge collapses among the newly-created verts in a Boolean, and will probably be faster than the current one we have.

@elalish
Copy link
Owner

elalish commented Jan 3, 2024

Yeah, agreed. Currently EdgeCollapse is recursively checking neighboring edges for potential collapse, but I may be missing some cases.

@zalo
Copy link
Contributor Author

zalo commented Jan 4, 2024

Another interesting wrinkle... the slivers left over from some of the Minkowski operations appear to be cleaned up by the simplifications in asOriginal(), which also changes the Genus:

Before (Genus 4):
image

After calling as_original() 10 times (settled on Genus 5 after the first call):
image

Also worth noting the nearby triangle that is not getting simplified...

@pca006132
Copy link
Collaborator

Wonder what the black thing in your first photo is. Is this a bug in our boolean impl? And yeah, the lump of triangles not being simplified at the end is also interesting.

@elalish
Copy link
Owner

elalish commented Jan 6, 2024

I would guess the black thing is a thin, disconnected mesh that's likely responsible for the genus being 1 low (an extra separate mesh will do that). On a second pass, I'm guessing it got simplified down to nothing.

@zalo
Copy link
Contributor Author

zalo commented Jan 6, 2024

Yep; that’s right! This is the same bug that was seen with Offset with the sliver meshes.

Simplify can often eliminate them (but not always).

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

No branches or pull requests

3 participants