#include "factoryMesh.h" #include "collections.hpp" #include "gfx/models/vertex.hpp" #include "modelFactoryMesh.h" #include Mesh::Ptr FactoryMesh::createMesh() const { constexpr glm::vec2 NullUV {}; ModelFactoryMesh mesh; for (const auto & use : uses) { use->createMesh(mesh, glm::identity()); } mesh.garbage_collection(); 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, smooth ? mesh.property(mesh.vertex_normals_pph(), vertex) : mesh.property(mesh.face_normals_pph(), face)); } } return std::make_shared(vertices, vectorOfN(vertices.size())); }