# Description
Texture displacement read the layer stack and the bake target from an
object's first model part, so a multibody object was displaced only
there while the paint on its other parts was kept and ignored. The bake,
prepare and preview jobs now each carry a vector of parts and run them
in one job, under one progress bar and one undo step; remesh and
subdivide cover every part too
# Screenshots/Recordings/Graphs
<img width="3515" height="1838" alt="image"
src="https://github.com/user-attachments/assets/227cd067-4b04-476a-982e-b52c4fdcca23"
/>
# Other
Fixes#16559
[How to Download Pull Requests Artifacts for
Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
Removing a layer clears its paint on every part, tiled and view-projected
textures run on across parts, the projection tools paint every visible part,
relief under a raised part reaches down to where the object rests, and closing
the tool no longer crashes the app.
Selecting the web Device tab, or changing the printer preset, called
load_url with the same URL. That navigated the webview again and reloaded
the printer UI, dropping its in-page state such as zoom.
PrinterWebView now remembers the URL, API key and host type of its last
finished load and skips navigation when all three match. A host type change
still reloads, since it selects the page handler. A failed load is not
remembered, so the next selection retries.
Fixes#16752
# Description
Three fixes that all come from the same root cause: code that assumes
the bed is the one at the plate origin.
**Arrange**
- An item whose outline fits the printable area could never be placed.
The arrange bed is inset by `bed_shrink` (1 mm per side) and the item is
inflated by its brim width, and `update_selected_items_inflation()` only
relaxed that inflation when there were more than 5 mm to spare. An item
scaled to fit the print volume was rejected every time, and arrange
looked like it did nothing. The bed margin is now given back where the
largest selected item needs it (never below the skirt distance) and the
inflation is capped at the printable area.
- When an item came back `UNARRANGED`,
`PartPlateList::postprocess_arrange_polygon()` parked it on a virtual
bed that was never created, moving it a whole plate stride off the
plate. The instance is left where the user had it instead.
- When nothing could be placed at all, `ArrangeJob::finalize()` still
cleared plate membership and rebuilt the plates, which re-homed a too
large item to whichever plate it happened to reach over. It now returns
before touching anything.
- Arrange no longer recycles plates. It must not delete a plate the user
created, even when the arrange leaves it empty.
**Scale to Fit Print Volume**
`Selection::scale_to_fit_print_volume()` centred the selection on
`bed.build_volume()`, the bed at the origin. Scaling a model that sat on
plate 2 moved it back to plate 1. The centre of the active plate is
passed in instead (and the print circle is shifted by it for circular
beds). Every plate shares the bed size, so only the centre differs.
It also fitted the whole bed, which on a multi-nozzle printer is larger
than any nozzle can reach. On the H2D the left nozzle covers X 0-325 and
the right X 25-350, so a model that filled the 350 mm bed in X sat
outside both, and the plater warned "The position or size of the model
exceeds the right nozzle's printable range" immediately after the user
asked it to fit. It now fits `PartPlate::get_build_volume(true)`, the
volume every nozzle shares and the same region Arrange already places
items in.
It now also keeps clear of rectangular exclusion zones
(`bed_exclude_area`). The fit volume is the shared bed minus each
exclusion: every rectangle spanned by bed and exclusion edges that
overlaps no exclusion. Candidates no wider than the bed padding are
dropped, otherwise a sliver at the bed edge wins and the model is scaled
to nothing. The candidate allowing the largest scale is used and the
selection is centred on it. Before this, a model could be fitted onto
the Qidi Q2's front-left notch. Circular beds are unchanged.
**Lay on Face**
Laying a face that already points straight up down needs a half turn,
and every horizontal axis does the job. `setFromTwoVectors()` resolved
that through an SVD whose null space is the whole XY plane, so the axis
followed rounding noise: the object landed at an arbitrary angle in the
plate plane, often large enough that a part which fitted the plate no
longer did ("Following objects are laid over the boundary of plate...").
Such a face is now turned over about X, which keeps the footprint, and
the rotation is shared between the gizmo and the `--ground-*` options
instead of duplicated in `Selection::flattening_rotate()` and
`lay_on_face()`.
# Screenshots/Recordings/Graphs
Fit to print volume now excludes exclusion areas and ensure it fits
within shared nozzle areas
<img width="1674" height="1408" alt="image"
src="https://github.com/user-attachments/assets/30bebe17-ee2c-454a-b361-cdb504ad4043"
/>
Lay On Face for faces that are pointing straight up does not cause weird
rotation anymore
https://github.com/user-attachments/assets/adfc0cb4-56e0-4768-873d-ef6c0fb940d9
Auto Arrange now does not remove empty plates anymore
https://github.com/user-attachments/assets/188cada1-304f-4505-a1df-4339f9dad2df
## Tests
New unit tests in `tests/libslic3r`:
- `test_arrange.cpp`: an item filling the printable area is now arranged
(it fails without the margin clamp), an item larger than the printable
area is still refused, and an item that cannot be placed keeps the
position it came in with.
- `test_lay_on_face.cpp`: a box laid on its top face ends up as `diag(1,
-1, -1)` with its 40 x 20 footprint and on the bed, instead of whichever
axis the noise picked.
The GUI side (arrange job, plate rebuild, scale to fit, gizmo) has no
test suite and was verified by reproducing each report and re-running
it. I have not built this branch locally.
Manual checks used while developing:
1. Scale a Benchy to fit the print volume, move it on Y, Arrange: it
centres and stays on the plate.
2. Add a plate, move a too large object onto it, Arrange: nothing moves,
no plate is removed.
3. Scale to fit on plate 2: the model stays on plate 2.
4. Lay on Face on the top face of a flat part: it flips over X and stays
inside the plate footprint.
5. Scale to fit a model that fills the bed in X on a dual-nozzle H2D
(bed 350x320, nozzles 0-325 and 25-350): it now fits the shared 300 mm
area, and the left/right nozzle printable range warnings stay closed.
Before the change the fit produced a 350 mm wide model that was outside
both nozzle areas.
6. Scale to fit on a Qidi Q2 (front-left exclusion 0-11 x 0-16 mm): the
model stays clear of the notch and is fitted to the largest free area.
7. Scale to fit a cube on a Qidi X-Max 4 (four corner exclusions): it
lands in the free central area at a sensible scale instead of going to
0%.
* Show Track-Switch AMS Units Under Both Nozzles in the Calibration Wizard
With a Filament Track Switch installed the device layer pins every AMS to
the main extruder and records the real binding in GetBindedExtruderSet(),
but the calibration preset page still split the AMS units by
GetExtruderId(). Every AMS landed under the right nozzle and the left
nozzle only offered its external spool.
Split the panels by the bound extruder set, blank the external spools when
the switch is installed, and take a selected filament's extruder from the
panel it was picked in rather than from its AMS.
* Run the Flow Rate Fine Pass on the Extruder the Coarse Pass Used
When the fine pass starts from the coarse page the filament comes from
the cached preset, but the extruder was resolved from whatever the
preset page currently has selected. After a restart or reconnect, or if
the selection was changed, that no longer matches and the lookup falls
back to the per-AMS map, which with a Filament Track Switch pins every
AMS to the main extruder. Take the extruder from the cache in that path;
it already records the one the coarse pass was sent with.
# Description
<!--
> Please provide a summary of the changes made in this PR. Include
details such as:
> * What issue does this PR address or fix?
> * What new features or enhancements does this PR introduce?
> * Are there any breaking changes or dependencies that need to be
considered?
-->
Fixes#16693. After slicing, the Preview listed layer pauses one or more
layers too high, and with two adjacent pauses one of them showed as
layer 0. The G-code was always right: every pause is written at the
correct height, before the correct layer. Only the Preview's layer
numbering was wrong.
## Cause
When the G-code processor reads a pause, color change or custom G-code
tag, `OptionsZCorrector::set()` stores the index of that vertex in the
move list. At the first extrusion after it, `update()` moves the vertex
to that point so it renders at the new layer's height.
A pause (and a color change) first flushes the time planner. The flush
inserts actual speed moves ahead of the flushed blocks' moves, which all
come before the vertex, so the stored index goes stale and points at an
earlier move: the previous layer's last extrusion. `update()` then moves
that extrusion past the travel to the next layer, with its old layer id,
and erases a real move. The erase also shifts every later move down one,
so the time blocks still queued for the travel and unretract after the
pause point one move off; a Debug build trips
`assert(curr_move.actual_feedrate == 0.0f)` in
`TimeMachine::calculate_time` on a Marlin profile.
This has been possible since actual speed moves were added. It became
visible with the belt printer change that renumbers the Preview's layers
on every change of a move's layer id (`f64b49ab52`): the out-of-order
move now turns into two extra layers, the layer heights stop being
sorted, and the legend's lookup misses. 2.4.2 is not affected.
## Changes
- `OptionsZCorrector::on_moves_inserted()`, called at the end of
`GCodeProcessor::calculate_time`, shifts the stored index by the moves
the flush inserted before it, read from the block id map the same
function already builds for the queued blocks.
- `OptionsZCorrector::update()` returns the index it erased, and
`process_G1` moves the queued blocks after it down by one.
No change to the G-code, the time estimates of prints without pauses, or
project files.
# Screenshots/Recordings/Graphs
<!--
> Please attach relevant screenshots to showcase the UI changes.
> Please attach images that can help explain the changes.
-->
The reporter's cube with pauses at layers 55 and 56 (Z 11 and 11.2):
main lists them at layers 56 and 60 and shows 132 layers for a 128-layer
print; with this change they are at 55 and 56, and the slider shows 128
layers.
Before:
<img width="480" height="560" alt="legend-before-main"
src="https://github.com/user-attachments/assets/d9604038-91c0-4574-8496-a7d9f49268cf"
/>
After:
<img width="480" height="560" alt="legend-after-fix"
src="https://github.com/user-attachments/assets/0ad4be7e-a258-4eaa-ae94-8eb66ef01fae"
/>
## Tests
<!--
> Please describe the tests that you have conducted to verify the
changes made in this PR.
-->
- New test in `tests/fff_print/test_gcodeprocessor.cpp`, "A pause keeps
the moves around it in order and on their own layers": three layers with
a pause before the second; checks the pause's height and that layer ids
and G-code lines never go backwards. It fails on main (the pause stays
at Z 0.2 and a layer-0 extrusion lands after layer-1 moves) and passes
with the change.
- `fff_print` suite passes (484 tests, Release, Linux), including the
`[GCodeTiming]` cases.
- On Linux, sliced the issue's project with one and two pauses on the
Anycubic Kobra 3 (Klipper) profile and checked the Preview legend and
layer slider. Marlin is covered by the new test, which runs the
processor with Marlin.
- clang-tidy check passes.
<!--
> A guide for users on how to download the artifacts from this PR.
-->
[How to Download Pull Requests Artifacts for
Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
# Description
Slicing finely detailed models such as HueForge reliefs is up to twice
as fast. Two steps that ran on a single core
dominated these slices. G-code export spent most of its time working out
which object each extrusion belongs to, and
internal bridge detection stalled for tens of seconds on layers printed
over fully dense infill. On the relief
"Mensch oder Gott 2", the slice goes from 108 s to 54 s on an M5 Max and
from 116 s to 65 s on Windows.
Over a lower layer printed at full density, bridge detection now settles
most layers with a cheaper check before it
falls back to the full computation. That check can disagree with the
full computation in one case, which is accepted:
a solid sliver thinner than about 16 µm that Clipper's own offset
simplification folds. There, internal bridges can
come out differently from main.
No change to slicing output on any project tested. G-code and object
masses are identical to main.
# Screenshots/Recordings/Graphs
<!--
> Please attach relevant screenshots to showcase the UI changes.
> Please attach images that can help explain the changes.
-->
## Tests
New unit tests compare the bridge-detection helper with the full
computation, and cover the box-only island lookup.
Main and this branch were compared on the projects below. They were also
compared on OrcaCube variants that set each
density option below 100%, plus a spiral vase, a crowded plate and a
two-part assembly. Every case slices to
byte-identical G-code, ignoring the timestamp line, and to identical
object and body masses. Slice times are for the
CLI, two runs each, on an M5 Max:
| Project | main | this PR |
|---|---:|---:|
| Mensch oder Gott 2 | 107.7 s, 108.8 s | 54.3 s, 54.4 s |
| Stranger Things 169×250 | 100.6 s, 100.6 s | 65.2 s, 66.0 s |
| RDR Front 229×256 | 12.6 s, 12.6 s | 8.6 s, 8.6 s |
| Lupo+AMS | 13.0 s, 13.1 s | 10.0 s, 10.0 s |
| Eagle 200×200 | 34.6 s, 34.0 s | 33.7 s, 34.0 s |
and on Windows with an Intel Core Ultra 7 270K Plus (Release build,
clang-cl), where the G-code is identical to main's
too:
| Project | main | this PR |
|---|---:|---:|
| Mensch oder Gott 2 | 121.2 s, 111.7 s | 68.2 s, 61.0 s |
| Stranger Things 169×250 | 100.7 s, 93.0 s | 59.7 s, 65.1 s |
| RDR Front 229×256 | 13.9 s, 13.4 s | 10.3 s, 10.1 s |
| Lupo+AMS | 19.9 s, 13.9 s | 20.9 s, 11.4 s |
| Eagle 200×200 | 38.9 s, 37.5 s | 38.1 s, 37.1 s |
Eagle uses about 15 s less CPU on both machines, but its export is bound
by G-code generation, so its slice time does
not change. Lupo's first run on Windows was slow with both builds. Peak
memory is the same within run-to-run spread,
except that it is about 0.1–0.2 GB higher on Stranger Things on the M5
Max and about 0.1 GB higher on Mensch oder Gott 2
on Windows.
<!--
> A guide for users on how to download the artifacts from this PR.
-->
[How to Download Pull Requests Artifacts for
Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
main has since given texture displacement a model UV channel of its own
(ModelVolume::texture_uv). That channel belongs to a part rather than to
the object, so it joins base_mesh and the paint masks in the per-part
entry each job now carries, and every part maps through its own layout.
Also kept from main in the panel: panel_tooltip() in place of the wrapped
ImGui tooltip, and the plural forms of the triangle-count note - with the
count still summed over the parts the bake will act on.
The flow ratio calibration capped its top surface and internal solid
infill speeds with a Flow built from the profile's line width and layer
height. A line width of 0 (auto) made that Flow throw for negative
spacing, which left the main loop and terminated the app.
Build the Flow from the width and height the calibration actually
prints, nozzle x 1.2 by nozzle / 2, as 2.4.2 did. This also corrects the
cap for non-zero widths, which was computed for a narrower line than the
one printed and let the test exceed the filament's max volumetric speed.
A Type2 tower with a rib or rectangle wall still carried the cone from
wipe_tower_cone_angle (30 degrees by default, hidden unless the wall type
is Cone) in two places that model the tower: the fake tower used by the
G-code path conflict check, and first_layer_wipe_tower_corners, which feeds
the first-layer convex hull and the skirt. On a tall tower that phantom cone
reported conflicts with objects the tower never reaches, enlarged the
first-layer print area, and could push a combined skirt off the bed.
Both now use the angle only for a Type2 tower with a cone wall, the same
rule construct_mesh and the footprint estimate already follow.
merge_tcr formatted the feedrate of the travel that joins two wipe tower
blocks with std::to_string, which follows the numeric locale. The GUI slices
on a thread that keeps the user's locale, so a comma-decimal locale wrote
moves such as 'G1 Y249.463 F5400,000000', which Klipper rejects. Format it
with float_to_string_decimal_point like the X and Y beside it; the output in
the C locale is unchanged.
The comma-locale test helper moves to the shared test header so the wipe
tower test can use it.
When a saved prime tower position no longer fits the estimated tower, the
load-time clamp moved it to the comfort-margin bound with no regard for the
objects on the plate, and stored it without telling the user. A tower saved
in a corner could land on the model and produce a G-code conflict the user
never caused.
The GUI reload clamp and the CLI pre-slice clamp now keep the re-placed spot
only when it is clear of every printable object and its brim. Otherwise they
take the clear spot nearest the saved position, keeping the comfort margin
where the plate allows, and only fall back to the old spot when no space is
left. The GUI shows a notification whenever a saved tower is moved, and the
CLI logs a warning.
hdiutil create -srcfolder sizes the image from the source folder and sometimes leaves too little room, failing every retry with "No space left on device" while packaging the profile validator DMG. Pass -size as the source size plus 20% and 50 MB; the free space compresses away in UDZO.
Some calls of the same script set fewer placeholders than the others,
so a placeholder the editor offers could stop the slice with "Variable
does not exist" on one path only:
- layer_change_gcode set max_layer_z after processing the template.
- Belt brim layers ran layer_change_gcode without
most_used_physical_extruder_id or the mass values. Both layer change
paths now share one helper.
- Printers that aren't bed slingers ran time_lapse_gcode with only
layer_num, layer_z and max_layer_z. Both timelapse paths now share
one helper for the snapshot placeholders, which picks the snapshot
position only when the template uses it.
- The Type 1 wipe tower ran filament_start_gcode without layer_num,
layer_z and max_layer_z, and filament_end_gcode without
filament_extruder_id and max_layer_z. filament_extruder_id is the
filament being unloaded, as in the Type 1 filament start G-code and
the end-of-print filament end G-code.
- The first filament start G-code on Bambu Lab printers had no layer_z
or max_layer_z.
The editor looks up a script's placeholder list by its option key, but
the timelapse list was keyed timelapse_gcode while the option is
time_lapse_gcode, so the editor showed no timelapse placeholders. The
list and the name passed to placeholder_parser_process, which the
placeholder validator looks up by, are now both time_lapse_gcode.
previous_extruder and next_extruder hold filament indexes, and
previous_extruder is -1 before any filament is loaded.
filament_extruder_id is the extruder index in filament end G-code at a
tool change outside the Type 1 wipe tower, and machine end G-code gets
the value from the last end-of-print filament end G-code. layer_num is
-1 before the first layer. total_wipe_tower_filament is a length in mm.
Since #13414 (v2.4.0), NetworkAgent calls default to the Orca cloud agent, whose Bambu-only methods are stubs that return empty data. These call sites didn't pass a provider, so firmware info, the MakerWorld task list, the cloud camera URL in Part Skip and Send to Printer, and the MakerWorld rating flow got empty data instead of calling the Bambu plugin. Pass get_printer_cloud_provider() at each one, as #13756, #14688 and #15911 did for the other call sites.
Use flock instead of fcntl for the refresh token lock on POSIX. An fcntl lock is held per process, so a second thread took it without waiting, and closing that thread's fd released it for the first thread too. Another Orca instance could then send the same refresh token while the first one was still rotating it.
# Description
Objects made of thousands of parts slice many times faster. Nearly all
of their slicing time went into deciding which parts touch for the brim,
and on macOS that cost was far higher, so an M5 Max took 2.5× longer
than a Windows desktop on the painted city map from @raistlin7447
https://github.com/OrcaSlicer/OrcaSlicer/pull/15985#issuecomment-6277850280.
That model is one object with 6,948 parts. It now slices in under 21 s
on both machines.
| `painted_city_map.3mf`, CLI slice | main | this PR |
|---|---|---|
| macOS, Apple M5 Max | 265 s | 18.4 s |
| Windows, Intel Core Ultra 7 270K Plus | 101.8 s | 20.1 s |
No change to slicing output: the G-code is byte-identical to main's.
# Screenshots/Recordings/Graphs
<!--
> Please attach relevant screenshots to showcase the UI changes.
> Please attach images that can help explain the changes.
-->
## Tests
G-code matches main's, apart from the timestamp line, for the city map
on macOS and Windows and for four other projects on macOS (13 files in
all). A new test checks that the brim groups an object's parts by
contact: overlapping and touching parts share a group, and a part 0.5 mm
away gets its own. It passes on main and on this branch, and so does the
rest of the `fff_print` suite.
<!--
> A guide for users on how to download the artifacts from this PR.
-->
[How to Download Pull Requests Artifacts for
Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
Quit was only bound to Cmd+Q on macOS. Add a Quit entry to the shortcut
registry bound to Ctrl+Q and handle it in the global key handler, so the
shortcut reaches the app regardless of focus. The File menu shows it as
display text. The macOS-only key check is removed; Cmd+Q now goes through
the registry.
The fit box was the whole bed, so a model could sit on a bed_exclude_area
such as the corner notch on the Qidi Q2.
Fit into the bed minus each rectangular exclusion: every rectangle
spanned by bed and exclusion edges that overlaps no exclusion. Candidates
no wider than the bed padding are dropped, otherwise a sliver at the bed
edge wins and the model is scaled to nothing. Selection::fit_rectangle
keeps the candidate that allows the largest scale.
Fix Moonraker connection threads outliving a destroyed printer agent
connect_printer and disconnect_printer detached the in-flight
connection thread, so the agent's destructor could not join it. On
exit, clear_printer_agent_cache disconnects each agent and then
destroys it, and a connection thread whose query succeeded afterwards
used the freed agent.
Each connection thread now joins the one it replaces, so the
destructor's join waits for all of them. The server info and status
queries are cancelled once their connection is superseded, so the wait
is about a second at most. A superseded connection no longer writes its
status into the next connection's cache or reports itself connected.
clear_printer_agent_cache destroys the agents after releasing the
registry lock, since destroying one now waits for its threads.
Co-authored-by: Ian Chua <iancrb00@gmail.com>
# Description
OrcaSlicer crashed on launch whenever an enabled plugin finished loading
before the main window was created, which is the usual case with locally
installed plugins. This regressed in #16708: the check that installs a
plugin's printer agent once it registers ran after every plugin load,
including during the splash screen, before any window existed. The check
now waits for the main window, where the startup preset load installs
the selected agent anyway, and only runs for plugins that provide a
printer connection, so agents that register late (the case #16708 fixed)
are still installed without a preset change.
No change to slicing output; plugins without a printer connection go
back to only refreshing the printer agent list after they load.
# Screenshots/Recordings/Graphs
<!--
> Please attach relevant screenshots to showcase the UI changes.
> Please attach images that can help explain the changes.
-->
## Tests
<!--
> Please describe the tests that you have conducted to verify the
changes made in this PR.
-->
<!--
> A guide for users on how to download the artifacts from this PR.
-->
[How to Download Pull Requests Artifacts for
Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
The texture displacement gizmo took the object's layer stack, its options
and its bake target from the first model part, so a multibody object was
displaced only on that part. The brush paints across every part, so the
user's paint on the others was kept and then quietly ignored, and with
only a later part painted the Bake button stayed disabled.
The bake, prepare and preview jobs now each carry a vector of parts and
run them in one job, under one progress bar, one Cancel and one undo
step. Remesh and subdivide cover every part as well, since a part left
coarse has no vertices for a height map to move. The per-unwrap fields of
a layer (LSCM seam edges, island placements, their join groups and the uv
overrides) index the owning part's mesh and chart ids, so they are dropped
for the other parts and each part unwraps on its own; everything else in
the stack applies unchanged.
The layer stack, the options and the UV and seam editors stay on the
first model part - they are object-wide settings kept on one part, not a
per-part thing - and the Fast view still shades that part alone.
Fixes#16559
The G-code processor remembers where a pause, color change or custom
G-code vertex sits in the move list, so it can move that vertex to the
first extrusion after it. A pause flushes the time planner first, which
inserts actual speed moves ahead of the vertex, so the remembered index
pointed at an earlier move: the previous layer's last extrusion was
moved instead, a real move was erased, and the time blocks queued after
the vertex were left one move off.
Shift the remembered index by the moves each flush inserts before it,
and shift the queued blocks after the erase. The Preview numbers layers
from the move order, so the stray move showed up as extra layers and
listed pauses on the wrong layer.
The painting gizmos clip the selected instance at the plate, so a sinking
object stopped at the bed with nothing to show how it continues below it, and
the plate disappeared along with the bed mesh. Give every paint tool the same
view of that region:
- Draw the part of the selected instance below the plate at 50% opacity with
depth writes off, so it reads as the object going through the plate.
- Keep the plate and its grid while the bed mesh is hidden, instead of losing
every reference plane in the scene.
- Mark the plate intersection with a 0.4 mm outline rather than an opaque
filled cap, which covered the model and hid the ghost from above.
- Gate the bed mesh and the below-plate pass on the same predicate. Texture
displacement derives from GLGizmoPainterBase like the other painters but was
missing from the gizmo type list in is_bed_visible(), so it kept its bed.
- Add GLVolume::simple_render()'s ban_color_volume so the ghost keeps its alpha
for volumes with MMU segmentation facets, whose sub-models carry their own
opaque filament colours, and stop gating the ghost on is_active: the colour
painter marks the whole instance inactive and draws it in its own pass.
# Description
Slicing performance work, split out of #14662 so it can be reviewed on
its own. No new features and no behaviour change: the same G-code,
produced faster. Nothing here knows about texture displacement.
The trigger was a plate that took about 24 min to slice at 0.1 mm once a
colour texture was baked onto it. The cause is general, not
texture-specific: ClipperLib's sweep line costs grow with the number of
edges crossing a scan line, and any layer cut into tens of thousands of
small pieces (fine relief, dense colour painting, heavily fragmented
models) makes several per-piece loops redo whole-layer work.
## What changed
**Restrict whole-layer work to the neighbourhood that needs it**
- `make_fills`: clip the layer's no-overlap area to each expolygon's box
before intersecting.
- `discover_vertical_shells`: the small-piece filter compares only
against the nearby part of the layer.
- `bridge_over_infill`: whole-layer union/diff/intersection restricted
to the candidate's neighbourhood; fill boundary expanded once per
spacing; anchor tree built only from lines crossing the scan range; bbox
pre-check in the collision test.
**Batch booleans by tile instead of per piece.**
`ClipperUtils::tile_expolygons` groups a layer's pieces into tiles, so a
huge clip contour is clipped once per tile rather than once per piece.
`detect_surfaces_type` at 0.1 mm went from about 145 s to about 50 s.
**Parallelize what is already independent:** a layer's regions in
`detect_surfaces_type`, `process_external_surfaces` and
`discover_vertical_shells`; wall generation and solid infill splitting;
colour segmentation and vertical shells.
**Stop copying polygons on move.** `MultiPoint` had no `Points &&`
constructor, so every derived move constructor passing
`std::move(points)` copied them. Added it, marked the moves `noexcept`,
and made `append(vector&&)` move its elements. Note the consequence: a
moved-from `Polygon` or `Polyline` is now really empty where it used to
silently keep its points.
**Seam placement.** `visit_nearby_points` visits candidates as the k-d
tree finds them instead of collecting them into a vector first.
**Travel ordering and sharp-tail detection** test only the pairs whose
boxes can meet, through a uniform grid and a bbox pre-filter, instead of
every pair.
## Results
| | before | after |
|---|---|---|
| Painted plate, 0.1 mm, 2000k triangles | 1447 s | 587 s |
| Same plate, default 750k | 99.5 s | 85.6 s |
| Unpainted, 0.1 mm | 523 s | 430 s |
## Tests
**179 of 179 G-code outputs byte-identical** across 11 models and 17
configurations (default, fine layers, zero and dense infill, no shells,
normal and tree supports, extra bridge layers, interface shells, three
`ensure_vertical_shell_thickness` modes, thick walls, spiral mode, five
seam modes), comparing full library builds of this branch against its
merge base. The painted plate is part of that matrix, and it is the case
whose layers reach the tiling threshold at all.
New unit tests:
- `test_kdtree.cpp`: the visiting and collecting searches return the
same points in the same order, and a radius search returns exactly the
points inside the radius.
- `test_clipper_utils.cpp`: the tiled and plain `diff_ex` and
`intersection_ex` return the same rings with the same coordinates, with
and without the safety offset, compared after rotating each ring to its
lowest point and sorting. The fixture asserts it really is split into
more than one tile, so it cannot quietly stop covering the tiled path.
Don't log a parse error for a vendor profile pruned beside its cache
Packaging deletes <vendor>.json for every vendor that ships a .opc cache, but installable_cache_version still read it to compare versions. Every packaged build logged a JSON parse error per installed vendor at startup. Check that the file exists first, as installed_vendor_version already does. The returned version does not change.
Sets the exclude-object outline tolerance to 0.2 mm in the four AD5M and AD5M Pro base process profiles. Every AD5M, AD5M Pro, AD5X, Creator 5, Creator 5 Pro and Adventurer A5 process inherits it, and so do some Guider 4 processes. Fewer outline points let these Klipper printers fit more objects on a plate without the "Timer too close" error. Also bumps the Flashforge profile version.
Placeholders that GCodeProcessor fills in after the G-code is generated
(print_time_total_sec and the other print_time_* parts,
used_filament_length, and the print statistics such as total_weight)
hold a tag such as @TOTAL_WEIGHT@ while the template is evaluated.
Multiplying one already failed with a type error. Adding a number
joined the tag as text, so {total_weight + 5} printed 123.455 for a
123.45 g print, and a comparison compared the tag as text, so
{if total_weight > 100} was always true. Neither gave an error.
PlaceholderParser::set_deferred() now registers such a value. Printing
it and joining it to text work as before. A calculation, a comparison,
a regex or a condition on it fails with an error that says the value is
known only after the G-code is generated, also after it was copied to a
variable or through regex_replace(). Adding a number or another
deferred value to one is treated as a sum and fails too. Text that
already contains one joins a number as text, like any other string.
filament_change() inside an {if} branch that is not taken now does
nothing. It used to set the current extruder from an uninitialized
value.