From 9805b02a25f3d24120ba8331cf14e00afe998708 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 12 Dec 2019 13:19:16 +0100 Subject: [PATCH] Removed an obsolete variable from MeshRaycaster --- src/slic3r/GUI/MeshUtils.cpp | 8 ++++---- src/slic3r/GUI/MeshUtils.hpp | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/MeshUtils.cpp b/src/slic3r/GUI/MeshUtils.cpp index 573952f75..3bf99f73c 100644 --- a/src/slic3r/GUI/MeshUtils.cpp +++ b/src/slic3r/GUI/MeshUtils.cpp @@ -195,10 +195,10 @@ Vec3f MeshRaycaster::get_closest_point(const Vec3f& point, Vec3f* normal) const Vec3d closest_point; m_emesh.squared_distance(point.cast(), idx, closest_point); if (normal) { - const stl_triangle_vertex_indices& indices = m_mesh->its.indices[idx]; - Vec3f a(m_mesh->its.vertices[indices(1)] - m_mesh->its.vertices[indices(0)]); - Vec3f b(m_mesh->its.vertices[indices(2)] - m_mesh->its.vertices[indices(0)]); - *normal = Vec3f(a.cross(b)); + auto indices = m_emesh.F().row(idx); + Vec3d a(m_emesh.V().row(indices(1)) - m_emesh.V().row(indices(0))); + Vec3d b(m_emesh.V().row(indices(2)) - m_emesh.V().row(indices(0))); + *normal = Vec3f(a.cross(b).cast()); } return closest_point.cast(); } diff --git a/src/slic3r/GUI/MeshUtils.hpp b/src/slic3r/GUI/MeshUtils.hpp index 56d726596..b4ad03011 100644 --- a/src/slic3r/GUI/MeshUtils.hpp +++ b/src/slic3r/GUI/MeshUtils.hpp @@ -105,10 +105,10 @@ private: // whether certain points are visible or obscured by the mesh etc. class MeshRaycaster { public: - // The class saves a const* to the mesh, calledz is responsible - // for making sure it does not get invalid. + // The class makes a copy of the mesh as EigenMesh3D. + // The pointer can be invalidated after constructor returns. MeshRaycaster(const TriangleMesh& mesh) - : m_emesh(mesh), m_mesh(&mesh) + : m_emesh(mesh) {} // Given a mouse position, this returns true in case it is on the mesh. @@ -138,7 +138,6 @@ public: private: sla::EigenMesh3D m_emesh; - const TriangleMesh* m_mesh = nullptr; };