Skip to content

Cut faces: the cut green for uncoloured tools, and keepMinuendColor - #173

Merged
revarbat merged 1 commit into
mainfrom
feat/cut-face-colors
Sep 11, 2026
Merged

revarbat merged 1 commit into
mainfrom
feat/cut-face-colors

Conversation

@revarbat

Copy link
Copy Markdown
Member

Two halves of BelfrySCAD/BelfrySCAD#412's follow-up, both verified against OpenSCAD 2026.02.01.

Parity: uncoloured tools paint the cut green. The reference paints faces exposed by an uncoloured subtrahend its CGAL back-face green (#9DCB51) — in preview, and kept by its colour-preserving render (measured in a 3MF export). We painted them the default geometry yellow, so a cut through an uncoloured part could not be seen as a cut. The green is now recorded against the tool's runs before the merge, and the merge looks even when every operand's own colour agrees. A coloured tool still paints its cut with its own colour.

Evaluator::keepMinuendColor (Evaluator(keep_minuend_color=True) in the bindings): difference() paints its cut faces with the minuend's colour instead. Upstream closed the request (openscad/openscad#4798) because OpenCSG preview is pixels in a frame buffer; we do real CSG and know every triangle's provenance. Since (A ∪ B) − S = (A − S) ∪ (B − S), each minuend part is differenced on its own, its cut-face runs re-minted under fresh IDs carrying that part's colour, then the parts are unioned. A union() built in this mode remembers what it merged (ColoredBody::mergedFrom, carried through transforms, color() and the cache restamp), so difference() { union() { red; blue; } tool } cuts red on the red side and blue on the blue side. Cache keys are prefixed per mode so the two never serve each other's bodies. Off by default: a viewer option, not a language feature.

Tests: cut green (three cases), keep mode (single colour, per-part exact colours checked by triangle position, transform/colour carried over the union, cached union restamped with its parts, cache keyed apart), plus a bindings test. Full suite 1257/1257, bindings 42/42. CLAUDE.md updated. 1.19.3 → 1.20.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y9HJERiDZrsAb5tgmwdqU6

- An uncoloured subtrahend now paints the faces it exposes the reference's
  cut green (#9DCB51, what its preview shows and its colour-preserving
  render keeps) instead of the default geometry colour, so a cut through
  an uncoloured part reads as a cut. Recorded against the tool's runs
  before the merge; the merge looks even when every operand's colour
  agrees.
- Evaluator::keepMinuendColor (bindings: keep_minuend_color=True) makes
  difference() paint cut faces with the minuend's colour instead -- the
  option OpenCSG cannot offer (openscad/openscad#4798). Each minuend part
  is differenced on its own, its cut-face runs re-minted under fresh IDs
  carrying that part's colour, then the parts are unioned. A union()
  built in this mode remembers what it merged (ColoredBody::mergedFrom,
  carried through transforms, color() and the cache restamp), so a
  union of coloured parts cuts each in its own colour. Cache keys are
  prefixed per mode. Off by default.

BelfrySCAD #412.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y9HJERiDZrsAb5tgmwdqU6
@revarbat
revarbat merged commit 8c382fd into main Sep 11, 2026
3 checks passed
@revarbat
revarbat deleted the feat/cut-face-colors branch September 11, 2026 04:30
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.

1 participant