diff options
author | Lukas Matena <lukasmatena@seznam.cz> | 2020-02-20 17:01:00 +0300 |
---|---|---|
committer | Lukas Matena <lukasmatena@seznam.cz> | 2020-02-20 17:04:53 +0300 |
commit | 90a8076d25626a05a94abdb8409ca09493079e54 (patch) | |
tree | b9248553bb150691b6c23915852f3251b70444d5 /src/slic3r/GUI | |
parent | 5e4a0b96b791f4ed72ae84b5f672a11ac174b12e (diff) |
SLA support gizmo correctly hides drain holes if they are clipped by clipping plane
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoBase.hpp | 2 | ||||
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp | 16 | ||||
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp | 2 | ||||
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 3 |
4 files changed, 13 insertions, 10 deletions
diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp index f3941b0a1..11185a83d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp @@ -198,6 +198,8 @@ public: bool recent_update = false; + static constexpr float HoleStickOutLength = 1.f; + ModelObject* m_model_object = nullptr; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index 31dd919a7..408164aa8 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -242,7 +242,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons const sla::DrainHole& drain_hole = m_c->m_model_object->sla_drain_holes[i]; const bool& point_selected = m_selected[i]; - if (is_mesh_point_clipped((drain_hole.pos+HoleStickOutLength*drain_hole.normal).cast<double>())) + if (is_mesh_point_clipped((drain_hole.pos+m_c->HoleStickOutLength*drain_hole.normal).cast<double>())) continue; // First decide about the color of the point. @@ -417,8 +417,8 @@ bool GLGizmoHollow::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_pos pos_and_normal.second(1)/scaling(1), pos_and_normal.second(2)/scaling(2)); - m_c->m_model_object->sla_drain_holes.emplace_back(pos_and_normal.first + HoleStickOutLength * pos_and_normal.second/* normal_transformed.normalized()*/, - -pos_and_normal.second, m_new_hole_radius, m_new_hole_height+HoleStickOutLength); + m_c->m_model_object->sla_drain_holes.emplace_back(pos_and_normal.first + m_c->HoleStickOutLength * pos_and_normal.second/* normal_transformed.normalized()*/, + -pos_and_normal.second, m_new_hole_radius, m_new_hole_height+m_c->HoleStickOutLength); m_selected.push_back(false); assert(m_selected.size() == m_c->m_model_object->sla_drain_holes.size()); m_parent.set_as_dirty(); @@ -545,7 +545,7 @@ void GLGizmoHollow::on_update(const UpdateData& data) std::pair<Vec3f, Vec3f> pos_and_normal; if (! unproject_on_mesh(data.mouse_pos.cast<double>(), pos_and_normal)) return; - m_c->m_model_object->sla_drain_holes[m_hover_id].pos = pos_and_normal.first + HoleStickOutLength * pos_and_normal.second; + m_c->m_model_object->sla_drain_holes[m_hover_id].pos = pos_and_normal.first + m_c->HoleStickOutLength * pos_and_normal.second; m_c->m_model_object->sla_drain_holes[m_hover_id].normal = -pos_and_normal.second; } } @@ -831,9 +831,9 @@ RENDER_AGAIN: m_imgui->text(m_desc["hole_depth"]); ImGui::SameLine(diameter_slider_left); - m_new_hole_height -= HoleStickOutLength; + m_new_hole_height -= m_c->HoleStickOutLength; ImGui::SliderFloat(" ", &m_new_hole_height, 0.f, 10.f, "%.1f"); - m_new_hole_height += HoleStickOutLength; + m_new_hole_height += m_c->HoleStickOutLength; clicked |= ImGui::IsItemClicked(); edited |= ImGui::IsItemEdited(); @@ -1082,7 +1082,7 @@ void GLGizmoHollow::select_point(int i) if (i == AllPoints) { m_new_hole_radius = m_c->m_model_object->sla_drain_holes[0].radius; - m_new_hole_height = m_c->m_model_object->sla_drain_holes[0].height - HoleStickOutLength; + m_new_hole_height = m_c->m_model_object->sla_drain_holes[0].height - m_c->HoleStickOutLength; } } else { @@ -1091,7 +1091,7 @@ void GLGizmoHollow::select_point(int i) m_selected[i] = true; m_selection_empty = false; m_new_hole_radius = m_c->m_model_object->sla_drain_holes[i].radius; - m_new_hole_height = m_c->m_model_object->sla_drain_holes[i].height - HoleStickOutLength; + m_new_hole_height = m_c->m_model_object->sla_drain_holes[i].height - m_c->HoleStickOutLength; } } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp index 2daf28b2a..f3650c94d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp @@ -24,8 +24,6 @@ private: mutable double m_z_shift = 0.; bool unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec3f, Vec3f>& pos_and_normal); - const float HoleStickOutLength = 1.f; - GLUquadricObj* m_quadric; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 05f33ae52..759cda35c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -342,6 +342,9 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) render_color[3] = 0.7f; glsafe(::glColor4fv(render_color)); for (const sla::DrainHole& drain_hole : m_c->m_model_object->sla_drain_holes) { + if (is_mesh_point_clipped((drain_hole.pos+m_c->HoleStickOutLength*drain_hole.normal).cast<double>())) + continue; + // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. glsafe(::glPushMatrix()); glsafe(::glTranslatef(drain_hole.pos(0), drain_hole.pos(1), drain_hole.pos(2))); |