Make ! the root of the tree, not a tag on the bodies - #87
Merged
Conversation
`!` does not merely mark what it points at -- it makes that subtree the whole model. Everything else goes: the siblings, and every operation wrapped around it. This was implemented by stamping a role onto the marked bodies and filtering at the top level, which cannot express the second half: by the time a body carries the tag, every ancestor has already been applied to it. So `translate([50,0,0]) !cube(5);` put the cube at x=50 where the reference leaves it at the origin, and `linear_extrude(height=10) !circle(10);` gave a cylinder where the reference leaves the 2D circle -- the extrude is an ancestor like any other. The tree is now re-rooted at the first show_only node between resolve and generate, so its ancestors are never generated at all. Two further divergences fall out with it: a highlighted sibling used to survive the filter and no longer does, and more than one `!` now warns and takes the first, both matching the reference (checked against 2021.01). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Reported against
linear_extrude(height=10) !circle(10);— it should leave the 2D circle, and we produced the cylinder.!does not merely mark what it points at. It makes that subtree the whole model: the siblings go, and so does every operation wrapped around it.That was implemented by stamping
BodyRole::ShowOnlyonto the marked bodies and filtering at the top level, which cannot express the second half — by the time a body carries the tag, every ancestor has already been applied to it.Measured against the reference implementation (2021.01):
translate([50,0,0]) !cube(5);linear_extrude(height=10) !circle(10);module m(){ !cube(5); } translate([50,0,0]) m();!cube(5); #sphere(9);!The tree is now re-rooted at the first
show_onlynode between resolve and generate, so its ancestors are never generated at all. The last two rows fall out of that rather than being handled separately: a highlighted sibling is outside the new root, and the "first wins" rule needs somewhere to choose, which the body filter never had.Testing
Modifiers.TopLevelShowOnlyFiltersOutEverythingElseasserted the old behaviour — that a#sibling survives — so it is rewritten as...LeavesNothingButItsOwnSubtree, against what the reference actually renders. Three tests added: ancestors discarded, the extrude case from the report, and first-wins-with-a-warning.811 tests pass. Negative-controlled three ways: not re-rooting at all, taking the last
!instead of the first, and dropping the warning — each fails its own tests.The 2D case needed care in the test: what survives has a
sectionand nobody, and asserting onbody->BoundingBox()segfaulted before I looked at how 2D is represented.🤖 Generated with Claude Code