Make gltf2 export normal normalization safe

This avoids introducing NaNs e.g. when the input mesh has 0-length normals
This commit is contained in:
Jeremy Cytryn
2020-05-11 12:02:38 -07:00
parent c5a9fbd47f
commit c3a21666da
4 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -348,7 +348,7 @@ void glTFExporter::GetMatColorOrTex(const aiMaterial* mat, glTF::TexProperty& pr
if (path[0] == '*') { // embedded
aiTexture* curTex = mScene->mTextures[atoi(&path[1])];
prop.texture->source->name = curTex->mFilename.C_Str();
uint8_t *data = reinterpret_cast<uint8_t *>(curTex->pcData);
+1 -1
View File
@@ -758,7 +758,7 @@ void glTF2Exporter::ExportMeshes()
// Normalize all normals as the validator can emit a warning otherwise
if ( nullptr != aim->mNormals) {
for ( auto i = 0u; i < aim->mNumVertices; ++i ) {
aim->mNormals[ i ].Normalize();
aim->mNormals[ i ].NormalizeSafe();
}
}