Bläddra i källkod

Merge pull request #2099 from gstanlo/master

Fixes crash when importing invalid glTF/2.0 files
Kim Kulling 7 år sedan
förälder
incheckning
ce9186b3a4
1 ändrade filer med 6 tillägg och 0 borttagningar
  1. 6 0
      code/glTF2Importer.cpp

+ 6 - 0
code/glTF2Importer.cpp

@@ -437,6 +437,12 @@ 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]->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]);
                 aim->mNumUVComponents[tc] = attr.texcoord[tc]->GetNumComponents();