Merge pull request #4693 from vkaytsanov/master

Remove exception on glTF 2.0 loading
pull/4701/head
Kim Kulling 2022-08-23 23:36:26 +02:00 committed by GitHub
commit 88c69d4edc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -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'; }
};
//

View File

@ -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

View File

@ -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;
}