From d469c7b161e300b9cf766f23303bb8651bba4efb Mon Sep 17 00:00:00 2001 From: vkaytsanov Date: Tue, 16 Aug 2022 15:52:43 +0300 Subject: [PATCH] Remove exception on glTF 2.0 loading --- code/AssetLib/glTF/glTFAsset.h | 4 +++- code/AssetLib/glTF/glTFAsset.inl | 8 ++++---- code/AssetLib/glTF/glTFImporter.cpp | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/code/AssetLib/glTF/glTFAsset.h b/code/AssetLib/glTF/glTFAsset.h index 1a42e9020..1b4faa9f6 100644 --- a/code/AssetLib/glTF/glTFAsset.h +++ b/code/AssetLib/glTF/glTFAsset.h @@ -903,8 +903,10 @@ struct AssetMetadata { void Read(Document &doc); AssetMetadata() : - premultipliedAlpha(false), version() { + premultipliedAlpha(false) { } + + operator bool() const { return version.size() && version[0] == '1'; } }; // diff --git a/code/AssetLib/glTF/glTFAsset.inl b/code/AssetLib/glTF/glTFAsset.inl index 86fba95b7..4eb7cd609 100644 --- a/code/AssetLib/glTF/glTFAsset.inl +++ b/code/AssetLib/glTF/glTFAsset.inl @@ -1114,10 +1114,6 @@ inline void AssetMetadata::Read(Document &doc) { 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 asset.Read(doc); + if (!asset) { + return; + } + ReadExtensionsUsed(doc); // Prepare the dictionaries diff --git a/code/AssetLib/glTF/glTFImporter.cpp b/code/AssetLib/glTF/glTFImporter.cpp index 81db12eba..4ba54ac23 100644 --- a/code/AssetLib/glTF/glTFImporter.cpp +++ b/code/AssetLib/glTF/glTFImporter.cpp @@ -96,8 +96,7 @@ bool glTFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool glTF::Asset asset(pIOHandler); try { asset.Load(pFile, GetExtension(pFile) == "glb"); - std::string version = asset.asset.version; - return !version.empty() && version[0] == '1'; + return asset.asset; } catch (...) { return false; }