Merge pull request #3279 from assimp/migenius-migenius-fix-texcoord

add a unittest.
pull/3267/head^2
Kim Kulling 2020-06-12 15:04:51 +02:00 committed by GitHub
commit 094b808880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 620 additions and 2 deletions

View File

@ -722,7 +722,7 @@ template <class T>
void Accessor::ExtractData(T *&outData) {
uint8_t *data = GetPointer();
if (!data) {
throw DeadlyImportError("GLTF: data is NULL");
throw DeadlyImportError("GLTF2: data is nullptr.");
}
const size_t elemSize = GetElementSize();

View File

@ -417,7 +417,8 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
}
for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) {
if (!attr.texcoord[tc]) {
throw DeadlyImportError("GLTF: Texture coordinate accessor not found or non-contiguous texture coordinate sets");
DefaultLogger::get()->warn("Texture coordinate accessor not found or non-contiguous texture coordinate sets.");
continue;
}
if (attr.texcoord[tc]->count != aim->mNumVertices) {

File diff suppressed because one or more lines are too long

View File

@ -534,3 +534,10 @@ TEST_F(utglTF2ImportExport, norootnode_scenewithoutnodes) {
ASSERT_NE(scene, nullptr);
ASSERT_NE(scene->mRootNode, nullptr);
}
// Shall not crash!
TEST_F(utglTF2ImportExport, norootnode_issue_3269) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/issue_3269/texcoord_crash.gltf", aiProcess_ValidateDataStructure);
ASSERT_EQ(scene, nullptr);
}