From 95a9fdea07ea91192b4b45ea94b130156696a2b0 Mon Sep 17 00:00:00 2001 From: elvispr94 <115122855+elvispr94@users.noreply.github.com> Date: Sun, 8 Dec 2024 02:11:02 +0300 Subject: [PATCH] Update ExtrusionProcessor.hpp --- src/libslic3r/GCode/ExtrusionProcessor.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode/ExtrusionProcessor.hpp b/src/libslic3r/GCode/ExtrusionProcessor.hpp index a8fd775e2a1..a96298adc80 100644 --- a/src/libslic3r/GCode/ExtrusionProcessor.hpp +++ b/src/libslic3r/GCode/ExtrusionProcessor.hpp @@ -421,11 +421,16 @@ class ExtrusionQualityEstimator } } } - auto calculate_speed = [&speed_sections, &original_speed](float distance) { float final_speed; if (distance <= speed_sections.front().first) { final_speed = original_speed; + if (distance >0){ + float t = distance / speed_sections.front().first; + t = std::clamp(t, 0.0f, 1.0f); + final_speed = (1.0f - t) * original_speed + t * speed_sections.front().second; + printf("distance %f, speed_sections.front().first %f, original speed %f, t %f, final_speed %f \n", distance, speed_sections.front().first, original_speed, final_speed); + } } else if (distance >= speed_sections.back().first) { final_speed = speed_sections.back().second; } else { @@ -438,7 +443,7 @@ class ExtrusionQualityEstimator t = std::clamp(t, 0.0f, 1.0f); final_speed = (1.0f - t) * speed_sections[section_idx].second + t * speed_sections[section_idx + 1].second; } - return round(final_speed); + return final_speed; }; float extrusion_speed = std::min(calculate_speed(curr.distance), calculate_speed(next.distance));