瀏覽代碼

fix more findings.

Kim Kulling 6 年之前
父節點
當前提交
c1dc3901e7
共有 4 個文件被更改,包括 19 次插入5 次删除
  1. 5 1
      code/SceneCombiner.cpp
  2. 3 3
      code/XGLLoader.cpp
  3. 5 1
      code/glTF2Asset.h
  4. 6 0
      code/glTF2Importer.cpp

+ 5 - 1
code/SceneCombiner.cpp

@@ -738,7 +738,11 @@ void SceneCombiner::MergeBones(aiMesh* out,std::vector<aiMesh*>::const_iterator
 
         // And copy the final weights - adjust the vertex IDs by the
         // face index offset of the corresponding mesh.
-        for (std::vector< BoneSrcIndex >::const_iterator wmit = (*boneIt).pSrcBones.begin(); wmit != wend; ++wmit)  {
+        for (std::vector< BoneSrcIndex >::const_iterator wmit = (*boneIt).pSrcBones.begin(); wmit != (*boneIt).pSrcBones.end(); ++wmit) {
+            if (wmit == wend) {
+                break;
+            }
+
             aiBone* pip = (*wmit).first;
             for (unsigned int mp = 0; mp < pip->mNumWeights;++mp,++avw) {
                 const aiVertexWeight& vfi = pip->mWeights[mp];

+ 3 - 3
code/XGLLoader.cpp

@@ -370,7 +370,7 @@ aiLight* XGLImporter::ReadDirectionalLight()
 // ------------------------------------------------------------------------------------------------
 aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* closetag)
 {
-    std::unique_ptr<aiNode> nd(new aiNode());
+    aiNode *nd = new aiNode;
     std::vector<aiNode*> children;
     std::vector<unsigned int> meshes;
 
@@ -453,11 +453,11 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl
         nd->mChildren = new aiNode*[nd->mNumChildren]();
         for(unsigned int i = 0; i < nd->mNumChildren; ++i) {
             nd->mChildren[i] = children[i];
-            children[i]->mParent = nd.get();
+            children[i]->mParent = nd;
         }
     }
 
-    return nd.release();
+    return nd;
 }
 
 // ------------------------------------------------------------------------------------------------

+ 5 - 1
code/glTF2Asset.h

@@ -656,7 +656,11 @@ namespace glTF2
             } ortographic;
         } cameraProperties;
 
-        Camera() {}
+        Camera()
+        : type(Perspective)
+        , cameraProperties() {
+            // empty
+        }
         void Read(Value& obj, Asset& r);
     };
 

+ 6 - 0
code/glTF2Importer.cpp

@@ -763,6 +763,12 @@ static void BuildVertexWeightMapping(Mesh::Primitive& primitive, std::vector<std
     }else {
         attr.joint[0]->ExtractData(indices16);
     }
+    // 
+    if (nullptr == indices8 && nullptr == indices16) {
+        // Something went completely wrong!
+        ai_assert(false);
+        return;
+    }
 
     for (int i = 0; i < num_vertices; ++i) {
         for (int j = 0; j < 4; ++j) {