From 90073dce70fb05bda80421158175b851855f0a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Fri, 16 Aug 2024 14:04:51 +0200 Subject: [PATCH] SPE-2441: Fix discontinuity between the processed blocks' exit speed and the new first block's entry speed. This discontinuity affected both time estimation and actual speed visualization. --- src/libslic3r/GCode/GCodeProcessor.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 2f52c8366d..6fd42f7e5a 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -412,10 +412,20 @@ void GCodeProcessor::TimeMachine::calculate_time(GCodeProcessorResult& result, P it_stop_time->elapsed_time = time; } - if (keep_last_n_blocks) + if (keep_last_n_blocks) { blocks.erase(blocks.begin(), blocks.begin() + n_blocks_process); - else + + // Ensure that the new first block's entry speed will be preserved to prevent discontinuity + // between the erased blocks' exit speed and the new first block's entry speed. + // Otherwise, the first block's entry speed could be recalculated on the next pass without + // considering that there are no more blocks before this first block. This could lead + // to discontinuity between the exit speed (of already processed blocks) and the entry + // speed of the first block. + TimeBlock &first_block = blocks.front(); + first_block.max_entry_speed = first_block.feedrate_profile.entry; + } else { blocks.clear(); + } } void GCodeProcessor::TimeProcessor::reset()