From fe5a06851823ac6da841a513cf59140c63ff69f3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 8 Apr 2023 14:08:25 +0100 Subject: Simplify extruding --- assetFactory/faceController.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/assetFactory/faceController.cpp b/assetFactory/faceController.cpp index 7e4b0e1..7992fba 100644 --- a/assetFactory/faceController.cpp +++ b/assetFactory/faceController.cpp @@ -50,23 +50,13 @@ FaceController::extrude(ModelFactoryMesh & mesh, const std::string & faceName, O { // get points const auto baseVertices {materializeRange(mesh.fv_range(faceHandle))}; - auto points = std::accumulate( - baseVertices.begin(), baseVertices.end(), std::vector {}, [&mesh](auto && out, auto && v) { - out.push_back(mesh.point(v)); - return std::move(out); - }); - const auto vertexCount = points.size(); - const auto centre = mesh.calc_face_centroid(faceHandle); - // mutate points - std::for_each(points.begin(), points.end(), [mutation = getMatrix(), ¢re](auto && p) { - p = centre + ((p - centre) % mutation); - }); // create new vertices - std::vector vertices; - std::transform(points.begin(), points.end(), std::back_inserter(vertices), [&mesh](auto && p) { - return mesh.add_vertex(p); - }); + const auto vertices + = baseVertices * [&mesh, mutation = getMatrix(), centre = mesh.calc_face_centroid(faceHandle)](auto && v) { + return mesh.add_vertex(centre + ((mesh.point(v) - centre) % mutation)); + }; // get new faces names + const auto vertexCount = baseVertices.size(); std::vector faceNames; for (size_t idx {}; idx < vertexCount; ++idx) { const auto next = (idx + 1) % vertexCount; -- cgit v1.2.3