From ce2e53dbfa5469992e7a5b8bacec0d322c506c2f Mon Sep 17 00:00:00 2001 From: YuSanka Date: Sun, 5 Apr 2020 23:18:22 +0200 Subject: [PATCH 1/2] Added control of "Invalid numeric input" for the PointCtrl --- src/slic3r/GUI/Field.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index a1a6583bc..c9e91bd95 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1291,9 +1291,13 @@ void PointCtrl::set_value(const boost::any& value, bool change_event) boost::any& PointCtrl::get_value() { double x, y; - x_textctrl->GetValue().ToDouble(&x); - y_textctrl->GetValue().ToDouble(&y); - + if (!x_textctrl->GetValue().ToDouble(&x) || + !y_textctrl->GetValue().ToDouble(&y)) + { + set_value(m_value.empty() ? Vec2d(0.0, 0.0) : m_value, true); + show_error(m_parent, _L("Invalid numeric input.")); + } + else if (m_opt.min > x || x > m_opt.max || m_opt.min > y || y > m_opt.max) { @@ -1303,7 +1307,7 @@ boost::any& PointCtrl::get_value() if (y > m_opt.max) y = m_opt.max; set_value(Vec2d(x, y), true); - show_error(m_parent, _(L("Input value is out of range"))); + show_error(m_parent, _L("Input value is out of range")); } return m_value = Vec2d(x, y); From 0e2fba6d6f07f515620483405021f8c83fba0080 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 8 Apr 2020 08:07:36 +0200 Subject: [PATCH 2/2] Fixed bug in calculating the specular component of the color in shaders --- resources/shaders/gouraud.vs | 8 ++++++-- resources/shaders/variable_layer_height.vs | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/resources/shaders/gouraud.vs b/resources/shaders/gouraud.vs index a9f3f6118..17cc764e2 100644 --- a/resources/shaders/gouraud.vs +++ b/resources/shaders/gouraud.vs @@ -65,11 +65,15 @@ void main() intensity.y = 0.0; if (NdotL > 0.0) - intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); + { + vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz; + intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); + } // Perform the same lighting calculation for the 2nd light source (no specular applied). NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); - intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; + if (NdotL > 0.0) + intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; // compute deltas for out of print volume detection (world coordinates) if (print_box.actived) diff --git a/resources/shaders/variable_layer_height.vs b/resources/shaders/variable_layer_height.vs index 4f98dfa56..5dd697063 100644 --- a/resources/shaders/variable_layer_height.vs +++ b/resources/shaders/variable_layer_height.vs @@ -35,12 +35,16 @@ void main() intensity.y = 0.0; if (NdotL > 0.0) - intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); + { + vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz; + intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); + } // Perform the same lighting calculation for the 2nd light source (no specular) NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); - intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; + if (NdotL > 0.0) + intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; // Scaled to widths of the Z texture. if (object_max_z > 0.0)