소스 검색

glTF importer - clean all member arrays

When importing more than one scene using the same gtlf importer loading fails with error 'bad array new length'. This happens because 'meshOffsets' are not cleared and the importer continues to push_back values at the end. Adjacent values are then used to calculate the length of 'mMeshes' array. This calculation expects that each value is higher than the previous otherwise we get negative length. But when pushin at the end of uncleared array we get contents like this: 0,1,2,3,0,1,2. Then when calculating 0-3 we try to allocate array of length -3 and get this exception.
petrmohelnik 6 년 전
부모
커밋
1855bf44f9
2개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 1
      code/glTF2Importer.cpp
  2. 5 1
      code/glTFImporter.cpp

+ 5 - 1
code/glTF2Importer.cpp

@@ -1130,7 +1130,11 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset& r)
     }
 }
 
-void glTF2Importer::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
+void glTF2Importer::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
+{
+    // clean all member arrays
+    meshOffsets.clear();
+    embeddedTexIdxs.clear();
 
     this->mScene = pScene;
 

+ 5 - 1
code/glTFImporter.cpp

@@ -717,7 +717,11 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r)
     }
 }
 
-void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
+void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
+{
+    // clean all member arrays
+    meshOffsets.clear();
+    embeddedTexIdxs.clear();
 
     this->mScene = pScene;