From 5382f4077ac88c988647979c4cb792a4cf475892 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 15 Nov 2022 16:08:27 +0100 Subject: [PATCH] Measurement: Partially fixed the common gizmo raycaster for self-intersecting meshes --- src/slic3r/GUI/MeshUtils.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/MeshUtils.cpp b/src/slic3r/GUI/MeshUtils.cpp index 0483d2bf0..94375a6e3 100644 --- a/src/slic3r/GUI/MeshUtils.cpp +++ b/src/slic3r/GUI/MeshUtils.cpp @@ -409,6 +409,12 @@ bool MeshRaycaster::unproject_on_mesh(const Vec2d& mouse_pos, const Transform3d& Vec3d direction; line_from_mouse_pos(mouse_pos, trafo, camera, point, direction); + if (rand()%100 == 0) { + int a=5; + int b=6; + int c=7; + } + std::vector hits = m_emesh.query_ray_hits(point, direction); if (hits.empty()) @@ -429,10 +435,10 @@ bool MeshRaycaster::unproject_on_mesh(const Vec2d& mouse_pos, const Transform3d& // All hits are clipped. return false; } - if ((hits.size()-i) % 2 != 0) { + if (clipping_plane && (hits.size()-i) % 2 != 0) { // There is an odd number of unclipped hits - meaning the nearest must be from inside the mesh. // In that case, calculate intersection with the clipping place. - if (clipping_plane && was_clipping_plane_hit) { + if (was_clipping_plane_hit) { direction = direction + point; point = trafo * point; // transform to world coords direction = trafo * direction - point;