Browse Source

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

add a unittest.
Kim Kulling 5 years ago
parent
commit
094b808880

+ 1 - 1
code/AssetLib/glTF2/glTF2Asset.inl

@@ -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();

+ 2 - 1
code/AssetLib/glTF2/glTF2Importer.cpp

@@ -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 it is too large
+ 412 - 0
test/models/glTF2/issue_3269/texcoord_crash.gltf


+ 7 - 0
test/unit/utglTF2ImportExport.cpp

@@ -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);
+}

Some files were not shown because too many files changed in this diff