Tech ENABLE_RAYCAST_PICKING - Removal of all remaining code related to old OpenGL based picking

This commit is contained in:
enricoturri1966 2022-06-21 09:16:36 +02:00
parent 255d8657dd
commit 6d97de14d9
10 changed files with 25 additions and 9 deletions

View File

@ -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) { 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 }; } 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) ColorRGBA picking_decode(unsigned int id)
{ {
return { return {
@ -403,6 +404,7 @@ unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char gr
b ^= 0x55; b ^= 0x55;
return b; return b;
} }
#endif // !ENABLE_RAYCAST_PICKING
} // namespace Slic3r } // namespace Slic3r

View File

@ -181,11 +181,13 @@ inline Vec3i value_to_rgbi(float minimum, float maximum, float value)
return (value_to_rgbf(minimum, maximum, value) * 255).cast<int>(); return (value_to_rgbf(minimum, maximum, value) * 255).cast<int>();
} }
#if !ENABLE_RAYCAST_PICKING
ColorRGBA picking_decode(unsigned int id); ColorRGBA picking_decode(unsigned int id);
unsigned int picking_encode(unsigned char r, unsigned char g, unsigned char b); 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 // 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. // were not interpolated by alpha blending or multi sampling.
unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue); unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue);
#endif // !ENABLE_RAYCAST_PICKING
} // namespace Slic3r } // namespace Slic3r

View File

@ -1717,7 +1717,7 @@ void GLCanvas3D::render()
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_RAYCAST_PICKING_DEBUG #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); m_scene_raycaster.render_hit(camera);
#endif // ENABLE_RAYCAST_PICKING_DEBUG #endif // ENABLE_RAYCAST_PICKING_DEBUG
@ -5603,6 +5603,11 @@ void GLCanvas3D::_picking_pass()
} }
#endif // ENABLE_RAYCAST_PICKING #endif // ENABLE_RAYCAST_PICKING
#if ENABLE_RAYCAST_PICKING
void GLCanvas3D::_rectangular_selection_picking_pass()
{
}
#else
void GLCanvas3D::_rectangular_selection_picking_pass() void GLCanvas3D::_rectangular_selection_picking_pass()
{ {
m_gizmos.set_hover_id(-1); m_gizmos.set_hover_id(-1);
@ -5621,10 +5626,8 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
_render_volumes_for_picking(); _render_volumes_for_picking();
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if !ENABLE_RAYCAST_PICKING
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
_render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward()); _render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward());
#endif // !ENABLE_RAYCAST_PICKING
#else #else
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward()); _render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -5686,6 +5689,7 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
m_hover_volume_idxs.assign(idxs.begin(), idxs.end()); m_hover_volume_idxs.assign(idxs.begin(), idxs.end());
_update_volumes_hover_state(); _update_volumes_hover_state();
} }
#endif // ENABLE_RAYCAST_PICKING
void GLCanvas3D::_render_background() void GLCanvas3D::_render_background()
{ {
@ -6085,6 +6089,7 @@ void GLCanvas3D::_render_overlays()
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL #endif // !ENABLE_LEGACY_OPENGL_REMOVAL
} }
#if !ENABLE_RAYCAST_PICKING
void GLCanvas3D::_render_volumes_for_picking() const void GLCanvas3D::_render_volumes_for_picking() const
{ {
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
@ -6136,6 +6141,7 @@ void GLCanvas3D::_render_volumes_for_picking() const
glsafe(::glEnable(GL_CULL_FACE)); glsafe(::glEnable(GL_CULL_FACE));
} }
#endif // !ENABLE_RAYCAST_PICKING
void GLCanvas3D::_render_current_gizmo() const void GLCanvas3D::_render_current_gizmo() const
{ {

View File

@ -999,7 +999,9 @@ private:
#endif // ENABLE_RENDER_SELECTION_CENTER #endif // ENABLE_RENDER_SELECTION_CENTER
void _check_and_update_toolbar_icon_scale(); void _check_and_update_toolbar_icon_scale();
void _render_overlays(); void _render_overlays();
#if !ENABLE_RAYCAST_PICKING
void _render_volumes_for_picking() const; void _render_volumes_for_picking() const;
#endif // !ENABLE_RAYCAST_PICKING
void _render_current_gizmo() const; void _render_current_gizmo() const;
void _render_gizmos_overlay(); void _render_gizmos_overlay();
void _render_main_toolbar(); void _render_main_toolbar();

View File

@ -42,8 +42,10 @@ std::pair<bool, std::string> GLShadersManager::init()
valid &= append_shader("imgui", { prefix + "imgui.vs", prefix + "imgui.fs" }); valid &= append_shader("imgui", { prefix + "imgui.vs", prefix + "imgui.fs" });
// basic shader, used to render all what was previously rendered using the immediate mode // basic shader, used to render all what was previously rendered using the immediate mode
valid &= append_shader("flat", { prefix + "flat.vs", prefix + "flat.fs" }); 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 // 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" }); 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 // basic shader for textures, used to render textures
valid &= append_shader("flat_texture", { prefix + "flat_texture.vs", prefix + "flat_texture.fs" }); valid &= append_shader("flat_texture", { prefix + "flat_texture.vs", prefix + "flat_texture.fs" });
// used to render 3D scene background // used to render 3D scene background

View File

@ -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->set_context(wxGetApp().init_glcontext(*m_canvas_widget));
m_canvas->allow_multisample(OpenGLManager::can_multisample()); m_canvas->allow_multisample(OpenGLManager::can_multisample());
// XXX: If have OpenGL
m_canvas->enable_picking(true); m_canvas->enable_picking(true);
m_canvas->enable_moving(true); m_canvas->enable_moving(true);
// XXX: more config from 3D.pm // XXX: more config from 3D.pm

View File

@ -338,8 +338,7 @@ void GLGizmoBase::unregister_grabbers_for_picking()
m_grabbers[i].unregister_raycasters_for_picking(); m_grabbers[i].unregister_raycasters_for_picking();
} }
} }
#endif // ENABLE_RAYCAST_PICKING #else
ColorRGBA GLGizmoBase::picking_color_component(unsigned int id) const ColorRGBA GLGizmoBase::picking_color_component(unsigned int id) const
{ {
id = BASE_ID - id; id = BASE_ID - id;
@ -348,6 +347,7 @@ ColorRGBA GLGizmoBase::picking_color_component(unsigned int id) const
return picking_decode(id); return picking_decode(id);
} }
#endif // ENABLE_RAYCAST_PICKING
void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
{ {

View File

@ -241,11 +241,11 @@ protected:
void unregister_grabbers_for_picking(); void unregister_grabbers_for_picking();
virtual void on_register_raycasters_for_picking() {} virtual void on_register_raycasters_for_picking() {}
virtual void on_unregister_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 // 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) // No check is made for clashing with other picking color (i.e. GLVolumes)
ColorRGBA picking_color_component(unsigned int id) const; ColorRGBA picking_color_component(unsigned int id) const;
#endif // ENABLE_RAYCAST_PICKING
void render_grabbers(const BoundingBoxf3& box) const; void render_grabbers(const BoundingBoxf3& box) const;
void render_grabbers(float size) const; void render_grabbers(float size) const;

View File

@ -214,7 +214,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking)
m_c->hollowed_mesh()->get_drainholes()[i].failed) { m_c->hollowed_mesh()->get_drainholes()[i].failed) {
render_color = { 1.0f, 0.0f, 0.0f, 0.5f }; 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); 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 #if !ENABLE_RAYCAST_PICKING
} }

View File

@ -20,6 +20,7 @@ SCENARIO("Color encoding/decoding cycle", "[Color]") {
} }
} }
#if !ENABLE_RAYCAST_PICKING
SCENARIO("Color picking encoding/decoding cycle", "[Color]") { SCENARIO("Color picking encoding/decoding cycle", "[Color]") {
GIVEN("Picking color") { GIVEN("Picking color") {
const ColorRGB src_rgb(static_cast<unsigned char>(255), static_cast<unsigned char>(127), static_cast<unsigned char>(63)); const ColorRGB src_rgb(static_cast<unsigned char>(255), static_cast<unsigned char>(127), static_cast<unsigned char>(63));
@ -33,5 +34,6 @@ SCENARIO("Color picking encoding/decoding cycle", "[Color]") {
} }
} }
} }
#endif // !ENABLE_RAYCAST_PICKING