summaryrefslogtreecommitdiff
path: root/assetFactory/factoryMesh.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-02-16 23:56:10 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-02-16 23:56:10 +0000
commit88d5b474f3ab1c021612b0730f1b8d327a7a32db (patch)
tree9d7178f03f130f7107ef4d278a1e34a0cc0dae06 /assetFactory/factoryMesh.cpp
parentRefactor so ModelFactoryMesh can define the smooth property on faces (diff)
downloadilt-88d5b474f3ab1c021612b0730f1b8d327a7a32db.tar.bz2
ilt-88d5b474f3ab1c021612b0730f1b8d327a7a32db.tar.xz
ilt-88d5b474f3ab1c021612b0730f1b8d327a7a32db.zip
Add support for smooth faces
Diffstat (limited to 'assetFactory/factoryMesh.cpp')
-rw-r--r--assetFactory/factoryMesh.cpp6
1 files changed, 5 insertions, 1 deletions
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<Vertex> 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<Mesh>(vertices, vectorOfN(vertices.size()));