Resolve #86: non-planar polyhedron() mismatch was already fixed, add regression test - #99
Merged
Merged
Conversation
…regression test Bisected polyhedron-nonplanar-tests.scad's reported "2.94 vs 1.29" volume mismatch against a live OpenSCAD 2021.01 + Manifold v3.5.2 oracle, isolating each of its three polyhedron() calls individually. The fan-triangulation CsgEvaluator::evalPolyhedron uses was never actually wrong here (two of the three cases already matched to floating-point noise). The real culprit was the third case's scale(0.02) — a bare scalar, which pre-v3.10 only scaled the Z axis, distorting that polyhedron into a self-intersecting mesh whose volume collapsed to ~0. That scale(<scalar>) bug was already fixed in 18f7a54 (filed under issue #90), as an incidental side effect of unrelated parser work, so this file already matches the oracle at floating-point-noise level with no CsgEvaluator/PrimitiveGen change needed. Adds the exact reproducing case as a fixture plus a chiselcad_tests regression pinning its volume to the oracle's measured value, so this doesn't silently regress independently of the existing scale(scalar) unit test that covers the actual root cause. Verified against the full 625-case suite (real CMake + Manifold v3.5.2 build, not the language-only ad hoc build prior sessions were limited to). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EpFgmMhwNWZHubDQG2doqQ
particlesector
commented
Jul 30, 2026
particlesector
left a comment
Owner
Author
There was a problem hiding this comment.
Reviewed. The root-cause finding checks out: CsgEvaluator's bare-scalar scale(n) broadcast (line ~547 in src/csg/CsgEvaluator.cpp, on main) does correctly expand to {n,n,n}, confirming the pre-v3.10 Z-only-scale bug is what actually caused issue #86's mismatch, not fan-triangulation. Roadmap edit is accurate and well-placed (new ## v3.11 section slots cleanly between v3.10 and v4), and the new regression test locks in the right invariant. One minor nit left inline on the test margin.
Generated by Claude Code
Generated by Claude Code
Measured rel_error for this case was ~1.4e-6; the margin(1e-3) left in place was ~1000x looser than that and could have missed a real regression. Tightened to margin(1e-5), ~7x above the measured noise. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EpFgmMhwNWZHubDQG2doqQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #86
Summary
polyhedron-nonplanar-tests.scadreportedly producing volume1.29vs. real OpenSCAD's2.94) using a live oracle:apt-installed OpenSCAD 2021.01 + a from-source Manifold v3.5.2 build (pertests/tools/README.md).polyhedron()calls individually showedCsgEvaluator::evalPolyhedron's fan-triangulation was never actually wrong — two of the three already matched the oracle to floating-point noise.scale(0.02) polyhedron(...).scale(0.02)is a bare scalar, and at the commit the issue was filed against,CsgEvaluator::makeMatrixstill had the pre-v3.10scale(<scalar>)bug that scaled only the Z axis, distorting the mesh into a self-intersecting shape whose volume collapsed to ~0. That bug was already fixed in18f7a54under unrelated issue [Medium] Parser fails on several 3D/features corpus files (for-loop / transform-argument grammar edge cases) #90 — nobody re-ran the volumetric corpus check afterward to notice it also closed [Medium] Non-planar polyhedron() faces triangulate differently than OpenSCAD, wrong volume #86.CsgEvaluator::evalPolyhedron/PrimitiveGen; this file now matches the oracle at floating-point-noise level (rel_error~1e-6) onmain.scale(scalar)unit test that covers the actual root cause.docs/roadmap.md(v3.11).Test plan
tests/fixtures/headless/polyhedron_nonplanar_scale.scad(the exact reproducing case from OpenSCAD's own test corpus)chiselcad_testscase intests/test_headless_build.cpppinning its volume to the oracle's measured1.6544281372scad_to_stl/stl_diffagainst a live OpenSCAD 2021.01 oracle: full filerel_error=3.5e-6, isolatedscale(0.02)caserel_error=1.4e-6🤖 Generated with Claude Code
Generated by Claude Code