Fix union()/difference()/intersection() dropping all geometry when one operand is invalid - #71
Merged
Merged
Conversation
…e operand is invalid generateCsg's boolean merge fed every foreground body straight into Manifold's +/-/^ operators. Manifold propagates a non-NoError Status() (e.g. NonFiniteVertex, typically from a degenerate accumulated transform somewhere upstream) onto the WHOLE combined result instead of treating that one operand as an empty no-op contributor -- so a single already-invalid part silently zeroed out every valid sibling in the same union(). Found via a real user project (snappy-reprap): an entire ~65-part extruder assembly, positioned deep inside several generations of indexed children()-forwarding (the z_tower_assembly chain), vanished from the render with no warning at all, while the exact same assembly rendered fine called directly/shallowly. Real OpenSCAD's CGAL backend doesn't hit this on the same input. Fix: filter out any operand whose own Status() isn't NoError before handing the group to Manifold's boolean ops, matching this evaluator's existing "invalid/empty operand doesn't poison the whole op" precedent for genuinely-empty statements. Bump to 0.13.10.
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.
Summary
generateCsgfed every foreground body directly into Manifold's+/-/^boolean operators. Manifold propagates a non-NoErrorStatus()(e.g.NonFiniteVertex, typically from a degenerate accumulated transform somewhere upstream) onto the whole combined result instead of treating that one operand as an empty no-op contributor — so a single already-invalid part silently zeroed out every valid sibling in the sameunion().children()-forwarding, vanished from the render with no warning at all — while the exact same assembly rendered fine called directly/shallowly. Real OpenSCAD's CGAL backend doesn't hit this on the same input.Status()isn'tNoErrorbefore handing the group to Manifold's boolean ops, matching this evaluator's existing "invalid/empty operand doesn't poison the whole op" precedent for genuinely-empty statements.Test plan
Union.OneInvalidOperandDoesNotDiscardValidSiblings) reproduces the exact mechanism with a deliberately NaN-vertexpolyhedron()unioned alongside a validcube()— confirmed it fails on the pre-fix code (volume 0 instead of 8) and passes after the fixOSCAD_BYTECODE_VM=0and=1snappy-reprap/full_assembly.scad: the extruder assembly (a real, non-degenerate 22,895-vertex merged body) now appears; body count 507→508, warnings unchanged at 2 (pre-existing/unrelated)🤖 Generated with Claude Code