perf: skip the unused curled wall estimate to speed up slicing by up to 9% (#16113)

perf: skip estimating curled walls when nothing reads them

The curled extrusion estimate ran whenever a region had overhang speed on,
which is the default, but only the slowdown for curled perimeters reads the
curled lines it produces, and that slowdown is off by default. The step now
also requires a region with the slowdown on, and clears the curled lines
when it skips the estimate, so none are left from an earlier slice. 
Also fixes stale fan commands due to the stale curled lines on the reused layers.
This commit is contained in:
Kris Austin
2026-10-04 09:45:19 +01:00
committed by GitHub
parent 88346efceb
commit 90ac58d3cd
4 changed files with 69 additions and 9 deletions
@@ -566,6 +566,12 @@ struct SlicedCage
using Walls = std::vector<std::vector<ProcessedPoint>>;
bool has_curled_lines(const PrintObject &object)
{
const auto layers = object.layers();
return std::any_of(layers.begin(), layers.end(), [](const Layer *layer) { return !layer->curled_lines.empty(); });
}
// Estimates every wall of `layer` against whatever layer `estimator` was last prepared with before it.
Walls estimate_walls(ExtrusionQualityEstimator &estimator, const PrintObject *object, const Layer &layer)
{
@@ -707,6 +713,53 @@ TEST_CASE("Precomputed overhang data has the curled-line tree exactly when a reg
CHECK((precomputed.front().lower_curled_lines != nullptr) == slowdown);
}
TEST_CASE("Curled walls are estimated only when overhang speed and the slowdown for curled perimeters are both on", "[ExtrusionProcessor]")
{
const auto [overhang_speed, slowdown, estimated] = GENERATE(table<bool, bool, bool>({
{true, true, true},
{true, false, false},
{false, true, false},
}));
DynamicPrintConfig config = caged_overhang_config("classic");
config.set_deserialize_strict({{"enable_overhang_speed", overhang_speed ? "1" : "0"},
{"slowdown_for_curled_perimeters", slowdown ? "1" : "0"}});
const SlicedCage cage(config);
CHECK(has_curled_lines(*cage.object) == estimated);
}
TEST_CASE("Curled walls are estimated when overhang speed and the slowdown for curled perimeters are on in different objects", "[ExtrusionProcessor]")
{
const std::vector<std::vector<ConfigBase::SetDeserializeItem>> overrides{
{{"enable_overhang_speed", "1"}, {"slowdown_for_curled_perimeters", "0"}},
{{"enable_overhang_speed", "0"}, {"slowdown_for_curled_perimeters", "1"}},
};
Print print;
Model model;
init_print(std::vector<TriangleMesh>{caged_overhang_mesh(), caged_overhang_mesh()}, print, model, caged_overhang_config("classic"),
&overrides);
print.process();
REQUIRE(print.objects().size() == 2);
for (const PrintObject *object : print.objects())
CHECK(has_curled_lines(*object));
}
TEST_CASE("Curled walls from an earlier slice are dropped once overhang speed is off", "[ExtrusionProcessor]")
{
DynamicPrintConfig config = caged_overhang_config("classic");
config.set_deserialize_strict("slowdown_for_curled_perimeters", "1");
SlicedCage cage(config);
const Layer *first_layer = cage.print.objects().front()->layers().front();
REQUIRE(has_curled_lines(*cage.print.objects().front()));
config.set_deserialize_strict("enable_overhang_speed", "0");
cage.print.apply(cage.model, config);
cage.print.process();
REQUIRE(cage.print.objects().front()->layers().front() == first_layer);
CHECK_FALSE(has_curled_lines(*cage.print.objects().front()));
}
TEST_CASE("Caged external overhangs are slowed when printed by object or through the pressure equalizer", "[ExtrusionProcessor]")
{
const auto [key, value] = GENERATE(table<const char *, const char *>({