summaryrefslogtreecommitdiff
path: root/assetFactory
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-25 02:46:03 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-25 02:46:03 +0100
commit9a16e572ab54c9f2598af5c02643cc1db7a30a91 (patch)
treede9a842a7ae4d81b13810dd940e8ecf390ef47b4 /assetFactory
parentAllow setting a flag to say (vertex) normals have been provided (diff)
downloadilt-9a16e572ab54c9f2598af5c02643cc1db7a30a91.tar.bz2
ilt-9a16e572ab54c9f2598af5c02643cc1db7a30a91.tar.xz
ilt-9a16e572ab54c9f2598af5c02643cc1db7a30a91.zip
Don't update face/vertex normals if normals were provided, simply use them as is
Diffstat (limited to 'assetFactory')
-rw-r--r--assetFactory/factoryMesh.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/assetFactory/factoryMesh.cpp b/assetFactory/factoryMesh.cpp
index f7bc7c8..784179f 100644
--- a/assetFactory/factoryMesh.cpp
+++ b/assetFactory/factoryMesh.cpp
@@ -13,10 +13,13 @@ FactoryMesh::createMesh() const
ModelFactoryMesh mesh;
use->createMesh(mesh, 1);
- mesh.update_face_normals();
- mesh.update_vertex_normals();
+ if (!mesh.normalsProvidedProperty) {
+ mesh.update_face_normals();
+ mesh.update_vertex_normals();
+ }
for (const auto & face : mesh.faces()) {
- const auto & smooth = mesh.property(mesh.smoothFaceProperty, face);
+ const auto & useVertexNormals
+ = mesh.property(mesh.smoothFaceProperty, face) || mesh.normalsProvidedProperty;
const auto & colour = mesh.color(face);
const auto & material = mesh.property(mesh.materialFaceProperty, face);
@@ -25,8 +28,8 @@ FactoryMesh::createMesh() const
const auto & vertex = mesh.to_vertex_handle(heh);
const auto & textureUV = mesh.texcoord2D(heh);
const auto & point = mesh.point(vertex);
- const auto & normal = smooth ? mesh.property(mesh.vertex_normals_pph(), vertex)
- : mesh.property(mesh.face_normals_pph(), face);
+ const auto & normal = useVertexNormals ? mesh.property(mesh.vertex_normals_pph(), vertex)
+ : mesh.property(mesh.face_normals_pph(), face);
Vertex outVertex {point, textureUV, normal, colour, material};
if (const auto existingItr = std::find(vertices.rbegin(), vertices.rend(), outVertex);
existingItr != vertices.rend()) {