summaryrefslogtreecommitdiff
path: root/assetFactory/factoryMesh.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-18 02:44:00 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-18 02:44:00 +0000
commit51f0f60bd24a3d7ed77cf713f846bc49c2f1aed5 (patch)
treeb4b7acb17274e1753a002956bcddebb691c40762 /assetFactory/factoryMesh.cpp
parentUse indices instead of triangulation (diff)
downloadilt-51f0f60bd24a3d7ed77cf713f846bc49c2f1aed5.tar.bz2
ilt-51f0f60bd24a3d7ed77cf713f846bc49c2f1aed5.tar.xz
ilt-51f0f60bd24a3d7ed77cf713f846bc49c2f1aed5.zip
Use halfedge for texture coordinates
More unique than vertex as it is also per face, allowing for a different texture on adjacent faces
Diffstat (limited to 'assetFactory/factoryMesh.cpp')
-rw-r--r--assetFactory/factoryMesh.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/assetFactory/factoryMesh.cpp b/assetFactory/factoryMesh.cpp
index 59b390f..6cca388 100644
--- a/assetFactory/factoryMesh.cpp
+++ b/assetFactory/factoryMesh.cpp
@@ -18,16 +18,17 @@ FactoryMesh::createMesh() const
for (const auto & face : mesh.faces()) {
const auto smooth = mesh.property(mesh.smoothFaceProperty, face);
const auto colour = mesh.color(face);
- auto vrange = mesh.fv_range(face);
+ auto hrange = mesh.fh_range(face);
const unsigned int start = static_cast<unsigned int>(vertices.size());
- for (const auto & vertex : vrange) {
- const auto textureUV = mesh.texcoord2D(vertex);
+ for (const auto & heh : hrange) {
+ const auto & vertex = mesh.to_vertex_handle(heh);
+ const auto textureUV = mesh.texcoord2D(heh);
vertices.emplace_back(mesh.point(vertex), textureUV,
smooth ? mesh.property(mesh.vertex_normals_pph(), vertex)
: mesh.property(mesh.face_normals_pph(), face),
colour);
}
- const auto vcount = std::distance(vrange.begin(), vrange.end());
+ const auto vcount = std::distance(hrange.begin(), hrange.end());
for (unsigned int i = 2; i < vcount; i++) {
indices.push_back(start);
indices.push_back(start + i - 1);