Gracefully handle NaNs and Infs in gltf2 accessor bound computation

This commit is contained in:
Jeremy Cytryn
2020-05-11 12:02:38 -07:00
parent aef4ecada5
commit c5a9fbd47f
2 changed files with 12 additions and 5 deletions
+10 -3
View File
@@ -1,4 +1,4 @@
/*
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
@@ -172,6 +172,13 @@ void SetAccessorRange(Ref<Accessor> acc, void* data, size_t count,
for (unsigned int j = 0 ; j < numCompsOut ; j++) {
double valueTmp = buffer_ptr[j];
// Gracefully tolerate rogue NaN's in buffer data
// Any NaNs/Infs introduced in accessor bounds will end up in
// document and prevent rapidjson from writing out valid JSON
if (!std::isfinite(valueTmp)) {
continue;
}
if (valueTmp < acc->min[j]) {
acc->min[j] = valueTmp;
}
@@ -348,7 +355,7 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref<Texture>& texture, aiTe
if (path[0] == '*') { // embedded
aiTexture* curTex = mScene->mTextures[atoi(&path[1])];
texture->source->name = curTex->mFilename.C_Str();
// The asset has its own buffer, see Image::SetData
@@ -762,7 +769,7 @@ void glTF2Exporter::ExportMeshes()
for (int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
if (!aim->HasTextureCoords(i))
continue;
// Flip UV y coords
if (aim -> mNumUVComponents[i] > 1) {
for (unsigned int j = 0; j < aim->mNumVertices; ++j) {