From 2aa55ef950a5372d45a68a32b34d1d8e366dd945 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 3 May 2023 16:14:26 +0200 Subject: [PATCH] Cut: fixed an issue when the view rotates to the other side of the plane --- src/slic3r/GUI/MeshUtils.cpp | 11 +++++------ src/slic3r/GUI/MeshUtils.hpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/MeshUtils.cpp b/src/slic3r/GUI/MeshUtils.cpp index 99a241c48..60ea6c856 100644 --- a/src/slic3r/GUI/MeshUtils.cpp +++ b/src/slic3r/GUI/MeshUtils.cpp @@ -392,12 +392,11 @@ void MeshClipper::recalculate_triangles() } isl.expoly = std::move(exp); - isl.expoly_bb = get_extents(exp); - isl.hash = 0; - for (const Point& pt : isl.expoly.contour) { - isl.hash ^= pt.x(); - isl.hash ^= pt.y(); - } + isl.expoly_bb = get_extents(isl.expoly); + + Point centroid_scaled = isl.expoly.contour.centroid(); + Vec3d centroid_world = m_result->trafo * Vec3d(unscale(centroid_scaled).x(), unscale(centroid_scaled).y(), 0.); + isl.hash = isl.expoly.contour.size() + size_t(std::abs(100.*centroid_world.x())) + size_t(std::abs(100.*centroid_world.y())) + size_t(std::abs(100.*centroid_world.z())); } // Now sort the islands so they are in defined order. This is a hack needed by cut gizmo, which sometimes diff --git a/src/slic3r/GUI/MeshUtils.hpp b/src/slic3r/GUI/MeshUtils.hpp index e5fa97e39..3645ecc02 100644 --- a/src/slic3r/GUI/MeshUtils.hpp +++ b/src/slic3r/GUI/MeshUtils.hpp @@ -141,7 +141,7 @@ private: ExPolygon expoly; BoundingBox expoly_bb; bool disabled = false; - coord_t hash; + size_t hash; }; struct ClipResult { std::vector cut_islands;