diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index 1e12674ec..a1e95cfc5 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -231,13 +231,7 @@ std::array GLGizmoBase::picking_color_component(unsigned int id) const void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const { - float size = (float)box.max_size(); - - for (int i = 0; i < (int)m_grabbers.size(); ++i) - { - if (m_grabbers[i].enabled) - m_grabbers[i].render((m_hover_id == i), size); - } + render_grabbers((float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0)); } void GLGizmoBase::render_grabbers(float size) const @@ -251,7 +245,7 @@ void GLGizmoBase::render_grabbers(float size) const void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const { - float size = (float)box.max_size(); + float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0); for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i) { @@ -261,7 +255,7 @@ void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const m_grabbers[i].color[0] = color[0]; m_grabbers[i].color[1] = color[1]; m_grabbers[i].color[2] = color[2]; - m_grabbers[i].render_for_picking(size); + m_grabbers[i].render_for_picking(mean_size); } } } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index e228706c0..566090504 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -173,7 +173,7 @@ void GLGizmoCut::on_render(const Selection& selection) const ::glEnd(); std::copy(std::begin(GrabberColor), std::end(GrabberColor), m_grabbers[0].color); - m_grabbers[0].render(m_hover_id == 0, box.max_size()); + m_grabbers[0].render(m_hover_id == 0, (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0)); } void GLGizmoCut::on_render_for_picking(const Selection& selection) const diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp index 03151c433..61f219dbf 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp @@ -216,7 +216,8 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box if (m_quadric == nullptr) return; - double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[axis].get_half_size((float)box.max_size()); + float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0); + double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size(mean_size) : (double)m_grabbers[axis].get_half_size(mean_size); float color[3]; ::memcpy((void*)color, (const void*)m_grabbers[axis].color, 3 * sizeof(float)); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp index 72b9ad18a..e05ad00fe 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp @@ -307,7 +307,8 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick if (m_quadric == nullptr) return; - double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[0].get_half_size((float)box.max_size()); + float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0); + double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size(mean_size) : (double)m_grabbers[0].get_half_size(mean_size); float color[3]; ::memcpy((void*)color, (const void*)m_grabbers[0].color, 3 * sizeof(float)); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp index 43152b56c..e9f7e2ae2 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp @@ -116,8 +116,6 @@ void GLGizmoScale3D::on_render(const Selection& selection) const Vec3d angles = Vec3d::Zero(); Transform3d offsets_transform = Transform3d::Identity(); - Vec3d grabber_size = Vec3d::Zero(); - if (single_instance) { // calculate bounding box in instance local reference system @@ -135,7 +133,6 @@ void GLGizmoScale3D::on_render(const Selection& selection) const angles = v->get_instance_rotation(); // consider rotation+mirror only components of the transform for offsets offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror()); - grabber_size = v->get_instance_transformation().get_matrix(true, true, false, true) * box.size(); } else if (single_volume) { @@ -145,13 +142,9 @@ void GLGizmoScale3D::on_render(const Selection& selection) const angles = Geometry::extract_euler_angles(transform); // consider rotation+mirror only components of the transform for offsets offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror()); - grabber_size = v->get_volume_transformation().get_matrix(true, true, false, true) * box.size(); } else - { box = selection.get_bounding_box(); - grabber_size = box.size(); - } m_box = box; @@ -196,7 +189,9 @@ void GLGizmoScale3D::on_render(const Selection& selection) const ::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f); - float grabber_mean_size = (float)(grabber_size(0) + grabber_size(1) + grabber_size(2)) / 3.0f; + const BoundingBoxf3& selection_box = selection.get_bounding_box(); + + float grabber_mean_size = (float)((selection_box.size()(0) + selection_box.size()(1) + selection_box.size()(2)) / 3.0); if (m_hover_id == -1) {