feat: Add Z Anti-Aliasing (ZAA) contouring support (updated) (#12736)
This PR supersedes #12225, which originally proposed this feature but appears inactive. The feature originated from work I developed earlier in [BambuStudio-ZAA](https://github.com/adob/BambuStudio-ZAA), a private fork of Bambu Studio Compared to #12225, I updated the implementation for current upstream and fixed the following issues: - fixed broken tests - removed references to nonplanar directory Reviewers may want to compare against #12225 for earlier discussion/context. ## Summary Port of **Z Anti-Aliasing (ZAA)** from [BambuStudio-ZAA](https://github.com/adob/BambuStudio-ZAA) to OrcaSlicer. ZAA eliminates visible stair-stepping on curved and sloped top surfaces by raycasting each extrusion point against the original 3D mesh and micro-adjusting its Z height to follow the actual surface geometry. The result is visibly smoother domes, chamfers, and shallow slopes — without post-processing. ## How It Works 1. The slicer runs normally, then a **posContouring** step processes each layer 2. `ContourZ.cpp` raycasts every extrusion point vertically against the source mesh 3. Each point's Z is adjusted to the mesh intersection, converting flat `Polyline` paths into `Polyline3` paths with per-point Z coordinates 4. The G-code writer emits the adjusted Z values, so the printer follows the true surface ## Configuration Five new settings under **Print Settings > Quality**: | Setting | Type | Default | Description | |---------|------|---------|-------------| | `zaa_enabled` | bool | off | Master enable/disable switch | | `zaa_min_z` | float | 0.06 mm | Minimum Z layer height; controls slicing plane offset | | `zaa_minimize_perimeter_height` | float | 35° | Reduce perimeter heights on slopes below this angle (0 = disabled) | | `zaa_dont_alternate_fill_direction` | bool | off | Keep fill direction consistent instead of alternating | | `zaa_region_disable` | bool | off | Disable ZAA for a specific print region/material | ## Key Changes - **Core algorithm**: New `src/libslic3r/ContourZ.cpp` (~330 lines) — raycasting engine - **3D geometry**: `Point3`, `Line3`, `Polyline3`, `MultiPoint3` extend existing 2D types - **Arc fitting**: Templated to work with both 2D and 3D geometry - **Pipeline**: `ExtrusionPath::polyline` changed from `Polyline` to `Polyline3`; new `posContouring` step in `PrintObject.cpp` - **G-code**: `GCode.cpp` writes per-point Z when `path.z_contoured` is set - **UI**: ZAA settings exposed in Print Settings > Quality panel - **Documentation**: `docs/ZAA.md` with usage and implementation details 57 files changed, ~1800 insertions, ~200 deletions. ## Test Plan - [ ] Load a model with curved top surfaces (sphere, dome, chamfered box) - [ ] Enable **Z contouring** in Print Settings > Quality - [ ] Slice and verify G-code has varying Z values within contoured layers - [ ] Build on macOS (verified), test on Linux and Windows
This commit is contained in:
@@ -4111,6 +4111,51 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("ironing_expansion", coFloat);
|
||||
def->label = L("Ironing expansion");
|
||||
def->category = L("Quality");
|
||||
def->tooltip = L("Expand or contract the ironing area.");
|
||||
def->sidetext = L("mm");
|
||||
def->min = -100;
|
||||
def->max = 100;
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionFloat(0));
|
||||
|
||||
def = this->add("zaa_enabled", coBool);
|
||||
def->label = L("Z contouring enabled");
|
||||
def->category = L("Quality");
|
||||
def->tooltip = L("Enable Z-layer contouring (aka Z-layer anti-aliasing)");
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("zaa_minimize_perimeter_height", coFloat);
|
||||
def->label = L("Minimize wall height angle");
|
||||
def->category = L("Quality");
|
||||
def->tooltip = L("Reduce height of top surface perimeters to match height of model edge. "
|
||||
"Effects perimeters whose slope is less than this angle in degrees. Reasonable value is 35. Set 0 to disable.");
|
||||
def->sidetext = L("°");
|
||||
def->min = 0;
|
||||
def->max = 90;
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionFloat(0));
|
||||
|
||||
def = this->add("zaa_dont_alternate_fill_direction", coBool);
|
||||
def->label = L("Don't alternate fill direction");
|
||||
def->category = L("Quality");
|
||||
def->tooltip = L("Disable alternating fill direction when using Z contouring");
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("zaa_min_z", coFloat);
|
||||
def->label = L("Minimum z height");
|
||||
def->category = L("Quality");
|
||||
def->tooltip = L("Minimum z layer height. Also controls slicing plane");
|
||||
def->sidetext = L("mm");
|
||||
def->min = 0;
|
||||
def->max = 100;
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionFloat(0.05));
|
||||
|
||||
def = this->add("layer_change_gcode", coString);
|
||||
def->label = L("Layer change G-code");
|
||||
def->tooltip = L("This G-code is inserted at every layer change after the Z lift.");
|
||||
|
||||
Reference in New Issue
Block a user