From 5b05b6104a2f03070b756ea56f92a05d7383028a Mon Sep 17 00:00:00 2001 From: yogihybo Date: Thu, 23 Apr 2026 02:02:12 +1000 Subject: [PATCH] Fix first layer speed and layer slow down handling with rafts (#13224) Adjust initial- and slowdown-layer speed logic to correctly account for raft layers. Replace the previous layer checks with object_layer_over_raft(), simplify initial-layer speed selection, and split the slow_down_layers interpolation into separate branches for configurations with and without rafts so the lerp uses the correct layer offset. Also avoid applying overhang speed adjustments to object layers that are over rafts. --- src/libslic3r/GCode.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index c67d8b6695..e23543869b 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -6365,14 +6365,17 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, if (speed == 0) speed = filament_max_volumetric_speed / _mm3_per_mm; - if (this->on_first_layer()) { + + const auto _layer = layer_id(); + if (this->on_first_layer() || object_layer_over_raft()) { //BBS: for solid infill of first layer, speed can be higher as long as //wall lines have be attached - if (path.role() != erBottomSurface) - speed = m_config.get_abs_value("initial_layer_speed"); - } - else if(m_config.slow_down_layers > 1){ - const auto _layer = layer_id(); + if (path.role() != erBottomSurface) { + speed = is_perimeter(path.role()) ? m_config.get_abs_value("initial_layer_speed") : + m_config.get_abs_value("initial_layer_infill_speed"); + } + } else if (m_config.slow_down_layers > 1 && !m_config.raft_layers > 0) { + if (_layer > 0 && _layer < m_config.slow_down_layers) { const auto first_layer_speed = is_perimeter(path.role()) @@ -6382,7 +6385,18 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, speed = std::min( speed, Slic3r::lerp(first_layer_speed, speed, - (double)_layer / m_config.slow_down_layers)); + (double) (_layer) / m_config.slow_down_layers)); + } + } + } else if (m_config.slow_down_layers > 1 && m_config.raft_layers > 0 ) { + + if (_layer > m_config.raft_layers && (_layer - m_config.raft_layers) < m_config.slow_down_layers) { + const auto first_layer_speed + = is_perimeter(path.role()) ? m_config.get_abs_value("initial_layer_speed") : + m_config.get_abs_value("initial_layer_infill_speed"); + if (first_layer_speed < speed) { + speed = std::min(speed, Slic3r::lerp(first_layer_speed, speed, + (double) (_layer - m_config.raft_layers) / m_config.slow_down_layers)); } } } @@ -6445,7 +6459,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, bool variable_speed = false; std::vector new_points {}; - if (m_config.enable_overhang_speed && !this->on_first_layer() && + if (m_config.enable_overhang_speed && !this->on_first_layer() && !object_layer_over_raft() && (is_bridge(path.role()) || is_perimeter(path.role()))) { bool is_external = is_external_perimeter(path.role()); double ref_speed = is_external ? m_config.get_abs_value("outer_wall_speed") : m_config.get_abs_value("inner_wall_speed");