diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 11dcfa775..1dd16ee91 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -1177,6 +1177,7 @@ void check_model_ids_equal(const Model &model1, const Model &model2); #endif /* NDEBUG */ static const float SINKING_Z_THRESHOLD = -0.001f; +static const double SINKING_MIN_Z_THRESHOLD = 0.05; } // namespace Slic3r diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 9c0341ff4..7a9fdc388 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -595,7 +595,7 @@ bool GLVolume::is_sinking() const bool GLVolume::is_below_printbed() const { - return transformed_convex_hull_bounding_box().max(2) < 0.0; + return transformed_convex_hull_bounding_box().max.z() < 0.0; } #if ENABLE_SINKING_CONTOURS diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index b9aefcc76..498b02605 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -621,7 +621,7 @@ void MainFrame::update_title() if (!dirty_marker.empty() || !project.empty()) { if (!dirty_marker.empty() && project.empty()) project = _("Untitled"); - title = dirty_marker + project + " - "; + title = dirty_marker + project + " - "; } } diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index dbc259444..acb1f1113 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -683,7 +683,8 @@ void Selection::translate(const Vec3d& displacement, bool local) synchronize_unselected_volumes(); #endif // !DISABLE_INSTANCES_SYNCH - this->set_bounding_boxes_dirty(); + ensure_not_below_bed(); + set_bounding_boxes_dirty(); } // Rotate an object around one of the axes. Only one rotation component is expected to be changing. @@ -1712,7 +1713,7 @@ void Selection::calc_unscaled_instance_bounding_box() const if (volume.is_modifier) continue; Transform3d trafo = volume.get_instance_transformation().get_matrix(false, false, true, false) * volume.get_volume_transformation().get_matrix(); - trafo.translation()(2) += volume.get_sla_shift_z(); + trafo.translation().z() += volume.get_sla_shift_z(); unscaled_instance_bounding_box->merge(volume.transformed_convex_hull_bounding_box(trafo)); } } @@ -1729,7 +1730,7 @@ void Selection::calc_scaled_instance_bounding_box() const if (volume.is_modifier) continue; Transform3d trafo = volume.get_instance_transformation().get_matrix(false, false, false, false) * volume.get_volume_transformation().get_matrix(); - trafo.translation()(2) += volume.get_sla_shift_z(); + trafo.translation().z() += volume.get_sla_shift_z(); scaled_instance_bounding_box->merge(volume.transformed_convex_hull_bounding_box(trafo)); } } @@ -2134,6 +2135,32 @@ void Selection::ensure_on_bed() } } +void Selection::ensure_not_below_bed() +{ + typedef std::map, double> InstancesToZMap; + InstancesToZMap instances_max_z; + + for (size_t i = 0; i < m_volumes->size(); ++i) { + GLVolume* volume = (*m_volumes)[i]; + if (!volume->is_wipe_tower && !volume->is_modifier) { + const double max_z = volume->transformed_convex_hull_bounding_box().max.z(); + std::pair instance = std::make_pair(volume->object_idx(), volume->instance_idx()); + InstancesToZMap::iterator it = instances_max_z.find(instance); + if (it == instances_max_z.end()) + it = instances_max_z.insert(InstancesToZMap::value_type(instance, -DBL_MAX)).first; + + it->second = std::max(it->second, max_z); + } + } + + for (GLVolume* volume : *m_volumes) { + std::pair instance = std::make_pair(volume->object_idx(), volume->instance_idx()); + InstancesToZMap::iterator it = instances_max_z.find(instance); + if (it != instances_max_z.end() && it->second < SINKING_MIN_Z_THRESHOLD) + volume->set_instance_offset(Z, volume->get_instance_offset(Z) + SINKING_MIN_Z_THRESHOLD - it->second); + } +} + bool Selection::is_from_fully_selected_instance(unsigned int volume_idx) const { struct SameInstance diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index 0e0e869ef..b3304571f 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -385,6 +385,7 @@ public: private: void ensure_on_bed(); + void ensure_not_below_bed(); bool is_from_fully_selected_instance(unsigned int volume_idx) const; void paste_volumes_from_clipboard();