From 535a27de65decbf0b16f85ff8004dc8935d86775 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 7 Apr 2020 15:55:54 +0200 Subject: [PATCH] Fixed crash related to ClippingPlane and incorrect handling of sla z shift in hollowing gizmo --- src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp | 8 ++++---- src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp | 4 ++-- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 4 ++-- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 13 +++++++++++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index 46c570c19..3c82806ca 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -223,7 +223,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons const Transform3d& instance_matrix = vol->get_instance_transformation().get_matrix(); glsafe(::glPushMatrix()); - glsafe(::glTranslated(0.0, 0.0, m_z_shift)); + glsafe(::glTranslated(0.0, 0.0, m_c->selection_info()->get_sla_shift())); glsafe(::glMultMatrixd(instance_matrix.data())); float render_color[4]; @@ -444,7 +444,7 @@ bool GLGizmoHollow::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_pos // First collect positions of all the points in world coordinates. Geometry::Transformation trafo = mo->instances[active_inst]->get_transformation(); - trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., m_z_shift)); + trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., m_c->selection_info()->get_sla_shift())); std::vector points; for (unsigned int i=0; isla_drain_holes.size(); ++i) points.push_back(trafo.get_matrix() * mo->sla_drain_holes[i].pos.cast()); @@ -607,7 +607,7 @@ GLGizmoHollow::get_config_options(const std::vector& keys) const return out; } - +/* ClippingPlane GLGizmoHollow::get_sla_clipping_plane() const { if (! m_c->selection_info()->model_object() @@ -619,7 +619,7 @@ ClippingPlane GLGizmoHollow::get_sla_clipping_plane() const return ClippingPlane(-clp.get_normal(), clp.get_data()[3]); } } - +*/ void GLGizmoHollow::on_render_input_window(float x, float y, float bottom_limit) { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp index 178579ba1..73d26b2da 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp @@ -22,7 +22,7 @@ enum class SLAGizmoEventType : unsigned char; class GLGizmoHollow : public GLGizmoBase { private: - mutable double m_z_shift = 0.; + //mutable double m_z_shift = 0.; bool unproject_on_mesh(const Vec2d& mouse_pos, std::pair& pos_and_normal); GLUquadricObj* m_quadric; @@ -34,7 +34,7 @@ public: void set_sla_support_data(ModelObject* model_object, const Selection& selection); bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down); void delete_selected_points(); - ClippingPlane get_sla_clipping_plane() const; + //ClippingPlane get_sla_clipping_plane() const; bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); } //void set_common_data_ptr(CommonGizmosData* ptr) { m_c = ptr; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index ac65d9313..16ac6ec3c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -691,7 +691,7 @@ std::vector GLGizmoSlaSupports::get_config_options(const st return out; } - +/* ClippingPlane GLGizmoSlaSupports::get_sla_clipping_plane() const { //if (!m_c->m_model_object || m_state == Off || m_c->m_clipping_plane_distance == 0.f) @@ -707,7 +707,7 @@ ClippingPlane GLGizmoSlaSupports::get_sla_clipping_plane() const return ClippingPlane(-clp.get_normal(), clp.get_data()[3]); } } - +*/ /* void GLGizmoSlaSupports::find_intersecting_facets(const igl::AABB* aabb, const Vec3f& normal, double offset, std::vector& idxs) const diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index 81b347204..2b7b1ae78 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -75,7 +75,7 @@ public: void set_sla_support_data(ModelObject* model_object, const Selection& selection); bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down); void delete_selected_points(bool force = false); - ClippingPlane get_sla_clipping_plane() const; + //ClippingPlane get_sla_clipping_plane() const; bool is_in_editing_mode() const { return m_editing_mode; } bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 884d63b4c..61d0bd5f4 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -395,13 +395,22 @@ bool GLGizmosManager::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_p ClippingPlane GLGizmosManager::get_sla_clipping_plane() const { - if (!m_enabled || (m_current != SlaSupports && m_current != Hollow) || m_gizmos.empty()) + if (! m_common_gizmos_data->object_clipper() + || m_common_gizmos_data->object_clipper()->get_position() == 0.) + return ClippingPlane::ClipsNothing(); + else { + const ClippingPlane& clp = *m_common_gizmos_data->object_clipper()->get_clipping_plane(); + return ClippingPlane(-clp.get_normal(), clp.get_data()[3]); + } + + + /*if (!m_enabled || (m_current != SlaSupports && m_current != Hollow) || m_gizmos.empty()) return ClippingPlane::ClipsNothing(); if (m_current == SlaSupports) return dynamic_cast(m_gizmos[SlaSupports].get())->get_sla_clipping_plane(); else - return dynamic_cast(m_gizmos[Hollow].get())->get_sla_clipping_plane(); + return dynamic_cast(m_gizmos[Hollow].get())->get_sla_clipping_plane();*/ } bool GLGizmosManager::wants_reslice_supports_on_undo() const