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

Better faces #1040

Merged
merged 10 commits into from
Feb 13, 2025
Merged

Better faces #1040

merged 10 commits into from
Feb 13, 2025

Conversation

elalish
Copy link
Owner

@elalish elalish commented Nov 14, 2024

I'm replacing our CreateFaces algorithm. Our previous was based on connected components, but in the case of e.g. a high-res sphere, it would connect everything into one big face. So then we added an algorithm to check global tolerance of each face after the fact, and if that failed, it would just throw out all the faces and say each triangle was individual.

This new algorithm skips all that and instead finds faces by starting with the largest triangle and searching its neighbors until none are within tolerance. Then it gets the next largest unprocessed triangle and does it again, serially, until all triangles have been assigned to faces. It's a bit arbitrary, but works decently.

Ideally we can eventually follow this on with some improved edge collapsing code.

@elalish elalish self-assigned this Nov 14, 2024
@elalish elalish requested a review from pca006132 November 14, 2024 06:07
@fire
Copy link
Contributor

fire commented Nov 14, 2024

This could be a way to attach an edge-length refiner with collapse or subdivide done per polygon.

Vec<TriPriority> triPriority(numTri);
for_each_n(autoPolicy(numTri), countAt(0), numTri,
[&triPriority, this](int tri) {
meshRelation_.triRef[tri].faceID = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this causing the check in line 238 and 249 to always be false?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because they get reassigned on lines 240 and 253.

@fire
Copy link
Contributor

fire commented Dec 1, 2024

can the random selection be more deterministic for like ai.. and import recreation / reproducibility

@elalish
Copy link
Owner Author

elalish commented Dec 2, 2024

can the random selection be more deterministic for like ai.. and import recreation / reproducibility

Since this is based on sorting, it should be as deterministic as we can hope for.

@fire
Copy link
Contributor

fire commented Dec 2, 2024

Can you see what happens when you try to merge https://github.com/user-attachments/files/17969298/node_3d.zip ?

@elalish
Copy link
Owner Author

elalish commented Feb 12, 2025

Okay, I got bogged down on this one because I tried to solve too many things at once. The actual point of this PR, which is to create faces better and faster is working just fine. Then I tried to make it into a general purpose decimator, but got stuck on some Boolean regressions. Now I've undone that to get back to basics here. I'll do further work on the decimator in separate PRs.

@elalish
Copy link
Owner Author

elalish commented Feb 12, 2025

@pca006132 This is odd - the CI is passing almost everywhere, but on three jobs it's failing, and not just a few tests, but a ton of them and even seg-faulting. On my mac everything is fine - even the address sanitizer isn't finding any undefined behavior. Do you have any idea what I did wrong?

@pca006132
Copy link
Collaborator

It seems that I can reproduce them locally with parallelization disabled. Will check.

@pca006132
Copy link
Collaborator

OK, for some reason Linux stdlib.h defines an int abs(int);, changing to std::abs fixes the issue.

@pca006132 pca006132 mentioned this pull request Feb 12, 2025
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 98.27586% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.65%. Comparing base (447921c) to head (34062e6).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/impl.cpp 98.24% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1040      +/-   ##
==========================================
- Coverage   91.71%   91.65%   -0.06%     
==========================================
  Files          30       30              
  Lines        5951     5922      -29     
==========================================
- Hits         5458     5428      -30     
- Misses        493      494       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@elalish
Copy link
Owner Author

elalish commented Feb 13, 2025

Wow, thanks for the fix! I wonder what their abs was doing... One of these days I'll remember to always put std:: in front of everything.

@elalish elalish merged commit f2da5ea into master Feb 13, 2025
27 checks passed
@elalish elalish deleted the betterFaces branch February 13, 2025 08:51
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

Successfully merging this pull request may close these issues.

3 participants