diff --git a/src/libslic3r/Color.cpp b/src/libslic3r/Color.cpp index 4d3bc6793..3efd4c813 100644 --- a/src/libslic3r/Color.cpp +++ b/src/libslic3r/Color.cpp @@ -379,6 +379,7 @@ ColorRGB to_rgb(const ColorRGBA& other_rgba) { return { other_rgba.r(), other_rg ColorRGBA to_rgba(const ColorRGB& other_rgb) { return { other_rgb.r(), other_rgb.g(), other_rgb.b(), 1.0f }; } ColorRGBA to_rgba(const ColorRGB& other_rgb, float alpha) { return { other_rgb.r(), other_rgb.g(), other_rgb.b(), alpha }; } +#if !ENABLE_RAYCAST_PICKING ColorRGBA picking_decode(unsigned int id) { return { @@ -403,6 +404,7 @@ unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char gr b ^= 0x55; return b; } +#endif // !ENABLE_RAYCAST_PICKING } // namespace Slic3r diff --git a/src/libslic3r/Color.hpp b/src/libslic3r/Color.hpp index 8044a0318..4a1c6a343 100644 --- a/src/libslic3r/Color.hpp +++ b/src/libslic3r/Color.hpp @@ -181,11 +181,13 @@ inline Vec3i value_to_rgbi(float minimum, float maximum, float value) return (value_to_rgbf(minimum, maximum, value) * 255).cast(); } +#if !ENABLE_RAYCAST_PICKING ColorRGBA picking_decode(unsigned int id); unsigned int picking_encode(unsigned char r, unsigned char g, unsigned char b); // Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components // were not interpolated by alpha blending or multi sampling. unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue); +#endif // !ENABLE_RAYCAST_PICKING } // namespace Slic3r diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index cb5e47d72..e34dc1319 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1717,7 +1717,7 @@ void GLCanvas3D::render() #endif // ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_RAYCAST_PICKING_DEBUG - if (m_picking_enabled && !m_mouse.dragging) + if (m_picking_enabled && !m_mouse.dragging && !m_gizmos.is_dragging()) m_scene_raycaster.render_hit(camera); #endif // ENABLE_RAYCAST_PICKING_DEBUG @@ -5603,6 +5603,11 @@ void GLCanvas3D::_picking_pass() } #endif // ENABLE_RAYCAST_PICKING +#if ENABLE_RAYCAST_PICKING +void GLCanvas3D::_rectangular_selection_picking_pass() +{ +} +#else void GLCanvas3D::_rectangular_selection_picking_pass() { m_gizmos.set_hover_id(-1); @@ -5621,10 +5626,8 @@ void GLCanvas3D::_rectangular_selection_picking_pass() _render_volumes_for_picking(); #if ENABLE_LEGACY_OPENGL_REMOVAL -#if !ENABLE_RAYCAST_PICKING const Camera& camera = wxGetApp().plater()->get_camera(); _render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward()); -#endif // !ENABLE_RAYCAST_PICKING #else _render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward()); #endif // ENABLE_LEGACY_OPENGL_REMOVAL @@ -5686,6 +5689,7 @@ void GLCanvas3D::_rectangular_selection_picking_pass() m_hover_volume_idxs.assign(idxs.begin(), idxs.end()); _update_volumes_hover_state(); } +#endif // ENABLE_RAYCAST_PICKING void GLCanvas3D::_render_background() { @@ -6085,6 +6089,7 @@ void GLCanvas3D::_render_overlays() #endif // !ENABLE_LEGACY_OPENGL_REMOVAL } +#if !ENABLE_RAYCAST_PICKING void GLCanvas3D::_render_volumes_for_picking() const { #if ENABLE_LEGACY_OPENGL_REMOVAL @@ -6136,6 +6141,7 @@ void GLCanvas3D::_render_volumes_for_picking() const glsafe(::glEnable(GL_CULL_FACE)); } +#endif // !ENABLE_RAYCAST_PICKING void GLCanvas3D::_render_current_gizmo() const { diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 62c823e62..629cc656d 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -999,7 +999,9 @@ private: #endif // ENABLE_RENDER_SELECTION_CENTER void _check_and_update_toolbar_icon_scale(); void _render_overlays(); +#if !ENABLE_RAYCAST_PICKING void _render_volumes_for_picking() const; +#endif // !ENABLE_RAYCAST_PICKING void _render_current_gizmo() const; void _render_gizmos_overlay(); void _render_main_toolbar(); diff --git a/src/slic3r/GUI/GLShadersManager.cpp b/src/slic3r/GUI/GLShadersManager.cpp index 0668ecec8..f2e0f6d1d 100644 --- a/src/slic3r/GUI/GLShadersManager.cpp +++ b/src/slic3r/GUI/GLShadersManager.cpp @@ -42,8 +42,10 @@ std::pair GLShadersManager::init() valid &= append_shader("imgui", { prefix + "imgui.vs", prefix + "imgui.fs" }); // basic shader, used to render all what was previously rendered using the immediate mode valid &= append_shader("flat", { prefix + "flat.vs", prefix + "flat.fs" }); +#if !ENABLE_RAYCAST_PICKING // basic shader with plane clipping, used to render volumes in picking pass valid &= append_shader("flat_clip", { prefix + "flat_clip.vs", prefix + "flat_clip.fs" }); +#endif // !ENABLE_RAYCAST_PICKING // basic shader for textures, used to render textures valid &= append_shader("flat_texture", { prefix + "flat_texture.vs", prefix + "flat_texture.fs" }); // used to render 3D scene background diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 88bd42a66..7ee4e7955 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -63,7 +63,7 @@ bool View3D::init(wxWindow* parent, Bed3D& bed, Model* model, DynamicPrintConfig m_canvas->set_context(wxGetApp().init_glcontext(*m_canvas_widget)); m_canvas->allow_multisample(OpenGLManager::can_multisample()); - // XXX: If have OpenGL + m_canvas->enable_picking(true); m_canvas->enable_moving(true); // XXX: more config from 3D.pm diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index 36603b692..a5c10b0a5 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -338,8 +338,7 @@ void GLGizmoBase::unregister_grabbers_for_picking() m_grabbers[i].unregister_raycasters_for_picking(); } } -#endif // ENABLE_RAYCAST_PICKING - +#else ColorRGBA GLGizmoBase::picking_color_component(unsigned int id) const { id = BASE_ID - id; @@ -348,6 +347,7 @@ ColorRGBA GLGizmoBase::picking_color_component(unsigned int id) const return picking_decode(id); } +#endif // ENABLE_RAYCAST_PICKING void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp index 4001dd190..09766bbac 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp @@ -241,11 +241,11 @@ protected: void unregister_grabbers_for_picking(); virtual void on_register_raycasters_for_picking() {} virtual void on_unregister_raycasters_for_picking() {} -#endif // ENABLE_RAYCAST_PICKING - +#else // Returns the picking color for the given id, based on the BASE_ID constant // No check is made for clashing with other picking color (i.e. GLVolumes) ColorRGBA picking_color_component(unsigned int id) const; +#endif // ENABLE_RAYCAST_PICKING void render_grabbers(const BoundingBoxf3& box) const; void render_grabbers(float size) const; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index 5f5ee9f92..a5b9e587a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -214,7 +214,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) m_c->hollowed_mesh()->get_drainholes()[i].failed) { render_color = { 1.0f, 0.0f, 0.0f, 0.5f }; } - else // neither hover nor picking + else render_color = point_selected ? ColorRGBA(1.0f, 0.3f, 0.3f, 0.5f) : ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f); #if !ENABLE_RAYCAST_PICKING } diff --git a/tests/libslic3r/test_color.cpp b/tests/libslic3r/test_color.cpp index c74e5642d..632691669 100644 --- a/tests/libslic3r/test_color.cpp +++ b/tests/libslic3r/test_color.cpp @@ -20,6 +20,7 @@ SCENARIO("Color encoding/decoding cycle", "[Color]") { } } +#if !ENABLE_RAYCAST_PICKING SCENARIO("Color picking encoding/decoding cycle", "[Color]") { GIVEN("Picking color") { const ColorRGB src_rgb(static_cast(255), static_cast(127), static_cast(63)); @@ -33,5 +34,6 @@ SCENARIO("Color picking encoding/decoding cycle", "[Color]") { } } } +#endif // !ENABLE_RAYCAST_PICKING