Check that normal count and tangent count matches vertex count. Ignore data and warn if counts don't match.

pull/3670/head
Max Vollmer (Microsoft Havok) 2021-02-24 14:19:29 +00:00
parent 3c79b12e02
commit facb7da701
1 changed files with 21 additions and 13 deletions

View File

@ -452,10 +452,16 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
}
if (attr.normal.size() > 0 && attr.normal[0]) {
if (attr.normal[0]->count != aim->mNumVertices) {
DefaultLogger::get()->warn("Normal count in mesh \"" + mesh.name + "\" does not match the vertex count");
} else {
attr.normal[0]->ExtractData(aim->mNormals);
// only extract tangents if normals are present
if (attr.tangent.size() > 0 && attr.tangent[0]) {
if (attr.tangent[0]->count != aim->mNumVertices) {
DefaultLogger::get()->warn("Tangent count in mesh \"" + mesh.name + "\" does not match the vertex count");
} else {
// generate bitangents from normals and tangents according to spec
Tangent *tangents = nullptr;
@ -472,6 +478,8 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
delete[] tangents;
}
}
}
}
for (size_t c = 0; c < attr.color.size() && c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c) {
if (attr.color[c]->count != aim->mNumVertices) {