Expand the first layer of a tree support raft once

The non-organic tree support raft was grown by the first layer
expansion on every raft layer, and its first layer by that expansion a
second time. The default 2 mm put the first layer 4 mm out, and a
20 mm setting 40 mm. The second expansion came with BambuStudio's fix
for this setting, which assumes the fixed 3 mm grip that Orca had
replaced with the setting. Restore that grip, so the setting widens the
first layer only, as it does for the other supports.

Ported from Snapmaker/OrcaSlicer@0e572ec63a

Co-authored-by: zackaree-shen <zackary_shen@qq.com>
This commit is contained in:
Ian Bassiandzackaree-shen committed 2026-11-30 14:11:14 -03:00
1 parent 553040c43c
commit 141aeb8a00
2 files changed
+27 -1

No files matched your search

+25
View File
@@ -6,6 +6,7 @@
#include <vector>
#include "libslic3r/Config.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/ExPolygon.hpp"
@@ -15,6 +16,8 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/Layer.hpp"
#include "libslic3r/TriangleMesh.hpp"
@@ -194,6 +197,28 @@ TEST_CASE("A raft is still generated under tree support", "[TreeSupport]")
REQUIRE(rafted_object->layers().front()->print_z > unrafted_object->layers().front()->print_z);
}
// With 4 raft layers, the first two are raft base layers.
TEST_CASE("The first layer expansion widens the first layer of a tree support raft by its value and no other layer", "[TreeSupport][Regression]")
{
auto raft_base_widths = [](double expansion) {
Slic3r::Print print;
slice_with_tree_support(make_cube(20, 20, 5), print, "tree_hybrid", 30, 0, 4, { { "raft_first_layer_expansion", expansion } });
const auto &layers = print.objects().front()->support_layers();
REQUIRE(layers.size() > 1);
auto width = [&layers](size_t idx) {
Points points;
layers[idx]->support_fills.collect_points(points);
return unscaled(BoundingBox(points).size().x());
};
return std::make_pair(width(0), width(1));
};
const auto [first_narrow, second_narrow] = raft_base_widths(2.);
const auto [first_wide, second_wide] = raft_base_widths(6.);
// 4 mm more on each side of the first layer.
CHECK_THAT(first_wide - first_narrow, Catch::Matchers::WithinAbs(8., 0.5));
CHECK_THAT(second_wide, Catch::Matchers::WithinAbs(second_narrow, 0.5));
}
// drop_nodes() decides the node merges and spawns the next layer's nodes in parallel. Every one of
// those decisions has to be applied in a fixed order, or the same model gives different branches on
// each slice.