diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-16 23:56:10 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-16 23:56:10 +0000 |
commit | 88d5b474f3ab1c021612b0730f1b8d327a7a32db (patch) | |
tree | 9d7178f03f130f7107ef4d278a1e34a0cc0dae06 /assetFactory/faceController.cpp | |
parent | Refactor so ModelFactoryMesh can define the smooth property on faces (diff) | |
download | ilt-88d5b474f3ab1c021612b0730f1b8d327a7a32db.tar.bz2 ilt-88d5b474f3ab1c021612b0730f1b8d327a7a32db.tar.xz ilt-88d5b474f3ab1c021612b0730f1b8d327a7a32db.zip |
Add support for smooth faces
Diffstat (limited to 'assetFactory/faceController.cpp')
-rw-r--r-- | assetFactory/faceController.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/assetFactory/faceController.cpp b/assetFactory/faceController.cpp index c04a656..7ec7820 100644 --- a/assetFactory/faceController.cpp +++ b/assetFactory/faceController.cpp @@ -23,6 +23,9 @@ FaceController::apply(ModelFactoryMesh & mesh, const std::string & name, Shape:: const auto vertexCount = points.size(); const auto centre = std::accumulate(points.begin(), points.end(), glm::vec3 {}) / static_cast<float>(vertexCount); + if (smooth) { + mesh.property(mesh.smoothFaceProperty, cf.second) = true; + } if (type == "extrude") { Shape::CreatedFaces newFaces; // mutate points @@ -43,6 +46,11 @@ FaceController::apply(ModelFactoryMesh & mesh, const std::string & name, Shape:: mesh.add_face({baseVertices[idx], baseVertices[next], vertices[next], vertices[idx]})); } newFaces.emplace(name, mesh.add_face(vertices)); + if (smooth) { + for (const auto & [name, face] : newFaces) { + mesh.property(mesh.smoothFaceProperty, face) = true; + } + } for (const auto & [name, faceController] : faceControllers) { faceController.apply(mesh, name, newFaces); } |