Merge branch 'master' into skylion007/modernize-use-emplace

pull/4700/head
Kim Kulling 2022-08-24 11:48:30 +02:00 committed by GitHub
commit 2b30b7e062
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 18 deletions

View File

@ -2,8 +2,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2019, assimp team Copyright (c) 2006-2022, assimp team
All rights reserved. All rights reserved.
@ -262,22 +261,25 @@ void X3DImporter::readDisk2D(XmlNode &node) {
// //
// create quad list from two point lists // create quad list from two point lists
// //
if (tlist_i.size() < 2) throw DeadlyImportError("Disk2D. Not enough points for creating quad list."); // tlist_i and tlist_o has equal size. if (tlist_i.size() < 2) {
// tlist_i and tlist_o has equal size.
throw DeadlyImportError("Disk2D. Not enough points for creating quad list.");
}
// add all quads except last // add all quads except last
for (std::list<aiVector3D>::iterator it_i = tlist_i.begin(), it_o = tlist_o.begin(); it_i != tlist_i.end();) { for (std::list<aiVector3D>::iterator it_i = tlist_i.begin(), it_o = tlist_o.begin(); it_i != tlist_i.end();) {
// do not forget - CCW direction // do not forget - CCW direction
vlist.push_back(*it_i++); // 1st point vlist.emplace_back(*it_i++); // 1st point
vlist.push_back(*it_o++); // 2nd point vlist.emplace_back(*it_o++); // 2nd point
vlist.push_back(*it_o); // 3rd point vlist.emplace_back(*it_o); // 3rd point
vlist.push_back(*it_i); // 4th point vlist.emplace_back(*it_i); // 4th point
} }
// add last quad // add last quad
vlist.push_back(*tlist_i.end()); // 1st point vlist.emplace_back(tlist_i.back()); // 1st point
vlist.push_back(*tlist_o.end()); // 2nd point vlist.emplace_back(tlist_o.back()); // 2nd point
vlist.push_back(*tlist_o.begin()); // 3rd point vlist.emplace_back(tlist_o.front()); // 3rd point
vlist.push_back(*tlist_o.begin()); // 4th point vlist.emplace_back(tlist_i.front()); // 4th point
((X3DNodeElementGeometry2D *)ne)->NumIndices = 4; ((X3DNodeElementGeometry2D *)ne)->NumIndices = 4;
} }

View File

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

View File

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

View File

@ -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 asset.asset;
return !version.empty() && version[0] == '1';
} catch (...) { } catch (...) {
return false; return false;
} }