diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 6349005987..86796dff5f 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -217,29 +217,21 @@ int GCodeViewer::SequentialView::ActualSpeedImguiWidget::plot(const char* label, } #endif // ENABLE_ACTUAL_SPEED_DEBUG -bool GCodeViewer::SequentialView::Marker::init(std::optional>& model_opt) -{ - if (! model_opt.has_value()) - return false; - - if (m_generic_marker != (model_opt->get() == nullptr)) - m_model.reset(); - - m_generic_marker = (model_opt->get() == nullptr); - bool ret = false; - if (!m_model.is_initialized()) { - if (m_generic_marker) - m_model.init_from(stilized_arrow(16, 2.0f, 4.0f, 1.0f, 8.0f)); - else { - m_model = **model_opt; - model_opt.reset(); - } - ret = true; - } - - m_model.set_color({ 1.0f, 1.0f, 1.0f, 0.5f }); - return ret; -} +void GCodeViewer::SequentialView::Marker::init(std::optional>& model_opt) + { + if (! model_opt.has_value()) + return; + + m_model.reset(); + + m_generic_marker = (model_opt->get() == nullptr); + if (m_generic_marker) + m_model.init_from(stilized_arrow(16, 2.0f, 4.0f, 1.0f, 8.0f)); + else + m_model = **model_opt; + + m_model.set_color({ 1.0f, 1.0f, 1.0f, 0.5f }); + } void GCodeViewer::SequentialView::Marker::render() { @@ -1213,7 +1205,8 @@ void GCodeViewer::render() // Following just makes sure that the shown marker is correct. auto marker_model_opt = wxGetApp().plater()->get_current_canvas3D()->get_current_marker_model(); - if (m_sequential_view.marker.init(marker_model_opt)) + m_sequential_view.marker.init(marker_model_opt); + if (marker_model_opt.has_value()) m_max_bounding_box.reset(); m_sequential_view.render(legend_height, &m_viewer, curr_vertex.gcode_id); diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index ac3ef8bcb6..8b01cb9bc2 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -133,7 +133,7 @@ public: #endif // ENABLE_ACTUAL_SPEED_DEBUG public: - bool init(std::optional>& model_opt); + void init(std::optional>& model_opt); const BoundingBoxf3& get_bounding_box() const { return m_model.get_bounding_box(); } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 11a49e9e74..00cd3cfd01 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -177,6 +177,11 @@ std::optional> GLCanvas3D::get_current_marker_model() c bool seq = m_config->opt_bool("complete_objects"); if (last_printer_notes != printer_notes || r != old_r || h != old_h || seq != old_seq) { + last_printer_notes = printer_notes; + old_r = r; + old_h = h; + old_seq = seq; + out = std::make_optional(nullptr); if (! seq) return out; @@ -212,10 +217,6 @@ std::optional> GLCanvas3D::get_current_marker_model() c m->init_from(mesh); out = std::make_optional(std::move(m)); } - last_printer_notes = printer_notes; - old_r = r; - old_h = h; - old_seq = seq; } return out; }