From f08cae6c5a537aa8fc7a6008d041e70dd9a42a37 Mon Sep 17 00:00:00 2001 From: Kuran Kaname Date: Tue, 23 Dec 2025 06:55:55 +0200 Subject: [PATCH] Adjust resonance avoidance speed calculation (#11462) * Adjust resonance avoidance speed calculation * Only adjust if it's strictly below max * If the speed is over half of the set speed range, use the max speed to prevent slowdowns Signed-off-by: Kuran Kaname * update comment --------- Signed-off-by: Kuran Kaname Co-authored-by: SoftFever --- src/libslic3r/GCode.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 048a428e40..eae1d1711a 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -6186,10 +6186,15 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, ); } - // if still in avoidance mode and under “max”, clamp to “min” - if (m_resonance_avoidance - && speed <= m_config.max_resonance_avoidance_speed.value) { - speed = std::min(speed, m_config.min_resonance_avoidance_speed.value); + // if still in avoidance mode and under "max", adjust speed: + // - speeds in lower half of range: clamp down to "min" + // - speeds in upper half of range: boost up to "max" if (m_resonance_avoidance && speed < m_config.max_resonance_avoidance_speed.value) { + if (speed < m_config.min_resonance_avoidance_speed.value + + ((m_config.max_resonance_avoidance_speed.value - m_config.min_resonance_avoidance_speed.value) / 2)) { + speed = std::min(speed, m_config.min_resonance_avoidance_speed.value); + } else { + speed = m_config.max_resonance_avoidance_speed.value; + } } // reset flag for next segment