Add to GCodeGenerator::last_position only when it has an assigned value.

This behavior was there for a long time, but it was uncovered when std::optional was used.
This commit is contained in:
Lukáš Hejl 2024-01-09 10:53:43 +01:00 committed by Martin Šach
parent da57489874
commit 5ddcea806b

View File

@ -2641,7 +2641,9 @@ void GCodeGenerator::set_origin(const Vec2d &pointf)
{
// if origin increases (goes towards right), last_pos decreases because it goes towards left
const auto offset = Point::new_scale(m_origin - pointf);
*(this->last_position) += offset;
if (last_position.has_value())
*(this->last_position) += offset;
m_wipe.offset_path(offset);
m_origin = pointf;
}