From 88d5b474f3ab1c021612b0730f1b8d327a7a32db Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 16 Feb 2023 23:56:10 +0000 Subject: Add support for smooth faces --- assetFactory/factoryMesh.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'assetFactory/factoryMesh.cpp') diff --git a/assetFactory/factoryMesh.cpp b/assetFactory/factoryMesh.cpp index 9d30ac9..baa031d 100644 --- a/assetFactory/factoryMesh.cpp +++ b/assetFactory/factoryMesh.cpp @@ -17,10 +17,14 @@ FactoryMesh::createMesh() const mesh.triangulate(); mesh.update_face_normals(); + mesh.update_vertex_normals(); std::vector vertices; for (const auto & face : mesh.faces()) { + const auto smooth = mesh.property(mesh.smoothFaceProperty, face); for (const auto & vertex : mesh.fv_range(face)) { - vertices.emplace_back(mesh.point(vertex), NullUV, mesh.property(mesh.face_normals_pph(), face)); + vertices.emplace_back(mesh.point(vertex), NullUV, + smooth ? mesh.property(mesh.vertex_normals_pph(), vertex) + : mesh.property(mesh.face_normals_pph(), face)); } } return std::make_shared(vertices, vectorOfN(vertices.size())); -- cgit v1.2.3