summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-08 14:08:25 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-08 14:08:25 +0100
commitfe5a06851823ac6da841a513cf59140c63ff69f3 (patch)
tree303d2e9f21538cc8d15e8d576391780ad5cf3665
parentUpdate Brush47 with yellow cab parts and window texture (diff)
downloadilt-fe5a06851823ac6da841a513cf59140c63ff69f3.tar.bz2
ilt-fe5a06851823ac6da841a513cf59140c63ff69f3.tar.xz
ilt-fe5a06851823ac6da841a513cf59140c63ff69f3.zip
Simplify extruding
-rw-r--r--assetFactory/faceController.cpp20
1 files 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<glm::vec3> {}, [&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(), &centre](auto && p) {
- p = centre + ((p - centre) % mutation);
- });
// create new vertices
- std::vector<OpenMesh::VertexHandle> 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<std::string> faceNames;
for (size_t idx {}; idx < vertexCount; ++idx) {
const auto next = (idx + 1) % vertexCount;