Skip to content

Feature windows choose Join, New Body or Cut from what the material touches (#6901) - #6903

Merged
bherbruck merged 9 commits into
tangency-labs:mainfrom
froglemonade2:auto-join-new-cut-6901
Oct 28, 2026
Merged

bherbruck merged 9 commits into
tangency-labs:mainfrom
froglemonade2:auto-join-new-cut-6901

Conversation

@froglemonade2

@froglemonade2 froglemonade2 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6901.

Feature windows that add material choose Join, New Body or Cut from what the material actually does, until you pick one yourself. Hidden bodies take no part.

Tool Automatic choice
Extrude (and Press Pull on a profile) New Body if it touches no shown body, Join if it does, Cut when it goes into a body (Extrude's existing rule)
Revolve New Body, Join, or Cut when the revolved volume lies inside a body
Box, Cylinder, Sphere, Torus New Body in empty space, Join on a body, Cut when it lies inside one
Sweep, Loft, Coil New Body or Join
Pipe, Thicken, Boundary Fill, Combine, fixed-operation tools, Mirror, Pattern unchanged

How it decides

The window asks the engine what its material does when joined (solidcraft_engine::Ahead::addition, off the window thread):

  1. No contact with any body the Join could take part in → New Body, from the material alone and the existing contact test (Body::meets); no boolean.
  2. Otherwise it runs the Join on a copy and counts pieces with Join: say so when the joined piece doesn't touch the body #4434's own rule (join_pieces_added, factored out of note_join_apart): a separate piece → New Body, one body (or fewer pieces, a bridge) → Join. So the choice is exactly what OK makes, and the Join: say so when the joined piece doesn't touch the body #4434 warning never fires on an automatic choice. The contact test alone isn't enough: it counts a 0.001 mm gap or a pin with 0.01 mm clearance as touching, while the Join leaves two pieces.
  3. Revolve and the primitives: material that adds (next to) no volume (display-mesh volumes) → Cut.
  4. When it joins, the evaluated Join is kept and OK takes it (Session::prime, as OK-off-thread already does), so the boolean is not computed twice.

Timing and races (crates/ui-egui/src/op_auto.rs)

  • The operation changes only when a finished check says so: no guesses, no flicker while dragging. One check runs at a time, for the latest inputs; undo, parameter changes and hiding/showing bodies invalidate it.
  • A pick in the Operation row wins at once and for good, the option already shown included (new ui_kit::dropdown_picked): a check running at the time, or finishing later, can't change it. In Extrude the pick stops its own automatic choice in the same frame (it used to be overwritten before the next update saw it).
  • OK runs what the window shows; while the window still chooses, OK waits for the running check.
  • A feature being edited keeps its operation.
  • The scenario harness's settle waits for a running check.

Hidden bodies

With some bodies of the scope hidden, a new feature's Join/Cut/Intersect names the shown ones as its targets (solidcraft_engine::shown_scope), so a hidden body is never joined or cut and showing it later changes nothing. With none shown: New Body, and a hand-picked Join/Cut says "No shown body to change: show one, or choose New Body". This is the implicit "visible = in scope" behaviour; it doesn't add a targets picker (#2465 does that for Extrude).

Before / after

A 30 × 30 × 10 block, a separate sketch with a rectangle standing apart from it, Extrude opened on it.

main (ece2a86) this PR
before: Join after: New Body
OK: 1 body, Base in 2 pieces, warning in History before OK OK: 2 bodies after OK

A block against the block's side wall still opens on Join:

touching: Join

Cost of the check

Measured in the ci profile (opt-level 1) on this 8-core desktop; release is faster:

Case Check
Material apart, any part contact test only: 0–60 ms, 230 ms on a 200 × 200 plate with 400 holes
Joins: blocks, ring round a hole, pin in a bore 10–170 ms
Joins: loft, sphere r100, filleted box 0.14–1.8 s
Joins: plate with 100 / 400 holes 0.9–1.3 s / 3.1–4.5 s, almost all of it the Join boolean that OK then takes instead of computing

Preference

Preferences › Design › Choose the operation automatically (auto_operation, on by default). Off: no window chooses; each keeps the operation it opens with (Extrude its own Join or Cut), no check runs and OK doesn't wait for one, as before this change. ui.prefs {"auto_operation": false} sets it over the control channel. Test: op_auto_tests::with_the_preference_off_the_window_keeps_its_operation (and saved settings without the key load with it on).

Preferences › Design with "Choose the operation automatically"

Validation

  • crates/engine/src/cmd/join_pieces_tests.rs: the verdict equals what a real Join makes (ring round a hole, pin filling a bore, flush and half-flush walls, a block past an edge, a bridge between pieces, 0.001 / 0.01 mm gaps, a pin clear in its bore, far blocks), Inside for a box/ring within a body, hidden bodies out of scope, no verdict for Cut, Combine, fillets or an empty design.
  • crates/ui-egui/src/op_auto_tests.rs: Extrude apart → New Body (2 bodies after OK), touching → Join with OK taking the evaluated Join; ring round a hole; sphere apart / on / inside → New Body / Join / Cut; a hand pick made while the check runs stays (Extrude and a primitive, the shown option included); OK pressed at once waits for the check; hidden bodies; an edited feature keeps its operation.
  • apply_off_thread_tests switch the window's own check off (they test OK computing).

Rebased onto main 2026-10-28 (head 3f600ff on 48ba6ff). After #6683 made list parameters strict, the operation check reads the Join's targets/participants with string_list_or_default (a preview: a wrong type only widens the contact pre-test, and the Join itself then refuses it, so the check gives no verdict). #3135 now computes OK's whole transaction off the window thread, so "OK takes the evaluated Join" primes that computation's scratch session (DialogComputation::new), compute_commands_inner unprimes the session it hands back so nothing primed reaches the adopted design, and OK on the window thread (web, previews off) primes around run_dialog (run_primed). #6766's exact_regions and this PR's shown-body targets are both applied in apply_commands.

Overlap with #5148 and #6894, which landed meanwhile: both keep hidden bodies out in the engine, per command (#5148 an Extrude Cut/Intersect, #6894 a Loft Join), where this PR does it once in the feature window for every Join/Cut/Intersect it makes. They agree: the window stores the shown bodies as explicit targets, so those engine paths don't run for a window-made feature, and both refuse when every body is hidden. #5148's private shown_scope and this PR's public one are now one function (Option: None when all are shown); #5148's call keeps its behaviour with unwrap_or_default().

Closing a window stops its check: the check runs under a Progress and a window that closes (or no longer chooses) abandons it, so its evaluation stops at the next feature and nothing waits for it (op_auto_tests::closing_the_window_stops_its_check). Before this, the test harness waited for a closed window's check after every step, which made icon_audit take ~30 min instead of ~1; it now runs with auto_operation off (it only looks at icons) and takes 75 s. #6248's Box placement test makes a box that overlaps its base, which the window would now join or cut, so it also turns the choice off.

Local validation:

Changes a default: yes — Extrude, Loft and Sweep choose New Body for material apart, and Revolve, the primitives and Coil choose Join or Cut where the material meets a body (hidden bodies are left out of a new feature's Join or Cut either way, as #5148 and #6894 now do in the engine), old behaviour kept behind preference auto_operation

🤖 Generated with Claude Code

@froglemonade2
froglemonade2 marked this pull request as ready for review October 26, 2026 06:35
@froglemonade2
froglemonade2 force-pushed the auto-join-new-cut-6901 branch 7 times, most recently from afdb8b1 to 9727239 Compare October 27, 2026 22:39
@froglemonade2
froglemonade2 force-pushed the auto-join-new-cut-6901 branch from 9727239 to 8f9b746 Compare October 28, 2026 13:13
@bherbruck bherbruck added ready to merge reviewed, every ask addressed; merge once CI is green owner-approved Owner reviewed a sensitive-path change (kernel, CI, build scripts, deps); only the owner adds this approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) and removed approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) labels Oct 28, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 28, 2026
@froglemonade2
froglemonade2 force-pushed the auto-join-new-cut-6901 branch from 8f9b746 to dac0c3c Compare October 28, 2026 18:56
froglemonade2 and others added 9 commits October 28, 2026 15:06
…ouches (tangency-labs#6901)

Extrude, Revolve, Loft, Sweep, Coil and the Box, Cylinder, Sphere and Torus choose
their operation by running the Join on a copy of the design off the window thread
and counting the pieces: Join when the material makes one body with what it
touches, New Body when it would be a separate piece, Cut when it lies inside a
body (Revolve and the four primitives; Extrude keeps its own Cut). The choice
changes only when a check is in, a pick in the Operation row (the shown option
included) stops it for good, and OK waits for a running check. Hidden bodies take
no part: with some hidden, the shown ones become the feature's targets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…strings, gallery entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he evaluated Join

Material touching no body is a New Body without running the Join (the contact
test costs 0-240 ms where the Join costs seconds on a large body). Inside is told
from display-mesh volumes instead of exact ones (8 s on a 400-hole plate). The
check evaluates the Join through Session::ahead, and OK of the same commands
takes it (Session::prime) rather than computing it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preferences > Design gets "Choose the operation automatically" (auto_operation,
on by default). Off, feature windows don't choose Join, New Body or Cut from
what their material touches: each keeps the operation it opens with (Extrude
its own Join or Cut), no check runs and OK doesn't wait for one, as before

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce and its preference

Arabic, Hebrew and Vietnamese are complete catalogs now, and Turkish has a full
catalog, so this change's three strings get them too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t choose

A window's operation check kept running after the window closed, a Join on
the design for nothing, and the test harness waited for it after every step:
the icon audit, which opens every window, took ~30 min instead of ~1. The
check now runs under a Progress, and closing the window (or one that doesn't
choose) abandons it: its evaluation stops at the next feature and nothing
waits for it. The icon audit turns auto_operation off, as it only looks at
icons (75 s again).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test tangency-labs#6248 added places a box that overlaps Base and expects a second body;
with tangency-labs#6901 the window would join or cut it. The test is about where the box
goes, so it turns auto_operation off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bherbruck
bherbruck force-pushed the auto-join-new-cut-6901 branch from dac0c3c to 3f600ff Compare October 28, 2026 19:19
@bherbruck
bherbruck added this pull request to the merge queue Oct 28, 2026
Merged via the queue into tangency-labs:main with commit 02ac56d Oct 28, 2026
24 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) owner-approved Owner reviewed a sensitive-path change (kernel, CI, build scripts, deps); only the owner adds this ready to merge reviewed, every ask addressed; merge once CI is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature windows choose Join, New Body or Cut from what the material touches, leaving hidden bodies out

2 participants