Fixes crash when importing invalid glTF/2.0 files
Skips some glTF/2.0 uv processing if the count of uvs in the attribute stream doesn't match the vertex count. This happens with some malformed glTF/2.0 files, and the change will allow them to be processed properly. Without the change, an access violation will occur several lines below if uv count is less than the position count.pull/2099/head
parent
1883d44b9b
commit
82f3d40d60
|
@ -436,6 +436,12 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) {
|
for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) {
|
||||||
|
if (attr.texcoord[tc]->count != aim->mNumVertices) {
|
||||||
|
DefaultLogger::get()->warn("Texcoord stream size in mesh \"" + mesh.name +
|
||||||
|
"\" does not match the vertex count");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
attr.texcoord[tc]->ExtractData(aim->mTextureCoords[tc]);
|
attr.texcoord[tc]->ExtractData(aim->mTextureCoords[tc]);
|
||||||
aim->mNumUVComponents[tc] = attr.texcoord[tc]->GetNumComponents();
|
aim->mNumUVComponents[tc] = attr.texcoord[tc]->GetNumComponents();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue