Force normalized normals

This commit is contained in:
Alexis Breust
2018-01-16 09:56:44 +01:00
parent 0f4189c77e
commit 5e6cae3094

View File

@@ -708,8 +708,13 @@ void glTF2Exporter::ExportMeshes()
if (v) p.attributes.position.push_back(v);
/******************** Normals ********************/
// Normalize all normals as the validator can emit a warning otherwise
for (auto i = 0u; i < aim->mNumVertices; ++i) {
aim->mNormals[i].Normalize();
}
Ref<Accessor> n = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mNormals, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
if (n) p.attributes.normal.push_back(n);
if (n) p.attributes.normal.push_back(n);
/************** Texture coordinates **************/
for (int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {