diff --git a/src/libslic3r/Slicing.cpp b/src/libslic3r/Slicing.cpp index 81e9bf0c5..9af6048ab 100644 --- a/src/libslic3r/Slicing.cpp +++ b/src/libslic3r/Slicing.cpp @@ -267,7 +267,7 @@ std::vector layer_height_profile_adaptive( int current_facet = 0; #if ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE while (slice_z <= slicing_params.object_print_z_height()) { - double height = 999.0; + double height = slicing_params.max_layer_height; #else double height = slicing_params.first_object_layer_height; while ((slice_z - height) <= slicing_params.object_print_z_height()) { diff --git a/src/libslic3r/SlicingAdaptive.cpp b/src/libslic3r/SlicingAdaptive.cpp index bc02a89c1..6776d8d71 100644 --- a/src/libslic3r/SlicingAdaptive.cpp +++ b/src/libslic3r/SlicingAdaptive.cpp @@ -94,8 +94,8 @@ float SlicingAdaptive::cusp_height(float z, float cusp_value, int ¤t_facet continue; // compute cusp-height for this facet and store minimum of all heights float normal_z = m_face_normal_z[ordered_id]; - height = std::min(height, (normal_z == 0.f) ? 9999.f : std::abs(cusp_value / normal_z)); - } + height = std::min(height, (normal_z == 0.0f) ? (float)m_slicing_params.max_layer_height : std::abs(cusp_value / normal_z)); + } } // lower height limit due to printer capabilities @@ -115,13 +115,13 @@ float SlicingAdaptive::cusp_height(float z, float cusp_value, int ¤t_facet // Compute cusp-height for this facet and check against height. float normal_z = m_face_normal_z[ordered_id]; - float cusp = (normal_z == 0) ? 9999 : abs(cusp_value / normal_z); - + float cusp = (normal_z == 0.0f) ? (float)m_slicing_params.max_layer_height : abs(cusp_value / normal_z); + float z_diff = zspan.first - z; // handle horizontal facets - if (m_face_normal_z[ordered_id] > 0.999) { - // Slic3r::debugf "cusp computation, height is reduced from %f", $height; + if (normal_z > 0.999f) { + // Slic3r::debugf "cusp computation, height is reduced from %f", $height; height = z_diff; // Slic3r::debugf "to %f due to near horizontal facet\n", $height; } else if (cusp > z_diff) { @@ -139,7 +139,7 @@ float SlicingAdaptive::cusp_height(float z, float cusp_value, int ¤t_facet // lower height limit due to printer capabilities again height = std::max(height, float(m_slicing_params.min_layer_height)); } - + // Slic3r::debugf "cusp computation, layer-bottom at z:%f, cusp_value:%f, resulting layer height:%f\n", unscale $z, $cusp_value, $height; return height; } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 693204435..c67604603 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -278,8 +278,8 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const ImGui::SameLine(); float widget_align = ImGui::GetCursorPosX(); ImGui::PushItemWidth(120.0f); - m_adaptive_cusp = std::min(m_adaptive_cusp, (float)m_slicing_parameters->max_layer_height); - ImGui::SliderFloat("", &m_adaptive_cusp, 0.0f, (float)m_slicing_parameters->max_layer_height, "%.2f"); + m_adaptive_cusp = clamp((float)m_slicing_parameters->min_layer_height, (float)m_slicing_parameters->max_layer_height, m_adaptive_cusp); + ImGui::SliderFloat("", &m_adaptive_cusp, (float)m_slicing_parameters->min_layer_height, (float)m_slicing_parameters->max_layer_height, "%.2f"); ImGui::Separator(); if (imgui.button(_(L("Smooth"))))