Skip to content

fix: Prevent multi-color 3MF color loss via per-layer XY area cross-region carving#519

Open
zackaree-shen wants to merge 3 commits into
bugfix_feedbacks_v234from
bugfix/multi-color-3mf-extruder-loss
Open

fix: Prevent multi-color 3MF color loss via per-layer XY area cross-region carving#519
zackaree-shen wants to merge 3 commits into
bugfix_feedbacks_v234from
bugfix/multi-color-3mf-extruder-loss

Conversation

@zackaree-shen

@zackaree-shen zackaree-shen commented Jun 18, 2026

Copy link
Copy Markdown

fix: Prevent multi-color 3MF color loss via per-layer XY area cross-region carving

Problem

Multi-color 3MF files suffered color loss during slicing. The root cause was that cross-region carving used a global bounding box instead of per-layer XY extrusion area, causing incorrect carving decisions on layers where the extrusion region differed from the global bounds.

Solution

Add per-layer XY area comparison for cross-region carving, but only when volumes belong to different print regions (different \print_object_region_id). This narrow scope:

  • Fixes the multi-color color loss bug
  • Preserves Bambu's original #if 1\ \diff_ex\ default for same-region overlaps
  • Avoids re-introducing the \ rim_overlap\ performance regression on same-region paths

Decision tree (per overlapping volume pair):

Condition Behavior Performance
Negative volume \diff_ex\ ✅ Fast
Cross-region (different \print_object_region_id) Per-layer XY area carving ✅ Fast (\diff_ex)
Same region / no region ptrs \diff_ex\ (Bambu default) ✅ Fast

Changes

File Lines
\src/libslic3r/PrintObjectSlice.cpp\ +39 / -16 (3 commits)
  • Compute per-layer XY area per \print_object_region_id\ before region clipping loop
  • Cross-region carving uses smaller per-layer area to determine carving direction
  • Hysteresis guard (ratio < 1.5x) uses \print_region_id\ as tiebreaker
  • Default path falls back to simple \diff_ex\ (Bambu's #if 1\ performance-safe behavior)
  • Explicit type declarations replace \�uto\ (code style compliance)

PR Size: Small (1 file, ~55 lines net)

Testing

  • Verified color preservation in multi-color 3MF slicing output
  • No regression in single-color slicing (same \diff_ex\ path as before)

…egion carving

Replace the arbitrary print_region_id-based and per-volume bbox_volume-based
cross-region overlap carving with a per-layer XY area comparison:

- Accumulate ExPolygon area per print_object_region_id at each Z layer
- Smaller area region (detail) carves larger area region (base)
- Hysteresis guard: use print_region_id tiebreaker when area ratio < 1.5x
- Preserve negative_volume and same-region trim_overlap behavior unchanged
… only

- Narrow the per-layer XY area carving to cross-region (different print_object_region_id) paths
- Default path falls back to simple diff_ex, preserving Bambu's #if 1 performance-safe behavior
- Avoids re-introducing trim_overlap performance regression on same-region overlaps
@zackaree-shen zackaree-shen force-pushed the bugfix/multi-color-3mf-extruder-loss branch from 72a0def to f24e1e8 Compare June 18, 2026 06:23
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