Skip to content

fix(boolean): exact results for touching solids instead of nudged retries - #200

Open
cykaan wants to merge 1 commit into
wrong-nebula:mainfrom
cykaan:fix/190-touching-solids
Open

cykaan wants to merge 1 commit into
wrong-nebula:mainfrom
cykaan:fix/190-touching-solids

Conversation

@cykaan

@cykaan cykaan commented Dec 5, 2026 •

Copy link
Copy Markdown

Fixes #190.

Cause. When operands touch only along an edge, the exact CSG result has an edge with four faces, so it counts as bad edges. boolean_op then nudges the tool and returns the nudged geometry. That output is watertight, but its corners move by about 1e-5 and volumes are off by about 2e-5. This matches the hypothesis in the issue. When operands share only a corner, the result passes the boolean but fails strict mode with a non-manifold vertex (the "WT=false, NM=0, B=0" case).

Fix. split_touching_solids() separates such contacts topologically, the way manifold libraries represent them:

  1. Faces around a multi-face edge are sorted by angle and paired across each solid wedge.
  2. Every vertex is split per fan of faces joined through (paired) edges.

Coordinates stay exact, and touching solids become separate shells. An edge whose faces cannot be paired consistently is left alone, and the existing path runs. The multi-shell overlap check now treats contact where neither triangle crosses the other's plane as touching, not overlapping.

Measured on 800 grid-aligned cases built like the issue's: 2–6 boxes, add/cut/intersect, 0.5 and 0.37 grids, with an exact cell-decomposition volume.

main This PR
Exact to 1e-9 762 800
Rejected 8 0
Volume drift 30 0

Tests. issue_regressions.rs:

  • Edge-touching union: two shells, volume exactly 2, corners exactly at 1.5, not overlapping.
  • The issue's corner-touching three-box union.
  • A seeded 200-case grid CSG sweep against exact volumes.

All three fail on main.

Re-checked on current main (d9d9c22, 2026-12-06): merges cleanly, the full workspace test suite passes with this PR applied (280 tests, 0 failures), and cargo clippy --workspace --all-targets reports no warnings.

This PR is one of 11 independent fixes from the fork cykaan/forma-tr, each based on main (5cecae8) and carrying only its own fix and test. The fork's Turkish glyphs for text3d, its size-first release profile and its new language features (list iteration, conditionals, seeded rand, indexing, textures, lights/cameras) are deliberately not included in any of these PRs; they can be proposed separately as issues.

🤖 Generated with Claude Code

https://claude.ai/code/session_018inpPNqrJ4RQcb5toxiqEE

…ries (wrong-nebula#190)

Operands that touch only along an edge or at a corner give an exact
CSG result whose solids share that edge or vertex. The edge then had
four faces (rejected as bad), so boolean_op nudged the tool and
returned the nudged geometry: watertight, but with corners moved by
~1e-5 and volumes off by ~2e-5 relative. A shared corner alone passed
the boolean but failed strict mode as a non-manifold vertex.

split_touching_solids() now separates such contacts topologically,
like manifold libraries do: faces around a multi-face edge are sorted
by angle and paired across each solid wedge, then every vertex is
split per fan of faces joined through (paired) edges. Coordinates stay
exact; touching solids become separate shells. The multi-shell overlap
check now treats contact where neither triangle crosses the other's
plane as touching, not overlapping.

Grid-aligned box CSG (2-6 boxes, add/cut/intersect, exact cell-volume
reference): 762/800 -> 800/800 exact to 1e-9, with no rejections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018inpPNqrJ4RQcb5toxiqEE
@cykaan
cykaan requested a review from wrong-nebula as a code owner December 5, 2026 13:02
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.

Boolean fuzz: 64 of 800 axis-aligned box cases fail (21 rejected as non-manifold, 42 with volume drift)

1 participant