From 9af9b9b35dedbfeddc5c2f9015051a439e108882 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 16 Nov 2021 12:39:54 +0100 Subject: [PATCH 1/6] Tech ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS set as default --- src/libslic3r/GCode/GCodeProcessor.cpp | 8 -------- src/libslic3r/GCode/GCodeProcessor.hpp | 2 -- src/libslic3r/Geometry.cpp | 2 -- src/libslic3r/Geometry.hpp | 2 -- src/libslic3r/Line.cpp | 2 -- src/libslic3r/Line.hpp | 2 -- src/libslic3r/Technologies.hpp | 3 --- src/libslic3r/TriangleMesh.cpp | 2 -- src/libslic3r/TriangleMesh.hpp | 2 -- src/slic3r/GUI/3DScene.cpp | 13 ------------- src/slic3r/GUI/GCodeViewer.cpp | 6 ------ src/slic3r/GUI/GCodeViewer.hpp | 6 ------ src/slic3r/GUI/GLCanvas3D.cpp | 13 ------------- src/slic3r/GUI/GLCanvas3D.hpp | 4 ---- src/slic3r/GUI/GLShadersManager.cpp | 4 ---- src/slic3r/GUI/GUI_ObjectManipulation.cpp | 14 ++------------ src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 16 ---------------- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 4 ---- src/slic3r/GUI/Selection.cpp | 11 ----------- src/slic3r/GUI/Selection.hpp | 5 ----- 20 files changed, 2 insertions(+), 119 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 448ba89aa..b28d3d706 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -719,9 +719,7 @@ void GCodeProcessor::UsedFilaments::process_caches(GCodeProcessor* processor) void GCodeProcessorResult::reset() { moves = std::vector(); bed_shape = Pointfs(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS max_print_height = 0.0f; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS settings_ids.reset(); extruders_count = 0; extruder_colors = std::vector(); @@ -736,9 +734,7 @@ void GCodeProcessorResult::reset() { moves.clear(); lines_ends.clear(); bed_shape = Pointfs(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS max_print_height = 0.0f; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS settings_ids.reset(); extruders_count = 0; extruder_colors = std::vector(); @@ -889,9 +885,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config) if (first_layer_height != nullptr) m_first_layer_height = std::abs(first_layer_height->value); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_result.max_print_height = config.max_print_height; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS } void GCodeProcessor::apply_config(const DynamicPrintConfig& config) @@ -1122,11 +1116,9 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) if (first_layer_height != nullptr) m_first_layer_height = std::abs(first_layer_height->value); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS const ConfigOptionFloat* max_print_height = config.option("max_print_height"); if (max_print_height != nullptr) m_result.max_print_height = max_print_height->value; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS } void GCodeProcessor::enable_stealth_time_estimator(bool enabled) diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index 330d8f71e..a7c1144f0 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -117,9 +117,7 @@ namespace Slic3r { // Positions of ends of lines of the final G-code this->filename after TimeProcessor::post_process() finalizes the G-code. std::vector lines_ends; Pointfs bed_shape; -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS float max_print_height; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS SettingsIds settings_ids; size_t extruders_count; std::vector extruder_colors; diff --git a/src/libslic3r/Geometry.cpp b/src/libslic3r/Geometry.cpp index 4466d0dcc..ecb29d4b8 100644 --- a/src/libslic3r/Geometry.cpp +++ b/src/libslic3r/Geometry.cpp @@ -33,14 +33,12 @@ bool directions_parallel(double angle1, double angle2, double max_diff) return diff < max_diff || fabs(diff - PI) < max_diff; } -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool directions_perpendicular(double angle1, double angle2, double max_diff) { double diff = fabs(angle1 - angle2); max_diff += EPSILON; return fabs(diff - 0.5 * PI) < max_diff || fabs(diff - 1.5 * PI) < max_diff; } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS template bool contains(const std::vector &vector, const Point &point) diff --git a/src/libslic3r/Geometry.hpp b/src/libslic3r/Geometry.hpp index 769f1d6df..e84a7aace 100644 --- a/src/libslic3r/Geometry.hpp +++ b/src/libslic3r/Geometry.hpp @@ -288,9 +288,7 @@ bool liang_barsky_line_clipping( } bool directions_parallel(double angle1, double angle2, double max_diff = 0); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool directions_perpendicular(double angle1, double angle2, double max_diff = 0); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS template bool contains(const std::vector &vector, const Point &point); template T rad2deg(T angle) { return T(180.0) * angle / T(PI); } double rad2deg_dir(double angle); diff --git a/src/libslic3r/Line.cpp b/src/libslic3r/Line.cpp index 773df3442..3a180f747 100644 --- a/src/libslic3r/Line.cpp +++ b/src/libslic3r/Line.cpp @@ -70,7 +70,6 @@ bool Line::parallel_to(const Line& line) const return sqr(cross2(v1, v2)) < sqr(EPSILON) * v1.squaredNorm() * v2.squaredNorm(); } -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool Line::perpendicular_to(double angle) const { return Slic3r::Geometry::directions_perpendicular(this->direction(), angle); @@ -82,7 +81,6 @@ bool Line::perpendicular_to(const Line& line) const const Vec2d v2 = (line.b - line.a).cast(); return sqr(v1.dot(v2)) < sqr(EPSILON) * v1.squaredNorm() * v2.squaredNorm(); } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool Line::intersection(const Line &l2, Point *intersection) const { diff --git a/src/libslic3r/Line.hpp b/src/libslic3r/Line.hpp index a4dcd827c..751e59458 100644 --- a/src/libslic3r/Line.hpp +++ b/src/libslic3r/Line.hpp @@ -105,10 +105,8 @@ public: double perp_distance_to(const Point &point) const; bool parallel_to(double angle) const; bool parallel_to(const Line& line) const; -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool perpendicular_to(double angle) const; bool perpendicular_to(const Line& line) const; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS double atan2_() const { return atan2(this->b(1) - this->a(1), this->b(0) - this->a(0)); } double orientation() const; double direction() const; diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 4f5098d59..39f1fa4c7 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -80,9 +80,6 @@ // Enable rendering modifiers and similar objects always as transparent #define ENABLE_MODIFIERS_ALWAYS_TRANSPARENT (1 && ENABLE_2_4_0_BETA1) -// Enable the fix for the detection of the out of bed state for sinking objects -// and detection of out of bed using the bed perimeter -#define ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS (1 && ENABLE_2_4_0_BETA1) //==================== diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index 365de8fb4..5eafd6884 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -436,7 +436,6 @@ BoundingBoxf3 TriangleMesh::transformed_bounding_box(const Transform3d &trafo) c return bbox; } -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS BoundingBoxf3 TriangleMesh::transformed_bounding_box(const Transform3d& trafod, double world_min_z) const { // 1) Allocate transformed vertices with their position with respect to print bed surface. @@ -487,7 +486,6 @@ BoundingBoxf3 TriangleMesh::transformed_bounding_box(const Transform3d& trafod, }; return out; } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS TriangleMesh TriangleMesh::convex_hull_3d() const { diff --git a/src/libslic3r/TriangleMesh.hpp b/src/libslic3r/TriangleMesh.hpp index 459917ab9..3a0b2c2ce 100644 --- a/src/libslic3r/TriangleMesh.hpp +++ b/src/libslic3r/TriangleMesh.hpp @@ -125,10 +125,8 @@ public: BoundingBoxf3 bounding_box() const; // Returns the bbox of this TriangleMesh transformed by the given transformation BoundingBoxf3 transformed_bounding_box(const Transform3d &trafo) const; -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS // Variant returning the bbox of the part of this TriangleMesh above the given world_min_z BoundingBoxf3 transformed_bounding_box(const Transform3d& trafo, double world_min_z) const; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS // Return the size of the mesh in coordinates. Vec3d size() const { return m_stats.size.cast(); } /// Return the center of the related bounding box. diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index f377edafa..ca634c079 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -262,11 +262,9 @@ void GLIndexedVertexArray::render( const std::pair& tverts_range, const std::pair& qverts_range) const { -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS // this method has been called before calling finalize() ? if (this->vertices_and_normals_interleaved_VBO_id == 0 && !this->vertices_and_normals_interleaved.empty()) return; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS assert(this->vertices_and_normals_interleaved_VBO_id != 0); assert(this->triangle_indices_VBO_id != 0 || this->quad_indices_VBO_id != 0); @@ -524,7 +522,6 @@ BoundingBoxf3 GLVolume::transformed_convex_hull_bounding_box(const Transform3d & bounding_box().transformed(trafo); } -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS BoundingBoxf3 GLVolume::transformed_non_sinking_bounding_box(const Transform3d& trafo) const { return GUI::wxGetApp().plater()->model().objects[object_idx()]->volumes[volume_idx()]->mesh().transformed_bounding_box(trafo, 0.0); @@ -539,7 +536,6 @@ const BoundingBoxf3& GLVolume::transformed_non_sinking_bounding_box() const } return *m_transformed_non_sinking_bounding_box; } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS void GLVolume::set_range(double min_z, double max_z) { @@ -773,9 +769,7 @@ int GLVolumeCollection::load_wipe_tower_preview( volumes.emplace_back(new GLVolume(color)); GLVolume& v = *volumes.back(); v.indexed_vertex_array.load_mesh(mesh); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS v.set_convex_hull(mesh.convex_hull_3d()); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS v.indexed_vertex_array.finalize_geometry(opengl_initialized); v.set_volume_offset(Vec3d(pos_x, pos_y, 0.0)); v.set_volume_rotation(Vec3d(0., 0., (M_PI / 180.) * rotation_angle)); @@ -882,17 +876,10 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab shader->set_uniform("uniform_color", volume.first->render_color); shader->set_uniform("z_range", m_z_range, 2); shader->set_uniform("clipping_plane", m_clipping_plane, 4); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS shader->set_uniform("print_volume.type", static_cast(m_print_volume.type)); shader->set_uniform("print_volume.xy_data", m_print_volume.data); shader->set_uniform("print_volume.z_data", m_print_volume.zs); shader->set_uniform("volume_world_matrix", volume.first->world_matrix()); -#else - shader->set_uniform("print_box.min", m_print_box_min, 3); - shader->set_uniform("print_box.max", m_print_box_max, 3); - shader->set_uniform("print_box.actived", volume.first->shader_outside_printer_detection_enabled); - shader->set_uniform("print_box.volume_world_matrix", volume.first->world_matrix()); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower); shader->set_uniform("slope.volume_world_normal_matrix", static_cast(volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast())); shader->set_uniform("slope.normal_z", m_slope.normal_z); diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index a38a0e0ed..8eb481f7b 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -681,9 +681,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr if (wxGetApp().is_gcode_viewer()) m_custom_gcode_per_print_z = gcode_result.custom_gcode_per_print_z; -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_max_print_height = gcode_result.max_print_height; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS load_toolpaths(gcode_result); @@ -831,9 +829,7 @@ void GCodeViewer::reset() m_paths_bounding_box = BoundingBoxf3(); m_max_bounding_box = BoundingBoxf3(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_max_print_height = 0.0f; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_tool_colors = std::vector(); m_extruders_count = 0; m_extruder_ids = std::vector(); @@ -850,9 +846,7 @@ void GCodeViewer::reset() #if ENABLE_GCODE_VIEWER_STATISTICS m_statistics.reset_all(); #endif // ENABLE_GCODE_VIEWER_STATISTICS -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_contained_in_bed = true; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS } void GCodeViewer::render() diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 85151ceb8..f81cb823e 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -780,9 +780,7 @@ private: BoundingBoxf3 m_paths_bounding_box; // bounding box of toolpaths + marker tools BoundingBoxf3 m_max_bounding_box; -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS float m_max_print_height{ 0.0f }; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS std::vector m_tool_colors; Layers m_layers; std::array m_layers_z_range; @@ -807,9 +805,7 @@ private: std::vector m_custom_gcode_per_print_z; -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool m_contained_in_bed{ true }; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS public: GCodeViewer(); @@ -839,9 +835,7 @@ public: const SequentialView& get_sequential_view() const { return m_sequential_view; } void update_sequential_view_current(unsigned int first, unsigned int last); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool is_contained_in_bed() const { return m_contained_in_bed; } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS EViewType get_view_type() const { return m_view_type; } void set_view_type(EViewType type) { diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 452173ae2..e52aec187 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2585,9 +2585,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) displacement = multiplier * direction; m_selection.translate(displacement); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_selection.stop_dragging(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_dirty = true; } ); @@ -2686,9 +2684,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) auto do_rotate = [this](double angle_z_rad) { m_selection.start_dragging(); m_selection.rotate(Vec3d(0.0, 0.0, angle_z_rad), TransformationType(TransformationType::World_Relative_Joint)); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_selection.stop_dragging(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_dirty = true; // wxGetApp().obj_manipul()->set_dirty(); }; @@ -3242,10 +3238,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } else if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) { -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS if (evt.LeftUp()) m_selection.stop_dragging(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS if (m_layers_editing.state != LayersEditing::Unknown) { m_layers_editing.state = LayersEditing::Unknown; @@ -6342,15 +6336,8 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning) show = _is_any_volume_outside(); else { if (wxGetApp().is_editor()) { -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS if (current_printer_technology() != ptSLA) show = m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed(); -#else - BoundingBoxf3 test_volume = (m_config != nullptr) ? print_volume(*m_config) : BoundingBoxf3(); - const BoundingBoxf3& paths_volume = m_gcode_viewer.get_paths_bounding_box(); - if (test_volume.radius() > 0.0 && paths_volume.radius() > 0.0) - show = !test_volume.contains(paths_volume); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS } } diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index ffcc4a6a0..4591da29f 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -479,9 +479,7 @@ private: const DynamicPrintConfig* m_config; Model* m_model; BackgroundSlicingProcess *m_process; -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool m_requires_check_outside_state{ false }; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS std::array m_old_size{ 0, 0 }; @@ -618,9 +616,7 @@ public: void post_event(wxEvent &&event); void set_as_dirty(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS void requires_check_outside_state() { m_requires_check_outside_state = true; } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS unsigned int get_volumes_count() const; const GLVolumeCollection& get_volumes() const { return m_volumes; } diff --git a/src/slic3r/GUI/GLShadersManager.cpp b/src/slic3r/GUI/GLShadersManager.cpp index 01407b09a..b67ee9b5d 100644 --- a/src/slic3r/GUI/GLShadersManager.cpp +++ b/src/slic3r/GUI/GLShadersManager.cpp @@ -61,12 +61,8 @@ std::pair GLShadersManager::init() // used to render extrusion and travel paths as lines in gcode preview valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" }); // used to render objects in 3d editor -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS // When setting this technology to default rename the following from "gouraud_mod" to "gouraud" valid &= append_shader("gouraud_mod", { "gouraud_mod.vs", "gouraud_mod.fs" } -#else - valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS #if ENABLE_ENVIRONMENT_MAP , { "ENABLE_ENVIRONMENT_MAP"sv } #endif // ENABLE_ENVIRONMENT_MAP diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index f5a274d69..201e5d78d 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -657,14 +657,10 @@ void ObjectManipulation::update_if_dirty() else m_og->disable(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS if (!selection.is_dragging()) { -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - update_reset_buttons_visibility(); - update_mirror_buttons_visibility(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS + update_reset_buttons_visibility(); + update_mirror_buttons_visibility(); } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_dirty = false; } @@ -820,9 +816,7 @@ void ObjectManipulation::change_position_value(int axis, double value) Selection& selection = canvas->get_selection(); selection.start_dragging(); selection.translate(position - m_cache.position, selection.requires_local_axes()); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS selection.stop_dragging(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS canvas->do_move(L("Set Position")); m_cache.position = position; @@ -854,9 +848,7 @@ void ObjectManipulation::change_rotation_value(int axis, double value) selection.rotate( (M_PI / 180.0) * (transformation_type.absolute() ? rotation : rotation - m_cache.rotation), transformation_type); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS selection.stop_dragging(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS canvas->do_rotate(L("Set Orientation")); m_cache.rotation = rotation; @@ -935,9 +927,7 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const selection.start_dragging(); selection.scale(scaling_factor, transformation_type); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS selection.stop_dragging(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS wxGetApp().plater()->canvas3D()->do_scale(L("Set Scale")); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 5ee0fddb1..b679bddb4 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -66,20 +66,12 @@ GLGizmoPainterBase::ClippingPlaneDataWrapper GLGizmoPainterBase::get_clipping_pl void GLGizmoPainterBase::render_triangles(const Selection& selection) const { -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS auto* shader = wxGetApp().get_shader("gouraud_mod"); -#else - auto* shader = wxGetApp().get_shader("gouraud"); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS if (! shader) return; shader->start_using(); shader->set_uniform("slope.actived", false); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS shader->set_uniform("print_volume.type", 0); -#else - shader->set_uniform("print_box.actived", false); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS shader->set_uniform("clipping_plane", this->get_clipping_plane_data().clp_dataf); ScopeGuard guard([shader]() { if (shader) shader->stop_using(); }); @@ -106,11 +98,7 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const // to the shader input variable print_box.volume_world_matrix before // rendering the painted triangles. When this matrix is not set, the // wrong transformation matrix is used for "Clipping of view". -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS shader->set_uniform("volume_world_matrix", trafo_matrix); -#else - shader->set_uniform("print_box.volume_world_matrix", trafo_matrix); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_triangle_selectors[mesh_id]->render(m_imgui); @@ -609,11 +597,7 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui) auto* shader = wxGetApp().get_current_shader(); if (! shader) return; -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS assert(shader->get_name() == "gouraud_mod"); -#else - assert(shader->get_name() == "gouraud"); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS ScopeGuard guard([shader]() { if (shader) shader->set_uniform("offset_depth_buffer", false);}); shader->set_uniform("offset_depth_buffer", true); for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color), diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 3104a8595..7eea8315f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -715,22 +715,18 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt) } else if (evt.LeftUp() && m_current == Flatten && m_gizmos[m_current]->get_hover_id() != -1) { // to avoid to loose the selection when user clicks an the white faces of a different object while the Flatten gizmo is active -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS selection.stop_dragging(); wxGetApp().obj_manipul()->set_dirty(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS processed = true; } else if (evt.RightUp() && (m_current == FdmSupports || m_current == Seam || m_current == MmuSegmentation) && !m_parent.is_mouse_dragging()) { gizmo_event(SLAGizmoEventType::RightUp, mouse_pos, evt.ShiftDown(), evt.AltDown(), control_down); processed = true; } -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS else if (evt.LeftUp()) { selection.stop_dragging(); wxGetApp().obj_manipul()->set_dirty(); } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS } else { // mouse inside toolbar diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index a6bcc0b38..c3313d434 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -112,9 +112,7 @@ Selection::Selection() , m_type(Empty) , m_valid(false) , m_scale_factor(1.0f) -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS , m_dragging(false) -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS { this->set_bounding_boxes_dirty(); } @@ -693,10 +691,7 @@ void Selection::start_dragging() if (!m_valid) return; -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS m_dragging = true; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - set_caches(); } @@ -737,9 +732,7 @@ void Selection::translate(const Vec3d& displacement, bool local) ensure_not_below_bed(); set_bounding_boxes_dirty(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS wxGetApp().plater()->canvas3D()->requires_check_outside_state(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS } // Rotate an object around one of the axes. Only one rotation component is expected to be changing. @@ -853,9 +846,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ } set_bounding_boxes_dirty(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS wxGetApp().plater()->canvas3D()->requires_check_outside_state(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS } void Selection::flattening_rotate(const Vec3d& normal) @@ -954,9 +945,7 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type ensure_on_bed(); set_bounding_boxes_dirty(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS wxGetApp().plater()->canvas3D()->requires_check_outside_state(); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS } void Selection::scale_to_fit_print_volume(const DynamicPrintConfig& config) diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index cb8f38d50..c81fa0510 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -219,10 +219,7 @@ private: GLModel m_curved_arrow; float m_scale_factor; - -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool m_dragging; -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS public: Selection(); @@ -316,10 +313,8 @@ public: const BoundingBoxf3& get_scaled_instance_bounding_box() const; void start_dragging(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS void stop_dragging() { m_dragging = false; } bool is_dragging() const { return m_dragging; } -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS void translate(const Vec3d& displacement, bool local = false); void rotate(const Vec3d& rotation, TransformationType transformation_type); From d6306f00b75b589fa7272ba584efad71eab74808 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 16 Nov 2021 10:39:20 +0100 Subject: [PATCH 2/6] Resin colors: Set default value when color wasn't set in config --- src/slic3r/GUI/3DScene.cpp | 5 ++++- src/slic3r/GUI/Plater.cpp | 4 ++-- src/slic3r/GUI/PresetComboBoxes.cpp | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index ca634c079..a96ea2d17 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -25,6 +25,7 @@ #include "libslic3r/PresetBundle.hpp" #include "libslic3r/ClipperUtils.hpp" #include "libslic3r/Tesselate.hpp" +#include "libslic3r/PrintConfig.hpp" #include #include @@ -1020,7 +1021,9 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con if (static_cast(config->opt_int("printer_technology")) == ptSLA) { - const std::string& txt_color = config->opt_string("material_colour"); + const std::string& txt_color = config->opt_string("material_colour").empty() ? + print_config_def.get("material_colour")->get_default_value()->value : + config->opt_string("material_colour"); if (Slic3r::GUI::BitmapCache::parse_color(txt_color, rgb)) { colors.resize(1); colors[0].set(txt_color, rgb); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index cea8b4fe3..bd8cc4d46 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -141,7 +141,7 @@ public: wxStaticText *info_size; wxStaticText *info_volume; wxStaticText *info_facets; - wxStaticText *info_materials; +// wxStaticText *info_materials; wxStaticText *info_manifold; wxStaticText *label_volume; @@ -199,7 +199,7 @@ ObjectInfo::ObjectInfo(wxWindow *parent) : sizer_manifold->Add(info_manifold, 0, wxLEFT, 2); Add(sizer_manifold, 0, wxEXPAND | wxTOP, 4); - sla_hidden_items = { label_volume, info_volume, /*label_materials, */info_materials }; + sla_hidden_items = { label_volume, info_volume, /*label_materials, info_materials*/ }; } void ObjectInfo::show_sizer(bool show) diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 33d8442a9..7b9c9846c 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -819,8 +819,11 @@ void PlaterPresetComboBox::update() bitmap_key += single_bar ? filament_rgb : filament_rgb + extruder_rgb; } - else if (m_type == Preset::TYPE_SLA_MATERIAL) + else if (m_type == Preset::TYPE_SLA_MATERIAL) { material_rgb = is_selected ? m_preset_bundle->sla_materials.get_edited_preset().config.opt_string("material_colour") : preset.config.opt_string("material_colour"); + if (material_rgb.empty()) + material_rgb = print_config_def.get("material_colour")->get_default_value()->value; + } wxBitmap* bmp = get_bmp(bitmap_key, wide_icons, bitmap_type_name, preset.is_compatible, preset.is_system || preset.is_default, From 9561fd8cc6d475e69e0b03f601ff36eb727c959e Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 16 Nov 2021 12:56:08 +0100 Subject: [PATCH 3/6] Removed obsolete gouraud shader files --- resources/shaders/gouraud.fs | 37 ++++++- resources/shaders/gouraud.vs | 49 +++------ resources/shaders/gouraud_mod.fs | 106 ------------------- resources/shaders/gouraud_mod.vs | 73 ------------- src/slic3r/GUI/GLCanvas3D.cpp | 2 +- src/slic3r/GUI/GLShadersManager.cpp | 3 +- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 4 +- 7 files changed, 50 insertions(+), 224 deletions(-) delete mode 100644 resources/shaders/gouraud_mod.fs delete mode 100644 resources/shaders/gouraud_mod.vs diff --git a/resources/shaders/gouraud.fs b/resources/shaders/gouraud.fs index b2c38e4a1..a1ba85b5c 100644 --- a/resources/shaders/gouraud.fs +++ b/resources/shaders/gouraud.fs @@ -22,6 +22,19 @@ const vec3 WHITE = vec3(1.0, 1.0, 1.0); const float EPSILON = 0.0001; const float BANDS_WIDTH = 10.0; +struct PrintVolumeDetection +{ + // 0 = rectangle, 1 = circle, 2 = custom, 3 = invalid + int type; + // type = 0 (rectangle): + // x = min.x, y = min.y, z = max.x, w = max.y + // type = 1 (circle): + // x = center.x, y = center.y, z = radius + vec4 xy_data; + // x = min z, y = max z + vec2 z_data; +}; + struct SlopeDetection { bool actived; @@ -44,11 +57,10 @@ varying vec3 clipping_planes_dots; // x = diffuse, y = specular; varying vec2 intensity; -varying vec3 delta_box_min; -varying vec3 delta_box_max; +uniform PrintVolumeDetection print_volume; varying vec4 model_pos; -varying float world_pos_z; +varying vec4 world_pos; varying float world_normal_z; varying vec3 eye_normal; @@ -63,15 +75,30 @@ void main() color = vec3(0.7, 0.7, 1.0); alpha = 1.0; } + // if the fragment is outside the print volume -> use darker color - color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(color, ZERO, 0.3333) : color; + vec3 pv_check_min = ZERO; + vec3 pv_check_max = ZERO; + if (print_volume.type == 0) { + // rectangle + pv_check_min = world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x); + pv_check_max = world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y); + } + else if (print_volume.type == 1) { + // circle + float delta_radius = print_volume.xy_data.z - distance(world_pos.xy, print_volume.xy_data.xy); + pv_check_min = vec3(delta_radius, 0.0, world_pos.z - print_volume.z_data.x); + pv_check_max = vec3(0.0, 0.0, world_pos.z - print_volume.z_data.y); + } + color = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color, ZERO, 0.3333) : color; + #ifdef ENABLE_ENVIRONMENT_MAP if (use_environment_tex) gl_FragColor = vec4(0.45 * texture2D(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, alpha); else #endif gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha); - + // In the support painting gizmo and the seam painting gizmo are painted triangles rendered over the already // rendered object. To resolved z-fighting between previously rendered object and painted triangles, values // inside the depth buffer are offset by small epsilon for painted triangles inside those gizmos. diff --git a/resources/shaders/gouraud.vs b/resources/shaders/gouraud.vs index d5e74b60b..79d7a63c0 100644 --- a/resources/shaders/gouraud.vs +++ b/resources/shaders/gouraud.vs @@ -18,14 +18,6 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); const vec3 ZERO = vec3(0.0, 0.0, 0.0); -struct PrintBoxDetection -{ - bool actived; - vec3 min; - vec3 max; - mat4 volume_world_matrix; -}; - struct SlopeDetection { bool actived; @@ -33,7 +25,7 @@ struct SlopeDetection mat3 volume_world_normal_matrix; }; -uniform PrintBoxDetection print_box; +uniform mat4 volume_world_matrix; uniform SlopeDetection slope; // Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane. @@ -44,46 +36,33 @@ uniform vec4 clipping_plane; // x = diffuse, y = specular; varying vec2 intensity; -varying vec3 delta_box_min; -varying vec3 delta_box_max; - varying vec3 clipping_planes_dots; varying vec4 model_pos; -varying float world_pos_z; +varying vec4 world_pos; varying float world_normal_z; varying vec3 eye_normal; void main() { - // First transform the normal into camera space and normalize the result. - eye_normal = normalize(gl_NormalMatrix * gl_Normal); + // First transform the normal into camera space and normalize the result. + eye_normal = normalize(gl_NormalMatrix * gl_Normal); - // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. - // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. - float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0); + // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. + // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. + float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0); - intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; - vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz; - intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS); + intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; + vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz; + intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS); - // Perform the same lighting calculation for the 2nd light source (no specular applied). - NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0); - intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; + // Perform the same lighting calculation for the 2nd light source (no specular applied). + NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0); + intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; model_pos = gl_Vertex; // Point in homogenous coordinates. - vec4 world_pos = print_box.volume_world_matrix * gl_Vertex; - world_pos_z = world_pos.z; - - // compute deltas for out of print volume detection (world coordinates) - if (print_box.actived) { - delta_box_min = world_pos.xyz - print_box.min; - delta_box_max = world_pos.xyz - print_box.max; - } else { - delta_box_min = ZERO; - delta_box_max = ZERO; - } + world_pos = volume_world_matrix * gl_Vertex; // z component of normal vector in world coordinate used for slope shading world_normal_z = slope.actived ? (normalize(slope.volume_world_normal_matrix * gl_Normal)).z : 0.0; diff --git a/resources/shaders/gouraud_mod.fs b/resources/shaders/gouraud_mod.fs deleted file mode 100644 index a1ba85b5c..000000000 --- a/resources/shaders/gouraud_mod.fs +++ /dev/null @@ -1,106 +0,0 @@ -#version 110 - -#define INTENSITY_CORRECTION 0.6 - -// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31) -const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); -#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SHININESS 20.0 - -// normalized values for (1./1.43, 0.2/1.43, 1./1.43) -const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); -#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) - -#define INTENSITY_AMBIENT 0.3 - -const vec3 ZERO = vec3(0.0, 0.0, 0.0); -const vec3 GREEN = vec3(0.0, 0.7, 0.0); -const vec3 YELLOW = vec3(0.5, 0.7, 0.0); -const vec3 RED = vec3(0.7, 0.0, 0.0); -const vec3 WHITE = vec3(1.0, 1.0, 1.0); -const float EPSILON = 0.0001; -const float BANDS_WIDTH = 10.0; - -struct PrintVolumeDetection -{ - // 0 = rectangle, 1 = circle, 2 = custom, 3 = invalid - int type; - // type = 0 (rectangle): - // x = min.x, y = min.y, z = max.x, w = max.y - // type = 1 (circle): - // x = center.x, y = center.y, z = radius - vec4 xy_data; - // x = min z, y = max z - vec2 z_data; -}; - -struct SlopeDetection -{ - bool actived; - float normal_z; - mat3 volume_world_normal_matrix; -}; - -uniform vec4 uniform_color; -uniform SlopeDetection slope; - -uniform bool offset_depth_buffer; - -#ifdef ENABLE_ENVIRONMENT_MAP - uniform sampler2D environment_tex; - uniform bool use_environment_tex; -#endif // ENABLE_ENVIRONMENT_MAP - -varying vec3 clipping_planes_dots; - -// x = diffuse, y = specular; -varying vec2 intensity; - -uniform PrintVolumeDetection print_volume; - -varying vec4 model_pos; -varying vec4 world_pos; -varying float world_normal_z; -varying vec3 eye_normal; - -void main() -{ - if (any(lessThan(clipping_planes_dots, ZERO))) - discard; - vec3 color = uniform_color.rgb; - float alpha = uniform_color.a; - - if (slope.actived && world_normal_z < slope.normal_z - EPSILON) { - color = vec3(0.7, 0.7, 1.0); - alpha = 1.0; - } - - // if the fragment is outside the print volume -> use darker color - vec3 pv_check_min = ZERO; - vec3 pv_check_max = ZERO; - if (print_volume.type == 0) { - // rectangle - pv_check_min = world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x); - pv_check_max = world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y); - } - else if (print_volume.type == 1) { - // circle - float delta_radius = print_volume.xy_data.z - distance(world_pos.xy, print_volume.xy_data.xy); - pv_check_min = vec3(delta_radius, 0.0, world_pos.z - print_volume.z_data.x); - pv_check_max = vec3(0.0, 0.0, world_pos.z - print_volume.z_data.y); - } - color = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color, ZERO, 0.3333) : color; - -#ifdef ENABLE_ENVIRONMENT_MAP - if (use_environment_tex) - gl_FragColor = vec4(0.45 * texture2D(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, alpha); - else -#endif - gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha); - - // In the support painting gizmo and the seam painting gizmo are painted triangles rendered over the already - // rendered object. To resolved z-fighting between previously rendered object and painted triangles, values - // inside the depth buffer are offset by small epsilon for painted triangles inside those gizmos. - gl_FragDepth = gl_FragCoord.z - (offset_depth_buffer ? EPSILON : 0.0); -} diff --git a/resources/shaders/gouraud_mod.vs b/resources/shaders/gouraud_mod.vs deleted file mode 100644 index 79d7a63c0..000000000 --- a/resources/shaders/gouraud_mod.vs +++ /dev/null @@ -1,73 +0,0 @@ -#version 110 - -#define INTENSITY_CORRECTION 0.6 - -// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31) -const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929); -#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION) -#define LIGHT_TOP_SHININESS 20.0 - -// normalized values for (1./1.43, 0.2/1.43, 1./1.43) -const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074); -#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION) -//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION) -//#define LIGHT_FRONT_SHININESS 5.0 - -#define INTENSITY_AMBIENT 0.3 - -const vec3 ZERO = vec3(0.0, 0.0, 0.0); - -struct SlopeDetection -{ - bool actived; - float normal_z; - mat3 volume_world_normal_matrix; -}; - -uniform mat4 volume_world_matrix; -uniform SlopeDetection slope; - -// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane. -uniform vec2 z_range; -// Clipping plane - general orientation. Used by the SLA gizmo. -uniform vec4 clipping_plane; - -// x = diffuse, y = specular; -varying vec2 intensity; - -varying vec3 clipping_planes_dots; - -varying vec4 model_pos; -varying vec4 world_pos; -varying float world_normal_z; -varying vec3 eye_normal; - -void main() -{ - // First transform the normal into camera space and normalize the result. - eye_normal = normalize(gl_NormalMatrix * gl_Normal); - - // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. - // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. - float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0); - - intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; - vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz; - intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS); - - // Perform the same lighting calculation for the 2nd light source (no specular applied). - NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0); - intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; - - model_pos = gl_Vertex; - // Point in homogenous coordinates. - world_pos = volume_world_matrix * gl_Vertex; - - // z component of normal vector in world coordinate used for slope shading - world_normal_z = slope.actived ? (normalize(slope.volume_world_normal_matrix * gl_Normal)).z : 0.0; - - gl_Position = ftransform(); - // Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded. - clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z); -} diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index e52aec187..b3afaf4d9 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5133,7 +5133,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type) m_volumes.set_clipping_plane(m_camera_clipping_plane.get_data()); m_volumes.set_show_sinking_contours(! m_gizmos.is_hiding_instances()); - GLShaderProgram* shader = wxGetApp().get_shader("gouraud_mod"); + GLShaderProgram* shader = wxGetApp().get_shader("gouraud"); if (shader != nullptr) { shader->start_using(); diff --git a/src/slic3r/GUI/GLShadersManager.cpp b/src/slic3r/GUI/GLShadersManager.cpp index b67ee9b5d..e1d66fa5d 100644 --- a/src/slic3r/GUI/GLShadersManager.cpp +++ b/src/slic3r/GUI/GLShadersManager.cpp @@ -61,8 +61,7 @@ std::pair GLShadersManager::init() // used to render extrusion and travel paths as lines in gcode preview valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" }); // used to render objects in 3d editor - // When setting this technology to default rename the following from "gouraud_mod" to "gouraud" - valid &= append_shader("gouraud_mod", { "gouraud_mod.vs", "gouraud_mod.fs" } + valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" } #if ENABLE_ENVIRONMENT_MAP , { "ENABLE_ENVIRONMENT_MAP"sv } #endif // ENABLE_ENVIRONMENT_MAP diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index b679bddb4..821ce367a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -66,7 +66,7 @@ GLGizmoPainterBase::ClippingPlaneDataWrapper GLGizmoPainterBase::get_clipping_pl void GLGizmoPainterBase::render_triangles(const Selection& selection) const { - auto* shader = wxGetApp().get_shader("gouraud_mod"); + auto* shader = wxGetApp().get_shader("gouraud"); if (! shader) return; shader->start_using(); @@ -597,7 +597,7 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui) auto* shader = wxGetApp().get_current_shader(); if (! shader) return; - assert(shader->get_name() == "gouraud_mod"); + assert(shader->get_name() == "gouraud"); ScopeGuard guard([shader]() { if (shader) shader->set_uniform("offset_depth_buffer", false);}); shader->set_uniform("offset_depth_buffer", true); for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color), From cb44542377a05526337d103ecabfac80de9cb15f Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 16 Nov 2021 13:40:24 +0100 Subject: [PATCH 4/6] Fix for broken zoom to bed command --- src/slic3r/GUI/GLCanvas3D.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index b3afaf4d9..8af4098d6 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1354,7 +1354,10 @@ void GLCanvas3D::allow_multisample(bool allow) void GLCanvas3D::zoom_to_bed() { - _zoom_to_box(m_bed.build_volume().bounding_volume()); + BoundingBoxf3 box = m_bed.build_volume().bounding_volume(); + box.min.z() = 0.0; + box.max.z() = 0.0; + _zoom_to_box(box); } void GLCanvas3D::zoom_to_volumes() From 1aaa4845c53e45070bc91038c1b349554b65ea72 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 16 Nov 2021 13:44:31 +0100 Subject: [PATCH 5/6] Partially ported https://github.com/supermerill/SuperSlicer/commit/ff195fc9(Add max_literal to setting def, to set the threshold for popup warning for float% fields) from @SuperSlicer (related to https://github.com/prusa3d/PrusaSlicer/issues/2829#issuecomment-955606863) --- src/libslic3r/Config.hpp | 2 ++ src/libslic3r/PrintConfig.cpp | 13 +++++++++++++ src/slic3r/GUI/Field.cpp | 3 +-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index dd121c90a..429f5901c 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -1764,6 +1764,8 @@ public: // By setting min=0, only nonnegative input is allowed. int min = INT_MIN; int max = INT_MAX; + // To check if it's not a typo and a % is missing + double max_literal = 1; ConfigOptionMode mode = comSimple; // Legacy names for this configuration option. // Used when parsing legacy configuration file. diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 5a14f8348..6315bdc52 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -374,6 +374,7 @@ void PrintConfigDef::init_fff_params() "Detour length could be specified either as an absolute value or as percentage (for example 50%) of a direct travel path."); def->sidetext = L("mm or % (zero to disable)"); def->min = 0; + def->max_literal = 1000; def->mode = comExpert; def->set_default_value(new ConfigOptionFloatOrPercent(0., false)); @@ -720,6 +721,7 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 200%), it will be computed over layer height."); def->sidetext = L("mm or %"); def->min = 0; + def->max_literal = 50; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); @@ -831,6 +833,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm or %"); def->min = 0; def->max = 1000; + def->max_literal = 50; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); @@ -1181,6 +1184,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm or %"); def->ratio_over = "first_layer_height"; def->min = 0; + def->max_literal = 50; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(200, true)); @@ -1200,6 +1204,7 @@ void PrintConfigDef::init_fff_params() "(for example: 40%) it will scale the default speeds."); def->sidetext = L("mm/s or %"); def->min = 0; + def->max_literal = 20; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(30, false)); @@ -1374,6 +1379,7 @@ void PrintConfigDef::init_fff_params() "Set this parameter to zero to disable anchoring perimeters connected to a single infill line."); def->sidetext = L("mm or %"); def->ratio_over = "infill_extrusion_width"; + def->max_literal = 1000; def->gui_type = ConfigOptionDef::GUIType::f_enum_open; def->enum_values.push_back("0"); def->enum_values.push_back("1"); @@ -1401,6 +1407,7 @@ void PrintConfigDef::init_fff_params() "Set this parameter to zero to disable anchoring."); def->sidetext = def_infill_anchor_min->sidetext; def->ratio_over = def_infill_anchor_min->ratio_over; + def->max_literal = def_infill_anchor_min->max_literal; def->gui_type = def_infill_anchor_min->gui_type; def->enum_values = def_infill_anchor_min->enum_values; def->enum_labels.push_back(L("0 (not anchored)")); @@ -1429,6 +1436,7 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 90%) it will be computed over layer height."); def->sidetext = L("mm or %"); def->min = 0; + def->max_literal = 50; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); @@ -1928,6 +1936,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm or %"); def->aliases = { "perimeters_extrusion_width" }; def->min = 0; + def->max_literal = 50; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); @@ -2300,6 +2309,7 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 90%) it will be computed over layer height."); def->sidetext = L("mm or %"); def->min = 0; + def->max_literal = 50; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); @@ -2474,6 +2484,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm or %"); def->ratio_over = "external_perimeter_extrusion_width"; def->min = 0; + def->max_literal = 10; def->mode = comAdvanced; // Default is half the external perimeter width. def->set_default_value(new ConfigOptionFloatOrPercent(50, true)); @@ -2560,6 +2571,7 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 90%) it will be computed over layer height."); def->sidetext = L("mm or %"); def->min = 0; + def->max_literal = 50; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); @@ -2793,6 +2805,7 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example 90%) it will be computed over layer height."); def->sidetext = L("mm or %"); def->min = 0; + def->max_literal = 50; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 0a5635630..f7ed84238 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -315,7 +315,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true set_value(double_to_string(val), true); } else if (((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) || - (m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1)) && + (m_opt.sidetext.rfind("mm ") != std::string::npos && val > /*1*/m_opt.max_literal)) && (m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast(m_value))) { if (!check_value) { @@ -330,7 +330,6 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true const wxString msg_text = from_u8((boost::format(_utf8(L("Do you mean %s%% instead of %s %s?\n" "Select YES if you want to change this value to %s%%, \n" "or NO if you are sure that %s %s is a correct value."))) % stVal % stVal % sidetext % stVal % stVal % sidetext).str()); -// wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")) + ": " + m_opt_id , wxICON_WARNING | wxYES | wxNO); WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES | wxNO); if ((!infill_anchors || val > 100) && dialog.ShowModal() == wxID_YES) { set_value(from_u8((boost::format("%s%%") % stVal).str()), false/*true*/); From 8d046a577ab218b2c84cc9cbcc50848da935181e Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 16 Nov 2021 14:52:07 +0100 Subject: [PATCH 6/6] Fixed wrong color of toolpaths in pre-gcode preview --- src/slic3r/GUI/GLCanvas3D.cpp | 53 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 8af4098d6..ee1db4802 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5095,36 +5095,35 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type) m_camera_clipping_plane = m_gizmos.get_clipping_plane(); - if (m_picking_enabled) { + if (m_picking_enabled) // Update the layer editing selection to the first object selected, update the current object maximum Z. m_layers_editing.select_object(*m_model, this->is_layers_editing_enabled() ? m_selection.get_object_idx() : -1); - if (const BuildVolume &build_volume = m_bed.build_volume(); build_volume.valid()) { - switch (build_volume.type()) { - case BuildVolume::Type::Rectangle: { - const BoundingBox3Base bed_bb = build_volume.bounding_volume().inflated(BuildVolume::SceneEpsilon); - m_volumes.set_print_volume({ 0, // circle - { float(bed_bb.min.x()), float(bed_bb.min.y()), float(bed_bb.max.x()), float(bed_bb.max.y()) }, - { 0.0f, float(build_volume.max_print_height()) } }); - break; - } - case BuildVolume::Type::Circle: { - m_volumes.set_print_volume({ 1, // rectangle - { unscaled(build_volume.circle().center.x()), unscaled(build_volume.circle().center.y()), unscaled(build_volume.circle().radius + BuildVolume::SceneEpsilon), 0.0f }, - { 0.0f, float(build_volume.max_print_height() + BuildVolume::SceneEpsilon) } }); - break; - } - default: - case BuildVolume::Type::Custom: { - m_volumes.set_print_volume({ static_cast(type), - { 0.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f } }); - } - } - if (m_requires_check_outside_state) { - m_volumes.check_outside_state(build_volume, nullptr); - m_requires_check_outside_state = false; - } + if (const BuildVolume &build_volume = m_bed.build_volume(); build_volume.valid()) { + switch (build_volume.type()) { + case BuildVolume::Type::Rectangle: { + const BoundingBox3Base bed_bb = build_volume.bounding_volume().inflated(BuildVolume::SceneEpsilon); + m_volumes.set_print_volume({ 0, // circle + { float(bed_bb.min.x()), float(bed_bb.min.y()), float(bed_bb.max.x()), float(bed_bb.max.y()) }, + { 0.0f, float(build_volume.max_print_height()) } }); + break; + } + case BuildVolume::Type::Circle: { + m_volumes.set_print_volume({ 1, // rectangle + { unscaled(build_volume.circle().center.x()), unscaled(build_volume.circle().center.y()), unscaled(build_volume.circle().radius + BuildVolume::SceneEpsilon), 0.0f }, + { 0.0f, float(build_volume.max_print_height() + BuildVolume::SceneEpsilon) } }); + break; + } + default: + case BuildVolume::Type::Custom: { + m_volumes.set_print_volume({ static_cast(type), + { 0.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f } }); + } + } + if (m_requires_check_outside_state) { + m_volumes.check_outside_state(build_volume, nullptr); + m_requires_check_outside_state = false; } }