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

added global coplanarity check #408

Merged
merged 4 commits into from
Apr 12, 2023
Merged

added global coplanarity check #408

merged 4 commits into from
Apr 12, 2023

Conversation

elalish
Copy link
Owner

@elalish elalish commented Apr 12, 2023

Fixes #388

Planar faces are determined by testing neighboring triangles for coplanarity and then doing connected components on the result. The problem is little changes can add up: a finely tessellated sphere can potentially have every edge be coplanar within tolerance, resulting in a single huge planar face, which is obviously incorrect. This affects output faceID, but also the internal edge collapsing and can result in wildly incorrect imports.

The fix is to do a second pass, since we already identify the largest triangle as the reference for a plane, we can simply check if any verts in the plane are out of that triangle's plane. If so, we simply discard the entire plane and all contained triangles are assumed to be not coplanar with each other. There are a few edge cases where this will miss actual planar faces, but I think they'll be rare, and it's much less of a problem geometrically to be conservative in this direction.

@elalish elalish self-assigned this Apr 12, 2023
@elalish
Copy link
Owner Author

elalish commented Apr 12, 2023

I also added a test that catches this problem, and in the process noticed that I wasn't passing precision in and out of the library properly yet, so that's fixed here. I also noticed that my cute idea of clamping our surface area calculation was resulting in quite a bit of error, so that's simplified and fixed too.

@elalish elalish requested a review from pca006132 April 12, 2023 05:27
@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.06 🎉

Comparison is base (a9bf836) 86.02% compared to head (371878c) 86.08%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #408      +/-   ##
==========================================
+ Coverage   86.02%   86.08%   +0.06%     
==========================================
  Files          38       38              
  Lines        4580     4601      +21     
==========================================
+ Hits         3940     3961      +21     
  Misses        640      640              
Impacted Files Coverage Δ
src/utilities/include/public.h 55.88% <ø> (+0.43%) ⬆️
src/manifold/src/impl.cpp 95.71% <100.00%> (+0.22%) ⬆️
src/manifold/src/manifold.cpp 92.24% <100.00%> (+0.06%) ⬆️
src/manifold/src/properties.cpp 85.91% <100.00%> (-0.30%) ⬇️
src/manifold/src/sort.cpp 90.33% <100.00%> (+0.03%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@elalish elalish merged commit 9731788 into master Apr 12, 2023
22 checks passed
@elalish elalish deleted the coplanarity branch April 12, 2023 15:03
@elalish elalish mentioned this pull request Nov 3, 2023
cartesian-theatrics pushed a commit to SovereignShop/manifold that referenced this pull request Mar 11, 2024
* added global coplanarity check

* fix early-out

* added test, fixed precision

* one more precision
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.

Corrupted union of seemingly simple large models
2 participants