Fix support preview artifacts (missing layers) (#13310)

Fix support preview artifacts caused by incorrect gap subdivision

Support generation could sometimes split a gap into too many steps,
even when it should fit exactly into a single layer.

This was most noticeable when max_suport_layer_height was equal to
the print layer height (e.g. 0.2 mm).

This resulted in incorrect support layering and visible artifacts
in preview.

The issue was caused by floating-point precision, where values that
should be equal to the configured limit were treated as slightly larger.

Fix by biasing the subdivision calculation with EPSILON so near-equal
values are not split into extra steps.

Applied consistently to:
- SupportMaterial (normal supports)
- TreeSupportCommon (tree stepping)
- TreeSupport (layer creation)
This commit is contained in:
Kiss Lorand
2026-04-23 16:20:06 +03:00
committed by GitHub
parent ff3ad5ed98
commit 0c7e16aa36
3 changed files with 20 additions and 11 deletions

View File

@@ -343,7 +343,8 @@ public:
}
if (double dist_to_go = slicing_params.object_print_z_min - z; dist_to_go > EPSILON) {
// Layers between the raft contacts and bottom of the object.
auto nsteps = int(ceil(dist_to_go / slicing_params.max_suport_layer_height));
// ORCA: Bias by EPSILON so near-equal gaps do not get an extra split from FP noise.
auto nsteps = int(ceil((dist_to_go - EPSILON) / slicing_params.max_suport_layer_height));
double step = dist_to_go / nsteps;
for (int i = 0; i < nsteps; ++ i) {
z += step;
@@ -754,4 +755,4 @@ enum class LineStatus
} // namespace Slic3r
#endif // slic3r_TreeSupportCommon_hpp
#endif // slic3r_TreeSupportCommon_hpp