summaryrefslogtreecommitdiff
path: root/assetFactory
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-25 02:46:55 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-25 02:46:55 +0100
commit18189cf376f7a0a18544df552f1fe8e905d87e38 (patch)
tree554679faf7e14e3c3e2e019e3d8027b7a7080da2 /assetFactory
parentDon't update face/vertex normals if normals were provided, simply use them as is (diff)
downloadilt-18189cf376f7a0a18544df552f1fe8e905d87e38.tar.bz2
ilt-18189cf376f7a0a18544df552f1fe8e905d87e38.tar.xz
ilt-18189cf376f7a0a18544df552f1fe8e905d87e38.zip
Set vertex normals from AssImp data if available
Diffstat (limited to 'assetFactory')
-rw-r--r--assetFactory/assimp.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/assetFactory/assimp.cpp b/assetFactory/assimp.cpp
index 840c5a9..74b1c54 100644
--- a/assetFactory/assimp.cpp
+++ b/assetFactory/assimp.cpp
@@ -59,9 +59,15 @@ public:
void
addMesh(CreatedFaces & faces, ModelFactoryMesh & mesh, const aiMesh * amesh) const
{
- const auto vhs = AIRANGE(amesh, Vertices) * [&mesh](auto && v) {
- return mesh.add_vertex(*v);
- };
+ mesh.normalsProvidedProperty = amesh->HasNormals();
+ const auto vhs = AIRANGE(amesh, Vertices) *
+ [&mesh, normals = amesh->HasNormals() ? amesh->mNormals : nullptr](auto && v) mutable {
+ const auto vh = mesh.add_vertex(*v);
+ if (normals) {
+ mesh.set_normal(vh, **(normals++));
+ }
+ return vh;
+ };
const auto & m = scene->mMaterials[amesh->mMaterialIndex]->GetName();
GLuint material {};