From fbdc9cd580f835d1a873d08ed64baed3b3db6f9a Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Mon, 14 Oct 2024 14:31:15 +0800 Subject: [PATCH] FIX:when two dir is perpendicular to each other,scale error (plane_normal.dot(ray_dir)) jira:STUDIO-8274 Change-Id: Ib3145ab75e18c832d20065d204aa41b75f73b673 --- src/slic3r/GUI/Gizmos/GLGizmoScale.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp index 255d3a232..849d665a2 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp @@ -364,10 +364,16 @@ double GLGizmoScale3D::calc_ratio(const UpdateData& data) const Vec3d plane_vec = mouse_dir.cross(m_starting.plane_nromal); plane_normal = plane_vec.cross(m_starting.plane_nromal); } - + plane_normal = plane_normal.normalized(); // finds the intersection of the mouse ray with the plane that the drag point moves // use ray-plane intersection see i.e. https://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection - Vec3d inters = GetIntersectionOfRayAndPlane(data.mouse_ray.a, mouse_dir, m_starting.drag_position, plane_normal.normalized()); + auto dot_value = (plane_normal.dot(mouse_dir)); + auto angle = Geometry::rad2deg(acos(dot_value)); + auto big_than_min_angle = abs(angle) < 95 && abs(angle) > 85; + if (big_than_min_angle) { + return 1; + } + Vec3d inters = GetIntersectionOfRayAndPlane(data.mouse_ray.a, mouse_dir, m_starting.drag_position, plane_normal); Vec3d inters_vec = inters - m_starting.drag_position;