From fcc13d166559b37190b4e54dcb53cf5ade07c9e2 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 1 Dec 2021 09:16:53 +0100 Subject: [PATCH] #7388 - Fixed shell does not align in Z direction if raft enabled in gcode preview --- src/slic3r/GUI/GCodeViewer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 671fdbe6e..69e652d4f 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -2067,8 +2067,19 @@ void GCodeViewer::load_shells(const Print& print, bool initialized) instance_ids[i] = i; } + size_t current_volumes_count = m_shells.volumes.volumes.size(); m_shells.volumes.load_object(model_obj, object_id, instance_ids, "object", initialized); + // adjust shells' z if raft is present + const SlicingParameters& slicing_parameters = obj->slicing_parameters(); + if (slicing_parameters.object_print_z_min != 0.0) { + const Vec3d z_offset = slicing_parameters.object_print_z_min * Vec3d::UnitZ(); + for (size_t i = current_volumes_count; i < m_shells.volumes.volumes.size(); ++i) { + GLVolume* v = m_shells.volumes.volumes[i]; + v->set_volume_offset(v->get_volume_offset() + z_offset); + } + } + ++object_id; }