From b5c56caf6f7b0e56cda421fa49647a28373478af Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 26 Nov 2018 15:19:42 +0100 Subject: [PATCH] Fixed an issue with the SLA Z offset at the end of slicing, fixed compilation on OSX due to the libigl overriding our "L" localization macro. --- src/slic3r/GUI/GLCanvas3D.cpp | 21 ++++++++------------- src/slic3r/GUI/GLGizmo.cpp | 5 +++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 4d2ab57a0..f2ff7d803 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4091,7 +4091,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re if (printer_technology == ptSLA) { size_t idx = 0; const SLAPrint *sla_print = this->sla_print(); - for (const SLAPrintObject *print_object : sla_print->objects()) { + std::vector shift_zs(m_model->objects.size(), 0); + for (const SLAPrintObject *print_object : sla_print->objects()) { SLASupportState &state = sla_support_state[idx ++]; const ModelObject *model_object = print_object->model_object(); // Find an index of the ModelObject @@ -4103,6 +4104,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re auto it = std::find(sla_print->model().objects.begin(), sla_print->model().objects.end(), model_object); assert(it != sla_print->model().objects.end()); object_idx = it - sla_print->model().objects.begin(); + // Cache the Z offset to be applied to all volumes with this object_idx. + shift_zs[object_idx] = print_object->get_current_elevation(); // Collect indices of this print_object's instances, for which the SLA support meshes are to be added to the scene. // pairs of std::vector> instances[std::tuple_size::value]; @@ -4132,19 +4135,11 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re for (size_t istep = 0; istep < sla_steps.size(); ++istep) if (!instances[istep].empty()) m_volumes.load_object_auxiliary(print_object, object_idx, instances[istep], sla_steps[istep], state.step[istep].timestamp, m_use_VBOs && m_initialized); - - if (volumes_count != m_volumes.volumes.size()) - { - // If any volume has been added - // Shift-up all volumes of the object so that it has the right elevation with respect to the print bed - double shift_z = print_object->get_current_elevation(); - for (GLVolume* volume : m_volumes.volumes) - { - if (volume->object_idx() == object_idx) - volume->set_sla_shift_z(shift_z); - } - } } + + // Shift-up all volumes of the object so that it has the right elevation with respect to the print bed + for (GLVolume* volume : m_volumes.volumes) + volume->set_sla_shift_z(shift_zs[volume->object_idx()]); } if (printer_technology == ptFFF && m_config->has("nozzle_diameter")) diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index e2523f07d..c52d2ebf1 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -1,4 +1,6 @@ -// #include +// Include GLGizmo.hpp before I18N.hpp as it includes some libigl code, which overrides our localization "L" macro. +#include "GLGizmo.hpp" + #include #include @@ -22,7 +24,6 @@ #include "GUI_Utils.hpp" #include "GUI_App.hpp" #include "I18N.hpp" -#include "GLGizmo.hpp" #include "PresetBundle.hpp" #if ENABLE_GIZMOS_SHORTCUT