diff --git a/src/mesa_pd/common/Contains.h b/src/mesa_pd/common/Contains.h index a9e583440a6207f9d54f6ad811daea2eb62eaaa8..00e74bb3990d29436d1a4507796d315c5d050ea7 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 8bb9ec0b5394747fff6f2d70a672f6d8d481294c..d04e347565cdaa8d7d9218fe833ee71283628772 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());