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:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user