From b3b0961d91560320bca12cdc4b712563b604e668 Mon Sep 17 00:00:00 2001 From: Vovodroid Date: Thu, 21 Nov 2024 15:40:51 +0200 Subject: [PATCH] Adaptive layers - respect layer height range modifiers. (#5941) * Adaptive layers - respect layer height range modifiers. * Remove #pragma optimize --- src/libslic3r/Slicing.cpp | 13 +++++++++++++ src/libslic3r/Slicing.hpp | 1 + src/slic3r/GUI/GLCanvas3D.cpp | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Slicing.cpp b/src/libslic3r/Slicing.cpp index 290871b9142..6655e3911d2 100644 --- a/src/libslic3r/Slicing.cpp +++ b/src/libslic3r/Slicing.cpp @@ -319,6 +319,13 @@ std::vector layer_height_profile_adaptive(const SlicingParameters& slici else if (layer_height_profile.back() > height && layer_height_profile.back() - height > LAYER_HEIGHT_CHANGE_STEP) height = layer_height_profile.back() - LAYER_HEIGHT_CHANGE_STEP; + for (auto const& [range,options] : object.layer_config_ranges) { + if ( print_z >= range.first && print_z <= range.second) { + height = options.opt_float("layer_height"); + break; + }; + }; + layer_height_profile.push_back(print_z); layer_height_profile.push_back(height); print_z += height; @@ -444,6 +451,7 @@ std::vector smooth_height_profile(const std::vector& profile, co } void adjust_layer_height_profile( + const ModelObject &model_object, const SlicingParameters &slicing_params, std::vector &layer_height_profile, coordf_t z, @@ -478,6 +486,11 @@ void adjust_layer_height_profile( } } + for (auto const& [range,options] : model_object.layer_config_ranges) { + if (z >= range.first - current_layer_height && z <= range.second + current_layer_height) + return; + }; + // 2) Is it possible to apply the delta? switch (action) { case LAYER_HEIGHT_EDIT_ACTION_DECREASE: diff --git a/src/libslic3r/Slicing.hpp b/src/libslic3r/Slicing.hpp index 6ba3403bba8..a7b21a140d3 100644 --- a/src/libslic3r/Slicing.hpp +++ b/src/libslic3r/Slicing.hpp @@ -176,6 +176,7 @@ enum LayerHeightEditActionType : unsigned int { }; void adjust_layer_height_profile( + const ModelObject &model_object, const SlicingParameters &slicing_params, std::vector &layer_height_profile, coordf_t z, diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 9fc70c62451..539cf687035 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -590,7 +590,7 @@ void GLCanvas3D::LayersEditing::adjust_layer_height_profile() { this->update_slicing_parameters(); PrintObject::update_layer_height_profile(*m_model_object, *m_slicing_parameters, m_layer_height_profile); - Slic3r::adjust_layer_height_profile(*m_slicing_parameters, m_layer_height_profile, this->last_z, this->strength, this->band_width, this->last_action); + Slic3r::adjust_layer_height_profile(*m_model_object, *m_slicing_parameters, m_layer_height_profile, this->last_z, this->strength, this->band_width, this->last_action); m_layers_texture.valid = false; }