Browse Source

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.
Lukáš Hejl 1 year ago
parent
commit
5ddcea806b
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/libslic3r/GCode.cpp

+ 3 - 1
src/libslic3r/GCode.cpp

@@ -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;
 }