浏览代码

Remove exception on glTF 2.0 loading

vkaytsanov 3 年之前
父节点
当前提交
d469c7b161
共有 3 个文件被更改,包括 8 次插入7 次删除
  1. 3 1
      code/AssetLib/glTF/glTFAsset.h
  2. 4 4
      code/AssetLib/glTF/glTFAsset.inl
  3. 1 2
      code/AssetLib/glTF/glTFImporter.cpp

+ 3 - 1
code/AssetLib/glTF/glTFAsset.h

@@ -903,8 +903,10 @@ struct AssetMetadata {
     void Read(Document &doc);
     void Read(Document &doc);
 
 
     AssetMetadata() :
     AssetMetadata() :
-            premultipliedAlpha(false), version() {
+            premultipliedAlpha(false) {
     }
     }
+
+    operator bool() const { return version.size() && version[0] == '1'; }
 };
 };
 
 
 //
 //

+ 4 - 4
code/AssetLib/glTF/glTFAsset.inl

@@ -1114,10 +1114,6 @@ inline void AssetMetadata::Read(Document &doc) {
             ReadMember(*curProfile, "version", this->profile.version);
             ReadMember(*curProfile, "version", this->profile.version);
         }
         }
     }
     }
-
-    if (version.empty() || version[0] != '1') {
-        throw DeadlyImportError("GLTF: Unsupported glTF version: ", version);
-    }
 }
 }
 
 
 //
 //
@@ -1222,6 +1218,10 @@ inline void Asset::Load(const std::string &pFile, bool isBinary) {
 
 
     // Load the metadata
     // Load the metadata
     asset.Read(doc);
     asset.Read(doc);
+    if (!asset) {
+        return;
+    }
+
     ReadExtensionsUsed(doc);
     ReadExtensionsUsed(doc);
 
 
     // Prepare the dictionaries
     // Prepare the dictionaries

+ 1 - 2
code/AssetLib/glTF/glTFImporter.cpp

@@ -96,8 +96,7 @@ bool glTFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool
     glTF::Asset asset(pIOHandler);
     glTF::Asset asset(pIOHandler);
     try {
     try {
         asset.Load(pFile, GetExtension(pFile) == "glb");
         asset.Load(pFile, GetExtension(pFile) == "glb");
-        std::string version = asset.asset.version;
-        return !version.empty() && version[0] == '1';
+        return asset.asset;
     } catch (...) {
     } catch (...) {
         return false;
         return false;
     }
     }