From 04e92cb409c1098d44851c8cf912834f4eeb0726 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 9 May 2023 11:14:50 +0200 Subject: [PATCH] SPE-1439 - Fixed move gizmo orientation when the volume is mirrored --- src/slic3r/GUI/Gizmos/GLGizmoMove.cpp | 22 ++++++---------------- src/slic3r/GUI/Selection.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp index 556d5b61e..d3538a7c0 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp @@ -67,23 +67,10 @@ bool GLGizmoMove3D::on_is_activable() const void GLGizmoMove3D::on_start_dragging() { assert(m_hover_id != -1); - m_displacement = Vec3d::Zero(); - const Selection& selection = m_parent.get_selection(); - const ECoordinatesType coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type(); - if (coordinates_type == ECoordinatesType::World) - m_starting_drag_position = m_center + m_grabbers[m_hover_id].center; - else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) { - const GLVolume& v = *selection.get_first_volume(); - m_starting_drag_position = m_center + v.get_instance_transformation().get_rotation_matrix() * v.get_volume_transformation().get_rotation_matrix() * m_grabbers[m_hover_id].center; - } - else { - const GLVolume& v = *selection.get_first_volume(); - m_starting_drag_position = m_center + v.get_instance_transformation().get_rotation_matrix() * m_grabbers[m_hover_id].center; - } + m_starting_drag_position = m_grabbers[m_hover_id].matrix * m_grabbers[m_hover_id].center; m_starting_box_center = m_center; - m_starting_box_bottom_center = m_center; - m_starting_box_bottom_center.z() = m_bounding_box.min.z(); + m_starting_box_bottom_center = Vec3d(m_center.x(), m_center.y(), m_bounding_box.min.z()); } void GLGizmoMove3D::on_stop_dragging() @@ -122,7 +109,8 @@ void GLGizmoMove3D::on_render() const auto& [box, box_trafo] = selection.get_bounding_box_in_current_reference_system(); m_bounding_box = box; m_center = box_trafo.translation(); - const Transform3d base_matrix = local_transform(m_parent.get_selection()); + const Transform3d base_matrix = box_trafo; + for (int i = 0; i < 3; ++i) { m_grabbers[i].matrix = base_matrix; } @@ -230,10 +218,12 @@ void GLGizmoMove3D::on_render() if (shader != nullptr) { shader->start_using(); shader->set_uniform("emission_factor", 0.1f); + glsafe(::glDisable(GL_CULL_FACE)); // draw grabber const Vec3d box_size = m_bounding_box.size(); const float mean_size = (float)((box_size.x() + box_size.y() + box_size.z()) / 3.0); m_grabbers[m_hover_id].render(true, mean_size); + glsafe(::glEnable(GL_CULL_FACE)); shader->stop_using(); } } diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index cbd61a1dd..e9d131c43 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -1593,6 +1593,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) shader->start_using(); glsafe(::glEnable(GL_DEPTH_TEST)); + glsafe(::glDisable(GL_CULL_FACE)); const Transform3d base_matrix = Geometry::translation_transform(get_bounding_box().center()); Transform3d orient_matrix = Transform3d::Identity(); @@ -1603,15 +1604,15 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) if (!boost::starts_with(sidebar_field, "layer")) { shader->set_uniform("emission_factor", 0.05f); if (is_single_full_instance() && !wxGetApp().obj_manipul()->is_world_coordinates()) { - orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_rotation_matrix(); - axes_center = (*m_volumes)[*m_list.begin()]->get_instance_offset(); + orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_rotation_matrix(); + axes_center = (*m_volumes)[*m_list.begin()]->get_instance_offset(); } else if (is_single_volume_or_modifier()) { if (!wxGetApp().obj_manipul()->is_world_coordinates()) { if (wxGetApp().obj_manipul()->is_local_coordinates()) { const GLVolume* v = (*m_volumes)[*m_list.begin()]; - orient_matrix = v->get_instance_transformation().get_rotation_matrix() * v->get_volume_transformation().get_rotation_matrix(); - axes_center = (*m_volumes)[*m_list.begin()]->world_matrix().translation(); + orient_matrix = get_bounding_box_in_current_reference_system().second; + orient_matrix.translation() = Vec3d::Zero(); } else { orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_rotation_matrix(); @@ -1645,6 +1646,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) m_axes.render(Geometry::translation_transform(axes_center) * orient_matrix, 0.25f); } + glsafe(::glEnable(GL_CULL_FACE)); shader->stop_using(); }