From 58b5e75a9c1ea3ae28b1c1f767e0024cfb9bdf6b Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 4 Feb 2020 12:18:57 +0100 Subject: [PATCH] SlaSupports gizmo - show holes position even when user did not Preview the drilled mesh --- src/slic3r/GUI/Gizmos/GLGizmoBase.cpp | 2 ++ src/slic3r/GUI/Gizmos/GLGizmoBase.hpp | 3 +++ src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index af022352e..c237198a9 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -358,12 +358,14 @@ bool CommonGizmosData::update_from_backend(GLCanvas3D& canvas, ModelObject* mode m_backend_mesh_transformed = po->get_mesh_to_print(); m_backend_mesh_transformed.transform(canvas.sla_print()->sla_trafo(*m_model_object).inverse()); m_mesh = &m_backend_mesh_transformed; + m_has_drilled_mesh = true; } } if (! m_mesh) { m_mesh = &m_model_object->volumes.front()->mesh(); m_backend_mesh_transformed.clear(); + m_has_drilled_mesh = false; } m_model_object_id = m_model_object->id(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp index 5cd3d9d84..f3941b0a1 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp @@ -227,10 +227,13 @@ public: m_clipping_plane_distance = m_clipping_plane_distance_stash; } + bool has_drilled_mesh() const { return m_has_drilled_mesh; } + private: const TriangleMesh* m_old_mesh; TriangleMesh m_backend_mesh_transformed; float m_clipping_plane_distance_stash = 0.f; + bool m_has_drilled_mesh = false; }; } // namespace GUI diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 879a09da2..fd9b116a9 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -335,7 +335,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) } // Now render the drain holes: - /*if (! m_c->m_cavity_mesh) { + if (! m_c->has_drilled_mesh()) { render_color[0] = 0.7f; render_color[1] = 0.7f; render_color[2] = 0.7f; @@ -370,7 +370,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) glFrontFace(GL_CCW); glsafe(::glPopMatrix()); } - }*/ + } if (!picking) glsafe(::glDisable(GL_LIGHTING)); @@ -414,14 +414,14 @@ bool GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos, std::pairm_cavity_mesh) { + if (! m_c->has_drilled_mesh()) { for (const sla::DrainHole& hole : m_c->m_model_object->sla_drain_holes) { if (hole.is_inside(hit)) { in_hole = true; break; } } - }*/ + } if (! in_hole) { // Return both the point and the facet normal. pos_and_normal = std::make_pair(hit, normal);