Force normalized normals

pull/1712/head
Alexis Breust 2018-01-16 09:56:44 +01:00
parent 0f4189c77e
commit 5e6cae3094
1 changed files with 6 additions and 1 deletions

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) {