From c6cf5b99b495c8bd98ffc57223893a1856711e66 Mon Sep 17 00:00:00 2001 From: Christoph Rettinger <christoph.rettinger@fau.de> Date: Tue, 3 May 2022 16:49:45 +0200 Subject: [PATCH] Added missing calls to compute mesh face normals in mesa_pd convex polyhedron --- src/mesa_pd/common/Contains.h | 2 ++ src/mesa_pd/data/shape/ConvexPolyhedron.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/mesa_pd/common/Contains.h b/src/mesa_pd/common/Contains.h index a9e583440..00e74bb39 100644 --- a/src/mesa_pd/common/Contains.h +++ b/src/mesa_pd/common/Contains.h @@ -79,6 +79,8 @@ bool isPointInsideCylindricalBoundary(const Vec3& point, #ifdef WALBERLA_MESAPD_CONVEX_POLYHEDRON_AVAILABLE bool isPointInsideConvexPolyhedronBF(const Vec3& point, const mesh::TriangleMesh& mesh) { + WALBERLA_ASSERT(mesh.has_face_normals(), "Provided mesh has no face normals! E.g., call `mesh.request_face_normals(); mesh.update_face_normals();` to add them.") + return std::none_of(mesh.faces().begin(), mesh.faces().end(), [&](auto fh) diff --git a/src/mesa_pd/data/shape/ConvexPolyhedron.h b/src/mesa_pd/data/shape/ConvexPolyhedron.h index 8bb9ec0b5..d04e34756 100644 --- a/src/mesa_pd/data/shape/ConvexPolyhedron.h +++ b/src/mesa_pd/data/shape/ConvexPolyhedron.h @@ -130,6 +130,9 @@ inline void ConvexPolyhedron::updateMassAndInertia(const real_t density) { inline void ConvexPolyhedron::updateMeshQuantities() { WALBERLA_CHECK_GREATER(mesh_.n_vertices(), 0, "Cannot compute mesh quantities for an empty mesh!"); + mesh_.request_face_normals(); + mesh_.update_face_normals(); + octandVertices_[0] = supportVertex(mesh::TriangleMesh::Normal(real_t(1), real_t(1), real_t(1)), *mesh_.vertices_begin()); octandVertices_[1] = supportVertex(mesh::TriangleMesh::Normal(real_t(1), real_t(1), real_t(-1)), *mesh_.vertices_begin()); octandVertices_[2] = supportVertex(mesh::TriangleMesh::Normal(real_t(1), real_t(-1), real_t(1)), *mesh_.vertices_begin()); -- GitLab