From d469c7b161e300b9cf766f23303bb8651bba4efb Mon Sep 17 00:00:00 2001 From: vkaytsanov Date: Tue, 16 Aug 2022 15:52:43 +0300 Subject: [PATCH 01/39] 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; } From 2c1943cd10c84d1a1b1ebf1982ddc35756f463cd Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 8 Aug 2022 13:35:58 +0300 Subject: [PATCH 02/39] Improve BlenderDNA error message --- code/AssetLib/Blender/BlenderDNA.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/Blender/BlenderDNA.h b/code/AssetLib/Blender/BlenderDNA.h index b2158f283..dc5a36c2a 100644 --- a/code/AssetLib/Blender/BlenderDNA.h +++ b/code/AssetLib/Blender/BlenderDNA.h @@ -416,10 +416,10 @@ template <> struct Structure::_defaultInitializer { template - void operator()(T & /*out*/, const char * = "") { + void operator()(T & /*out*/, const char *message = "") { // obviously, it is crucial that _DefaultInitializer is used // only from within a catch clause. - throw DeadlyImportError("Constructing BlenderDNA Structure encountered an error"); + throw DeadlyImportError("Constructing BlenderDNA Structure encountered an error: ", message); } }; From e43e3e11b93ea8cd6bce757c4a62d59eda20e8f5 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 8 Aug 2022 13:53:38 +0300 Subject: [PATCH 03/39] Move SharedModifierData definition to BlenderScene.h --- code/AssetLib/Blender/BlenderModifier.cpp | 4 ---- code/AssetLib/Blender/BlenderScene.h | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/Blender/BlenderModifier.cpp b/code/AssetLib/Blender/BlenderModifier.cpp index d2b393dc4..09bad0cfa 100644 --- a/code/AssetLib/Blender/BlenderModifier.cpp +++ b/code/AssetLib/Blender/BlenderModifier.cpp @@ -71,10 +71,6 @@ static const fpCreateModifier creators[] = { nullptr // sentinel }; -// ------------------------------------------------------------------------------------------------ -struct SharedModifierData : ElemBase { - ModifierData modifier; -}; // ------------------------------------------------------------------------------------------------ void BlenderModifierShowcase::ApplyModifiers(aiNode &out, ConversionData &conv_data, const Scene &in, const Object &orig_object) { diff --git a/code/AssetLib/Blender/BlenderScene.h b/code/AssetLib/Blender/BlenderScene.h index c153d3c22..cef40b660 100644 --- a/code/AssetLib/Blender/BlenderScene.h +++ b/code/AssetLib/Blender/BlenderScene.h @@ -648,6 +648,13 @@ struct ModifierData : ElemBase { char name[32]; }; + +// ------------------------------------------------------------------------------------------------ +struct SharedModifierData : ElemBase { + ModifierData modifier; +}; + + // ------------------------------------------------------------------------------- struct SubsurfModifierData : ElemBase { From 2e64880abf50b17864913b7db3279f5862c19d7e Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 8 Aug 2022 13:56:20 +0300 Subject: [PATCH 04/39] Inherit SubsurfModifierData and MirrorModifierData from SharedModifierData This makes the cast in BlenderModifierShowcase::ApplyModifiers work correctly and not invoke UB. --- code/AssetLib/Blender/BlenderScene.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/code/AssetLib/Blender/BlenderScene.h b/code/AssetLib/Blender/BlenderScene.h index cef40b660..d44a7c470 100644 --- a/code/AssetLib/Blender/BlenderScene.h +++ b/code/AssetLib/Blender/BlenderScene.h @@ -656,7 +656,7 @@ struct SharedModifierData : ElemBase { // ------------------------------------------------------------------------------- -struct SubsurfModifierData : ElemBase { +struct SubsurfModifierData : SharedModifierData { enum Type { @@ -669,7 +669,6 @@ struct SubsurfModifierData : ElemBase { FLAGS_SubsurfUV = 1 << 3 }; - ModifierData modifier FAIL; short subdivType WARN; short levels FAIL; short renderLevels; @@ -677,7 +676,7 @@ struct SubsurfModifierData : ElemBase { }; // ------------------------------------------------------------------------------- -struct MirrorModifierData : ElemBase { +struct MirrorModifierData : SharedModifierData { enum Flags { Flags_CLIPPING = 1 << 0, @@ -689,8 +688,6 @@ struct MirrorModifierData : ElemBase { Flags_VGROUP = 1 << 6 }; - ModifierData modifier FAIL; - short axis, flag; float tolerance; std::shared_ptr mirror_ob; From 90d14644053b2704b0839f0ec61de678b1ee7608 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 9 Aug 2022 10:32:01 +0300 Subject: [PATCH 05/39] Remove set but unused variables --- code/AssetLib/LWO/LWOMaterial.cpp | 2 -- code/AssetLib/LWS/LWSLoader.cpp | 6 +----- code/AssetLib/Obj/ObjFileParser.cpp | 2 -- code/AssetLib/X3D/X3DImporter.cpp | 3 --- code/Common/ScenePreprocessor.cpp | 2 -- contrib/openddlparser/code/OpenDDLParser.cpp | 3 --- 6 files changed, 1 insertion(+), 17 deletions(-) diff --git a/code/AssetLib/LWO/LWOMaterial.cpp b/code/AssetLib/LWO/LWOMaterial.cpp index 4728706db..50bac884b 100644 --- a/code/AssetLib/LWO/LWOMaterial.cpp +++ b/code/AssetLib/LWO/LWOMaterial.cpp @@ -707,12 +707,10 @@ void LWOImporter::LoadNodalBlocks(unsigned int size) { if (mFileBuffer + head.length > end) { throw DeadlyImportError("LWO3: cannot read length; LoadNodalBlocks"); } - int node_idx = 0; uint8_t *const next = mFileBuffer + head.length; mFileBuffer += bufOffset; switch (head.type) { case AI_LWO_NNDS: - node_idx++; LoadNodes(head.length); break; } diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp index abaaaa305..0e29bb38f 100644 --- a/code/AssetLib/LWS/LWSLoader.cpp +++ b/code/AssetLib/LWS/LWSLoader.cpp @@ -516,7 +516,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy std::list nodes; unsigned int cur_light = 0, cur_camera = 0, cur_object = 0; - unsigned int num_light = 0, num_camera = 0, num_object = 0; + unsigned int num_light = 0, num_camera = 0; // check magic identifier, 'LWSC' bool motion_file = false; @@ -586,7 +586,6 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy d.id = batch.AddLoadRequest(path, 0, &props); nodes.push_back(d); - ++num_object; } else if ((*it).tokens[0] == "LoadObject") { // 'LoadObject': load a LWO file into the scene-graph // add node to list @@ -604,7 +603,6 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy d.path = path; nodes.push_back(d); - ++num_object; } else if ((*it).tokens[0] == "AddNullObject") { // 'AddNullObject': add a dummy node to the hierarchy // add node to list @@ -618,8 +616,6 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy } d.name = c; nodes.push_back(d); - - num_object++; } // 'NumChannels': Number of envelope channels assigned to last layer else if ((*it).tokens[0] == "NumChannels") { diff --git a/code/AssetLib/Obj/ObjFileParser.cpp b/code/AssetLib/Obj/ObjFileParser.cpp index 93f37bc6b..167cab544 100644 --- a/code/AssetLib/Obj/ObjFileParser.cpp +++ b/code/AssetLib/Obj/ObjFileParser.cpp @@ -112,7 +112,6 @@ ObjFile::Model *ObjFileParser::GetModel() const { void ObjFileParser::parseFile(IOStreamBuffer &streamBuffer) { // only update every 100KB or it'll be too slow //const unsigned int updateProgressEveryBytes = 100 * 1024; - unsigned int progressCounter = 0; const unsigned int bytesToProcess = static_cast(streamBuffer.size()); const unsigned int progressTotal = bytesToProcess; unsigned int processed = 0; @@ -129,7 +128,6 @@ void ObjFileParser::parseFile(IOStreamBuffer &streamBuffer) { if (lastFilePos < filePos) { processed = static_cast(filePos); lastFilePos = filePos; - progressCounter++; m_progress->UpdateFileRead(processed, progressTotal); } diff --git a/code/AssetLib/X3D/X3DImporter.cpp b/code/AssetLib/X3D/X3DImporter.cpp index 01c97eb4c..e28c9e5f3 100644 --- a/code/AssetLib/X3D/X3DImporter.cpp +++ b/code/AssetLib/X3D/X3DImporter.cpp @@ -477,9 +477,6 @@ void X3DImporter::ParseHelper_Node_Exit() { // check if we can walk up. if (mNodeElementCur != nullptr) { mNodeElementCur = mNodeElementCur->Parent; - } else { - int i = 0; - ++i; } } diff --git a/code/Common/ScenePreprocessor.cpp b/code/Common/ScenePreprocessor.cpp index 60133f651..c769ec30c 100644 --- a/code/Common/ScenePreprocessor.cpp +++ b/code/Common/ScenePreprocessor.cpp @@ -118,10 +118,8 @@ void ScenePreprocessor::ProcessMesh(aiMesh *mesh) { // as if they were 2D channels .. just in case an application doesn't handle // this case if (2 == mesh->mNumUVComponents[i]) { - size_t num = 0; for (; p != end; ++p) { p->z = 0.f; - num++; } } else if (1 == mesh->mNumUVComponents[i]) { for (; p != end; ++p) { diff --git a/contrib/openddlparser/code/OpenDDLParser.cpp b/contrib/openddlparser/code/OpenDDLParser.cpp index e2bef97a7..fe9d23ab5 100644 --- a/contrib/openddlparser/code/OpenDDLParser.cpp +++ b/contrib/openddlparser/code/OpenDDLParser.cpp @@ -647,12 +647,9 @@ char *OpenDDLParser::parseBooleanLiteral(char *in, char *end, Value **boolean) { in = lookForNextToken(in, end); char *start(in); - size_t len(0); while (!isSeparator(*in) && in != end) { ++in; - ++len; } - ++len; int res = ::strncmp(Grammar::BoolTrue, start, strlen(Grammar::BoolTrue)); if (0 != res) { res = ::strncmp(Grammar::BoolFalse, start, strlen(Grammar::BoolFalse)); From 56b644691340c6040670a9f8fe5f221e68cb4eeb Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 9 Aug 2022 11:12:53 +0300 Subject: [PATCH 06/39] Use weak pointer for MirrorModifierData mirror_ob to avoid memory leak --- code/AssetLib/Blender/BlenderModifier.cpp | 5 +++-- code/AssetLib/Blender/BlenderScene.cpp | 4 +++- code/AssetLib/Blender/BlenderScene.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/Blender/BlenderModifier.cpp b/code/AssetLib/Blender/BlenderModifier.cpp index 09bad0cfa..6cc11ec8e 100644 --- a/code/AssetLib/Blender/BlenderModifier.cpp +++ b/code/AssetLib/Blender/BlenderModifier.cpp @@ -153,6 +153,7 @@ void BlenderModifier_Mirror ::DoIt(aiNode &out, ConversionData &conv_data, const // hijacking the ABI, see the big note in BlenderModifierShowcase::ApplyModifiers() const MirrorModifierData &mir = static_cast(orig_modifier); ai_assert(mir.modifier.type == ModifierData::eModifierType_Mirror); + std::shared_ptr mirror_ob = mir.mirror_ob.lock(); conv_data.meshes->reserve(conv_data.meshes->size() + out.mNumMeshes); @@ -167,8 +168,8 @@ void BlenderModifier_Mirror ::DoIt(aiNode &out, ConversionData &conv_data, const const float ys = mir.flag & MirrorModifierData::Flags_AXIS_Y ? -1.f : 1.f; const float zs = mir.flag & MirrorModifierData::Flags_AXIS_Z ? -1.f : 1.f; - if (mir.mirror_ob) { - const aiVector3D center(mir.mirror_ob->obmat[3][0], mir.mirror_ob->obmat[3][1], mir.mirror_ob->obmat[3][2]); + if (mirror_ob) { + const aiVector3D center(mirror_ob->obmat[3][0], mirror_ob->obmat[3][1], mirror_ob->obmat[3][2]); for (unsigned int j = 0; j < mesh->mNumVertices; ++j) { aiVector3D &v = mesh->mVertices[j]; diff --git a/code/AssetLib/Blender/BlenderScene.cpp b/code/AssetLib/Blender/BlenderScene.cpp index 9ad086fe6..d458ede2e 100644 --- a/code/AssetLib/Blender/BlenderScene.cpp +++ b/code/AssetLib/Blender/BlenderScene.cpp @@ -772,7 +772,9 @@ void Structure ::Convert( ReadField(dest.axis, "axis", db); ReadField(dest.flag, "flag", db); ReadField(dest.tolerance, "tolerance", db); - ReadFieldPtr(dest.mirror_ob, "*mirror_ob", db); + std::shared_ptr mirror_ob; + ReadFieldPtr(mirror_ob, "*mirror_ob", db); + dest.mirror_ob = mirror_ob; db.reader->IncPtr(size); } diff --git a/code/AssetLib/Blender/BlenderScene.h b/code/AssetLib/Blender/BlenderScene.h index d44a7c470..479eae018 100644 --- a/code/AssetLib/Blender/BlenderScene.h +++ b/code/AssetLib/Blender/BlenderScene.h @@ -690,7 +690,7 @@ struct MirrorModifierData : SharedModifierData { short axis, flag; float tolerance; - std::shared_ptr mirror_ob; + std::weak_ptr mirror_ob; }; // ------------------------------------------------------------------------------- From 219dbbd4afc0eed61521369c5e4a5316c78e591e Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 9 Aug 2022 12:39:27 +0300 Subject: [PATCH 07/39] Fix crash of "assimp info" with no parameters --- tools/assimp_cmd/Info.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/assimp_cmd/Info.cpp b/tools/assimp_cmd/Info.cpp index 4703713c8..ef6554619 100644 --- a/tools/assimp_cmd/Info.cpp +++ b/tools/assimp_cmd/Info.cpp @@ -286,12 +286,6 @@ void PrintHierarchy( // ----------------------------------------------------------------------------------- // Implementation of the assimp info utility to print basic file info int Assimp_Info(const char *const *params, unsigned int num) { - // --help - if (!strcmp(params[0], "-h") || !strcmp(params[0], "--help") || !strcmp(params[0], "-?")) { - printf("%s", AICMD_MSG_INFO_HELP_E); - return AssimpCmdError::Success; - } - // asssimp info [-r] if (num < 1) { printf("assimp info: Invalid number of arguments. " @@ -299,6 +293,12 @@ int Assimp_Info(const char *const *params, unsigned int num) { return AssimpCmdError::InvalidNumberOfArguments; } + // --help + if (!strcmp(params[0], "-h") || !strcmp(params[0], "--help") || !strcmp(params[0], "-?")) { + printf("%s", AICMD_MSG_INFO_HELP_E); + return AssimpCmdError::Success; + } + const std::string in = std::string(params[0]); // get -r and -v arguments From 30555282fea98e334606f61ef0f28ef355580d63 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 9 Aug 2022 12:43:50 +0300 Subject: [PATCH 08/39] Use weak pointer for ElemBase last to avoid memory leak --- code/AssetLib/Blender/BlenderScene.cpp | 4 +++- code/AssetLib/Blender/BlenderScene.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/Blender/BlenderScene.cpp b/code/AssetLib/Blender/BlenderScene.cpp index d458ede2e..76582db76 100644 --- a/code/AssetLib/Blender/BlenderScene.cpp +++ b/code/AssetLib/Blender/BlenderScene.cpp @@ -624,7 +624,9 @@ void Structure ::Convert( const FileDatabase &db) const { ReadFieldPtr(dest.first, "*first", db); - ReadFieldPtr(dest.last, "*last", db); + std::shared_ptr last; + ReadFieldPtr(last, "*last", db); + dest.last = last; db.reader->IncPtr(size); } diff --git a/code/AssetLib/Blender/BlenderScene.h b/code/AssetLib/Blender/BlenderScene.h index 479eae018..c592db57f 100644 --- a/code/AssetLib/Blender/BlenderScene.h +++ b/code/AssetLib/Blender/BlenderScene.h @@ -124,7 +124,7 @@ struct ID : ElemBase { // ------------------------------------------------------------------------------- struct ListBase : ElemBase { std::shared_ptr first; - std::shared_ptr last; + std::weak_ptr last; }; // ------------------------------------------------------------------------------- From d2dc0401c3ebdf5b39c380855e4e9a1d40691f90 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 9 Aug 2022 12:47:11 +0300 Subject: [PATCH 09/39] Use weak pointer for ModifierData prev to avoid memory leak --- code/AssetLib/Blender/BlenderScene.cpp | 4 +++- code/AssetLib/Blender/BlenderScene.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/Blender/BlenderScene.cpp b/code/AssetLib/Blender/BlenderScene.cpp index 76582db76..b503cb8ff 100644 --- a/code/AssetLib/Blender/BlenderScene.cpp +++ b/code/AssetLib/Blender/BlenderScene.cpp @@ -650,7 +650,9 @@ void Structure ::Convert( const FileDatabase &db) const { ReadFieldPtr(dest.next, "*next", db); - ReadFieldPtr(dest.prev, "*prev", db); + std::shared_ptr prev; + ReadFieldPtr(prev, "*prev", db); + dest.prev = prev; ReadField(dest.type, "type", db); ReadField(dest.mode, "mode", db); ReadFieldArray(dest.name, "name", db); diff --git a/code/AssetLib/Blender/BlenderScene.h b/code/AssetLib/Blender/BlenderScene.h index c592db57f..436e47061 100644 --- a/code/AssetLib/Blender/BlenderScene.h +++ b/code/AssetLib/Blender/BlenderScene.h @@ -642,7 +642,7 @@ struct ModifierData : ElemBase { }; std::shared_ptr next WARN; - std::shared_ptr prev WARN; + std::weak_ptr prev WARN; int type, mode; char name[32]; From 1c59de42fcb62207b5659e96c9c4b11c2da24df4 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 9 Aug 2022 12:41:46 +0300 Subject: [PATCH 10/39] Make some blender fields warn if missing instead of error --- code/AssetLib/Blender/BlenderScene.cpp | 6 +-- test/unit/utBlenderImportExport.cpp | 51 +++++++++----------------- 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/code/AssetLib/Blender/BlenderScene.cpp b/code/AssetLib/Blender/BlenderScene.cpp index b503cb8ff..3a9a02fd0 100644 --- a/code/AssetLib/Blender/BlenderScene.cpp +++ b/code/AssetLib/Blender/BlenderScene.cpp @@ -839,9 +839,9 @@ void Structure::Convert( ReadField(dest.flag, "flag", db); ReadField(dest.active, "active", db); ReadField(dest.active_rnd, "active_rnd", db); - ReadField(dest.active_clone, "active_clone", db); - ReadField(dest.active_mask, "active_mask", db); - ReadField(dest.uid, "uid", db); + ReadField(dest.active_clone, "active_clone", db); + ReadField(dest.active_mask, "active_mask", db); + ReadField(dest.uid, "uid", db); ReadFieldArray(dest.name, "name", db); ReadCustomDataPtr(dest.data, dest.type, "*data", db); diff --git a/test/unit/utBlenderImportExport.cpp b/test/unit/utBlenderImportExport.cpp index 297098672..c9cce72b4 100644 --- a/test/unit/utBlenderImportExport.cpp +++ b/test/unit/utBlenderImportExport.cpp @@ -64,8 +64,7 @@ TEST_F(utBlenderImporterExporter, importBlenFromFileTest) { TEST(utBlenderImporter, import4cubes) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/4Cubes4Mats_248.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, import269_regress1) { @@ -77,22 +76,19 @@ TEST(utBlenderImporter, import269_regress1) { TEST(utBlenderImporter, importBlenderDefault248) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_248.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importBlenderDefault250) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importBlenderDefault250Compressed) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250_Compressed.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importBlenderDefault262) { @@ -123,92 +119,79 @@ TEST(utBlenderImporter, importBlenderDefault293) { TEST(utBlenderImporter, importCubeHierarchy_248) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/CubeHierarchy_248.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importHuman) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/HUMAN.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importMirroredCube_252) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/MirroredCube_252.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importNoisyTexturedCube_VoronoiGlob_248) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/NoisyTexturedCube_VoronoiGlob_248.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importSmoothVsSolidCube_248) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SmoothVsSolidCube_248.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importSuzanne_248) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/Suzanne_248.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importSuzanneSubdiv_252) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SuzanneSubdiv_252.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importTexturedCube_ImageGlob_248) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedCube_ImageGlob_248.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importTexturedPlane_ImageUv_248) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUv_248.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importTexturedPlane_ImageUvPacked_248) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUvPacked_248.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importTorusLightsCams_250_compressed) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TorusLightsCams_250_compressed.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, import_yxa_1) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/yxa_1.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importBob) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/Bob.blend", aiProcess_ValidateDataStructure); - // FIXME: this is probably not right, loading this should succeed - ASSERT_EQ(nullptr, scene); + ASSERT_NE(nullptr, scene); } TEST(utBlenderImporter, importFleurOptonl) { From 2013ae114a089ce67a73d2108fbb0dc0317a4084 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 18 Aug 2022 17:41:07 +0200 Subject: [PATCH 11/39] [WIP] Use ai_Real to write correct accuracy - closes https://github.com/assimp/assimp/issues/4676 --- code/AssetLib/Assbin/AssbinFileWriter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/AssetLib/Assbin/AssbinFileWriter.cpp b/code/AssetLib/Assbin/AssbinFileWriter.cpp index 1d16f179e..d1388cde6 100644 --- a/code/AssetLib/Assbin/AssbinFileWriter.cpp +++ b/code/AssetLib/Assbin/AssbinFileWriter.cpp @@ -130,7 +130,7 @@ inline size_t Write(IOStream *stream, const double &f) { // Serialize a vec3 template <> inline size_t Write(IOStream *stream, const aiVector3D &v) { - size_t t = Write(stream, v.x); + size_t t = Write(stream, v.x); t += Write(stream, v.y); t += Write(stream, v.z); @@ -141,7 +141,7 @@ inline size_t Write(IOStream *stream, const aiVector3D &v) { // Serialize a color value template <> inline size_t Write(IOStream *stream, const aiColor3D &v) { - size_t t = Write(stream, v.r); + size_t t = Write(stream, v.r); t += Write(stream, v.g); t += Write(stream, v.b); @@ -152,7 +152,7 @@ inline size_t Write(IOStream *stream, const aiColor3D &v) { // Serialize a color value template <> inline size_t Write(IOStream *stream, const aiColor4D &v) { - size_t t = Write(stream, v.r); + size_t t = Write(stream, v.r); t += Write(stream, v.g); t += Write(stream, v.b); t += Write(stream, v.a); @@ -164,7 +164,7 @@ inline size_t Write(IOStream *stream, const aiColor4D &v) { // Serialize a quaternion template <> inline size_t Write(IOStream *stream, const aiQuaternion &v) { - size_t t = Write(stream, v.w); + size_t t = Write(stream, v.w); t += Write(stream, v.x); t += Write(stream, v.y); t += Write(stream, v.z); @@ -190,7 +190,7 @@ template <> inline size_t Write(IOStream *stream, const aiMatrix4x4 &m) { for (unsigned int i = 0; i < 4; ++i) { for (unsigned int i2 = 0; i2 < 4; ++i2) { - Write(stream, m[i][i2]); + Write(stream, m[i][i2]); } } From 5f28c51c03dd07ce94d6c41427a61c503ef2567d Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 23 Aug 2022 13:59:42 +0300 Subject: [PATCH 12/39] Apply clang-tidy modernize-loop-convert transformation --- code/AssetLib/SMD/SMDLoader.cpp | 42 +++++++++++++-------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index 46fd968c8..f8b760f74 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -147,10 +147,8 @@ void SMDImporter::InternReadFile( const std::string& pFile, aiScene* scene, IOSy if (!asBones.empty()) { // Check whether all bones have been initialized - for (std::vector::const_iterator - i = asBones.begin(); - i != asBones.end();++i) { - if (!(*i).mName.length()) { + for (const auto &asBone : asBones) { + if (!asBone.mName.length()) { ASSIMP_LOG_WARN("SMD: Not all bones have been initialized"); break; } @@ -210,12 +208,10 @@ void SMDImporter::LogWarning(const char* msg) { void SMDImporter::FixTimeValues() { double dDelta = (double)iSmallestFrame; double dMax = 0.0f; - for (std::vector::iterator - iBone = asBones.begin(); - iBone != asBones.end();++iBone) { + for (auto &asBone : asBones) { for (std::vector::iterator - iKey = (*iBone).sAnim.asKeys.begin(); - iKey != (*iBone).sAnim.asKeys.end();++iKey) { + iKey = asBone.sAnim.asKeys.begin(); + iKey != asBone.sAnim.asKeys.end();++iKey) { (*iKey).dTime -= dDelta; dMax = std::max(dMax, (*iKey).dTime); } @@ -351,8 +347,7 @@ void SMDImporter::CreateOutputMeshes() { if (fSum) { fSum = 1 / fSum; - for (unsigned int iBone = 0;iBone < face.avVertices[iVert].aiBoneLinks.size();++iBone) { - TempWeightListEntry& pairval = face.avVertices[iVert].aiBoneLinks[iBone]; + for (auto &pairval : face.avVertices[iVert].aiBoneLinks) { if (pairval.first >= asBones.size()) { continue; } @@ -411,8 +406,7 @@ void SMDImporter::AddBoneChildren(aiNode* pcNode, uint32_t iParent) { ai_assert( nullptr == pcNode->mChildren); // first count ... - for (unsigned int i = 0; i < asBones.size();++i) { - SMD::Bone& bone = asBones[i]; + for (auto &bone : asBones) { if (bone.iParent == iParent) { ++pcNode->mNumChildren; } @@ -516,21 +510,21 @@ void SMDImporter::CreateOutputAnimation(int index, const std::string &name) { // now build valid keys unsigned int a = 0; - for (std::vector::const_iterator i = asBones.begin(); i != asBones.end(); ++i) { + for (const auto &asBone : asBones) { aiNodeAnim* p = pp[a] = new aiNodeAnim(); // copy the name of the bone - p->mNodeName.Set(i->mName); + p->mNodeName.Set(asBone.mName); - p->mNumRotationKeys = (unsigned int)(*i).sAnim.asKeys.size(); + p->mNumRotationKeys = (unsigned int)asBone.sAnim.asKeys.size(); if (p->mNumRotationKeys){ p->mNumPositionKeys = p->mNumRotationKeys; aiVectorKey* pVecKeys = p->mPositionKeys = new aiVectorKey[p->mNumRotationKeys]; aiQuatKey* pRotKeys = p->mRotationKeys = new aiQuatKey[p->mNumRotationKeys]; for (std::vector::const_iterator - qq = (*i).sAnim.asKeys.begin(); - qq != (*i).sAnim.asKeys.end(); ++qq) { + qq = asBone.sAnim.asKeys.begin(); + qq != asBone.sAnim.asKeys.end(); ++qq) { pRotKeys->mTime = pVecKeys->mTime = (*qq).dTime; // compute the rotation quaternion from the euler angles @@ -982,8 +976,8 @@ void SMDImporter::ParseTriangle(const char* szCurrent, const char** szCurrentOut SkipSpacesAndLineEnd(szCurrent,&szCurrent); // load three vertices - for (unsigned int iVert = 0; iVert < 3;++iVert) { - ParseVertex(szCurrent,&szCurrent, face.avVertices[iVert]); + for (auto &avVertex : face.avVertices) { + ParseVertex(szCurrent,&szCurrent, avVertex); } *szCurrentOut = szCurrent; } @@ -1080,13 +1074,11 @@ void SMDImporter::ParseVertex(const char* szCurrent, } vertex.aiBoneLinks.resize(iSize,std::pair(0,0.0f)); - for (std::vector >::iterator - i = vertex.aiBoneLinks.begin(); - i != vertex.aiBoneLinks.end();++i) { - if(!ParseUnsignedInt(szCurrent,&szCurrent,(*i).first)) { + for (auto &aiBoneLink : vertex.aiBoneLinks) { + if(!ParseUnsignedInt(szCurrent,&szCurrent,aiBoneLink.first)) { SMDI_PARSE_RETURN; } - if(!ParseFloat(szCurrent,&szCurrent,(*i).second)) { + if(!ParseFloat(szCurrent,&szCurrent,aiBoneLink.second)) { SMDI_PARSE_RETURN; } } From 712671e81a51e4f778c42b23362700a6fb4fb85e Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 23 Aug 2022 14:02:36 +0300 Subject: [PATCH 13/39] Apply modernize-loop-convert again --- code/AssetLib/SMD/SMDLoader.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index f8b760f74..97637b20a 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -209,11 +209,9 @@ void SMDImporter::FixTimeValues() { double dDelta = (double)iSmallestFrame; double dMax = 0.0f; for (auto &asBone : asBones) { - for (std::vector::iterator - iKey = asBone.sAnim.asKeys.begin(); - iKey != asBone.sAnim.asKeys.end();++iKey) { - (*iKey).dTime -= dDelta; - dMax = std::max(dMax, (*iKey).dTime); + for (auto &asKey : asBone.sAnim.asKeys) { + asKey.dTime -= dDelta; + dMax = std::max(dMax, asKey.dTime); } } dLengthOfAnim = dMax; @@ -522,15 +520,13 @@ void SMDImporter::CreateOutputAnimation(int index, const std::string &name) { aiVectorKey* pVecKeys = p->mPositionKeys = new aiVectorKey[p->mNumRotationKeys]; aiQuatKey* pRotKeys = p->mRotationKeys = new aiQuatKey[p->mNumRotationKeys]; - for (std::vector::const_iterator - qq = asBone.sAnim.asKeys.begin(); - qq != asBone.sAnim.asKeys.end(); ++qq) { - pRotKeys->mTime = pVecKeys->mTime = (*qq).dTime; + for (const auto &asKey : asBone.sAnim.asKeys) { + pRotKeys->mTime = pVecKeys->mTime = asKey.dTime; // compute the rotation quaternion from the euler angles // aiQuaternion: The order of the parameters is yzx? - pRotKeys->mValue = aiQuaternion((*qq).vRot.y, (*qq).vRot.z, (*qq).vRot.x); - pVecKeys->mValue = (*qq).vPos; + pRotKeys->mValue = aiQuaternion(asKey.vRot.y, asKey.vRot.z, asKey.vRot.x); + pVecKeys->mValue = asKey.vPos; ++pVecKeys; ++pRotKeys; } From 1ca44acebcdc7fae599eb1ae9e038ba4264b1707 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 23 Aug 2022 14:03:48 +0300 Subject: [PATCH 14/39] Simplify a for loop --- code/AssetLib/SMD/SMDLoader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index 97637b20a..4ff6234c2 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -244,7 +244,7 @@ void SMDImporter::CreateOutputMeshes() { iNum = 0; for (std::vector::const_iterator iFace = asTriangles.begin(); - iFace != asTriangles.end();++iFace,++iNum) { + iFace != asTriangles.end(); ++iFace) { if (UINT_MAX == (*iFace).iTexture) { aaiFaces[(*iFace).iTexture].push_back( 0 ); } else if ((*iFace).iTexture >= aszTextures.size()) { @@ -253,6 +253,7 @@ void SMDImporter::CreateOutputMeshes() { } else { aaiFaces[(*iFace).iTexture].push_back(iNum); } + ++iNum; } // now create the output meshes From 795c0abcc865f139daf5e44cb89e54bf8b110673 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 23 Aug 2022 14:10:00 +0300 Subject: [PATCH 15/39] Apply modernize-loop-convert to the simplified loop --- code/AssetLib/SMD/SMDLoader.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index 4ff6234c2..1a860568a 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -242,16 +242,14 @@ void SMDImporter::CreateOutputMeshes() { // collect all faces iNum = 0; - for (std::vector::const_iterator - iFace = asTriangles.begin(); - iFace != asTriangles.end(); ++iFace) { - if (UINT_MAX == (*iFace).iTexture) { - aaiFaces[(*iFace).iTexture].push_back( 0 ); - } else if ((*iFace).iTexture >= aszTextures.size()) { + for (const auto &asTriangle : asTriangles) { + if (UINT_MAX == asTriangle.iTexture) { + aaiFaces[asTriangle.iTexture].push_back( 0 ); + } else if (asTriangle.iTexture >= aszTextures.size()) { ASSIMP_LOG_INFO("[SMD/VTA] Material index overflow in face"); - aaiFaces[(*iFace).iTexture].push_back((unsigned int)aszTextures.size()-1); + aaiFaces[asTriangle.iTexture].push_back((unsigned int)aszTextures.size()-1); } else { - aaiFaces[(*iFace).iTexture].push_back(iNum); + aaiFaces[asTriangle.iTexture].push_back(iNum); } ++iNum; } From 03397d42e2dc5fb29d4fc374086daebfe38be21a Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 23 Aug 2022 14:15:06 +0300 Subject: [PATCH 16/39] Use unique_ptr for aaiFaces instead of explicit delete[] --- code/AssetLib/SMD/SMDLoader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index 1a860568a..2a43aab09 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -231,7 +231,7 @@ void SMDImporter::CreateOutputMeshes() { pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; typedef std::vector FaceList; - FaceList* aaiFaces = new FaceList[pScene->mNumMeshes]; + std::unique_ptr aaiFaces(new FaceList[pScene->mNumMeshes]); // approximate the space that will be required unsigned int iNum = (unsigned int)asTriangles.size() / pScene->mNumMeshes; @@ -392,7 +392,6 @@ void SMDImporter::CreateOutputMeshes() { } delete[] aaiBones; } - delete[] aaiFaces; } // ------------------------------------------------------------------------------------------------ From 68bc6a06b93ee2881ed4b62dbe7f29294743d33e Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 23 Aug 2022 14:17:56 +0300 Subject: [PATCH 17/39] Use unique_ptr for aaiBones instead of explicit delete[] --- code/AssetLib/SMD/SMDLoader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index 2a43aab09..78ff397b7 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -268,7 +268,7 @@ void SMDImporter::CreateOutputMeshes() { typedef std::pair TempWeightListEntry; typedef std::vector< TempWeightListEntry > TempBoneWeightList; - TempBoneWeightList* aaiBones = new TempBoneWeightList[asBones.size()](); + std::unique_ptr aaiBones(new TempBoneWeightList[asBones.size()]()); // try to reserve enough memory without wasting too much for (unsigned int iBone = 0; iBone < asBones.size();++iBone) { @@ -390,7 +390,6 @@ void SMDImporter::CreateOutputMeshes() { ++iNum; } } - delete[] aaiBones; } } From f890bc791fc055d25788f9fdeda5fc3e0097924a Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 23 Aug 2022 14:38:27 +0300 Subject: [PATCH 18/39] Fix out of bounds write --- code/AssetLib/SMD/SMDLoader.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index 78ff397b7..686851c92 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -243,9 +243,7 @@ void SMDImporter::CreateOutputMeshes() { // collect all faces iNum = 0; for (const auto &asTriangle : asTriangles) { - if (UINT_MAX == asTriangle.iTexture) { - aaiFaces[asTriangle.iTexture].push_back( 0 ); - } else if (asTriangle.iTexture >= aszTextures.size()) { + if (asTriangle.iTexture >= aszTextures.size()) { ASSIMP_LOG_INFO("[SMD/VTA] Material index overflow in face"); aaiFaces[asTriangle.iTexture].push_back((unsigned int)aszTextures.size()-1); } else { From 27edb436004e06c844a15c9282d6888402017992 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Tue, 23 Aug 2022 11:41:49 -0400 Subject: [PATCH 19/39] Apply modernize-use-emplace clang-tidy rule --- code/AssetLib/3DS/3DSLoader.cpp | 6 +- code/AssetLib/AC/ACLoader.cpp | 12 ++-- code/AssetLib/ASE/ASELoader.cpp | 6 +- code/AssetLib/ASE/ASEParser.cpp | 18 ++--- code/AssetLib/Assjson/mesh_splitter.cpp | 2 +- code/AssetLib/B3D/B3DImporter.cpp | 6 +- code/AssetLib/BVH/BVHLoader.cpp | 2 +- code/AssetLib/COB/COBLoader.cpp | 6 +- code/AssetLib/Collada/ColladaExporter.cpp | 4 +- code/AssetLib/Collada/ColladaParser.cpp | 16 ++--- code/AssetLib/DXF/DXFLoader.cpp | 6 +- code/AssetLib/FBX/FBXConverter.cpp | 2 +- code/AssetLib/FBX/FBXParser.cpp | 18 ++--- code/AssetLib/IFC/IFCBoolean.cpp | 6 +- code/AssetLib/IFC/IFCCurve.cpp | 2 +- code/AssetLib/IFC/IFCGeometry.cpp | 4 +- code/AssetLib/IFC/IFCOpenings.cpp | 38 +++++------ code/AssetLib/IFC/IFCProfile.cpp | 34 ++++----- code/AssetLib/IFC/IFCUtil.cpp | 4 +- code/AssetLib/Irr/IRRLoader.cpp | 8 +-- code/AssetLib/LWO/LWOLoader.cpp | 4 +- code/AssetLib/LWS/LWSLoader.cpp | 10 +-- code/AssetLib/MD3/MD3Loader.cpp | 12 ++-- code/AssetLib/MDC/MDCLoader.cpp | 6 +- code/AssetLib/MS3D/MS3DLoader.cpp | 2 +- code/AssetLib/NDO/NDOLoader.cpp | 6 +- code/AssetLib/NFF/NFFLoader.cpp | 24 +++---- code/AssetLib/Obj/ObjExporter.cpp | 2 +- code/AssetLib/Obj/ObjFileParser.cpp | 2 +- code/AssetLib/Ogre/OgreStructs.cpp | 2 +- code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp | 6 +- code/AssetLib/Q3D/Q3DLoader.cpp | 8 +-- code/AssetLib/Raw/RawLoader.cpp | 16 ++--- code/AssetLib/SMD/SMDLoader.cpp | 10 +-- code/AssetLib/Unreal/UnrealLoader.cpp | 4 +- code/AssetLib/X/XFileImporter.cpp | 2 +- code/AssetLib/X/XFileParser.cpp | 8 +-- code/AssetLib/X3D/X3DExporter.cpp | 72 ++++++++++---------- code/AssetLib/X3D/X3DGeoHelper.cpp | 8 +-- code/AssetLib/X3D/X3DImporter_Geometry2D.cpp | 16 ++--- code/Common/Exporter.cpp | 68 +++++++++--------- code/Common/SGSpatialSort.cpp | 4 +- code/Common/SceneCombiner.cpp | 8 +-- code/Common/SkeletonMeshBuilder.cpp | 72 ++++++++++---------- code/Common/SpatialSort.cpp | 2 +- code/Common/StandardShapes.cpp | 18 ++--- code/PostProcessing/ProcessHelper.cpp | 2 +- code/PostProcessing/SplitLargeMeshes.cpp | 10 +-- 48 files changed, 302 insertions(+), 302 deletions(-) diff --git a/code/AssetLib/3DS/3DSLoader.cpp b/code/AssetLib/3DS/3DSLoader.cpp index b76640218..e6bc3a171 100644 --- a/code/AssetLib/3DS/3DSLoader.cpp +++ b/code/AssetLib/3DS/3DSLoader.cpp @@ -319,7 +319,7 @@ void Discreet3DSImporter::ParseObjectChunk() { case Discreet3DS::CHUNK_MAT_MATERIAL: // Add a new material to the list - mScene->mMaterials.push_back(D3DS::Material(std::string("UNNAMED_" + ai_to_string(mScene->mMaterials.size())))); + mScene->mMaterials.emplace_back(std::string("UNNAMED_" + ai_to_string(mScene->mMaterials.size()))); ParseMaterialChunk(); break; @@ -370,7 +370,7 @@ void Discreet3DSImporter::ParseChunk(const char *name, unsigned int num) { switch (chunk.Flag) { case Discreet3DS::CHUNK_TRIMESH: { // this starts a new triangle mesh - mScene->mMeshes.push_back(D3DS::Mesh(std::string(name, num))); + mScene->mMeshes.emplace_back(std::string(name, num)); // Read mesh chunks ParseMeshChunk(); @@ -999,7 +999,7 @@ void Discreet3DSImporter::ParseMeshChunk() { mMesh.mFaces.reserve(num); while (num-- > 0) { // 3DS faces are ALWAYS triangles - mMesh.mFaces.push_back(D3DS::Face()); + mMesh.mFaces.emplace_back(); D3DS::Face &sFace = mMesh.mFaces.back(); sFace.mIndices[0] = (uint16_t)stream->GetI2(); diff --git a/code/AssetLib/AC/ACLoader.cpp b/code/AssetLib/AC/ACLoader.cpp index e93624b3e..410e04c2a 100644 --- a/code/AssetLib/AC/ACLoader.cpp +++ b/code/AssetLib/AC/ACLoader.cpp @@ -180,7 +180,7 @@ void AC3DImporter::LoadObjectSection(std::vector &objects) { ++mNumMeshes; - objects.push_back(Object()); + objects.emplace_back(); Object &obj = objects.back(); aiLight *light = nullptr; @@ -267,7 +267,7 @@ void AC3DImporter::LoadObjectSection(std::vector &objects) { --buffer; // make sure the line is processed a second time break; } - obj.vertices.push_back(aiVector3D()); + obj.vertices.emplace_back(); aiVector3D &v = obj.vertices.back(); buffer = TAcCheckedLoadFloatArray(buffer, "", 0, 3, &v.x); } @@ -293,7 +293,7 @@ void AC3DImporter::LoadObjectSection(std::vector &objects) { Q3DWorkAround = true; } SkipSpaces(&buffer); - obj.surfaces.push_back(Surface()); + obj.surfaces.emplace_back(); Surface &surf = obj.surfaces.back(); surf.flags = strtoul_cppstyle(buffer); @@ -324,7 +324,7 @@ void AC3DImporter::LoadObjectSection(std::vector &objects) { ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: surface references are incomplete"); break; } - surf.entries.push_back(Surface::SurfaceEntry()); + surf.entries.emplace_back(); Surface::SurfaceEntry &entry = surf.entries.back(); entry.first = strtoul10(buffer, &buffer); @@ -786,7 +786,7 @@ void AC3DImporter::InternReadFile(const std::string &pFile, while (GetNextLine()) { if (TokenMatch(buffer, "MATERIAL", 8)) { - materials.push_back(Material()); + materials.emplace_back(); Material &mat = materials.back(); // manually parse the material ... sscanf would use the buldin atof ... @@ -813,7 +813,7 @@ void AC3DImporter::InternReadFile(const std::string &pFile, } if (materials.empty()) { ASSIMP_LOG_WARN("AC3D: No material has been found"); - materials.push_back(Material()); + materials.emplace_back(); } mNumMeshes += (mNumMeshes >> 2u) + 1; diff --git a/code/AssetLib/ASE/ASELoader.cpp b/code/AssetLib/ASE/ASELoader.cpp index 7caac24ce..41f5639b5 100644 --- a/code/AssetLib/ASE/ASELoader.cpp +++ b/code/AssetLib/ASE/ASELoader.cpp @@ -265,7 +265,7 @@ void ASEImporter::GenerateDefaultMaterial() { } if (bHas || mParser->m_vMaterials.empty()) { // add a simple material without submaterials to the parser's list - mParser->m_vMaterials.push_back(ASE::Material(AI_DEFAULT_MATERIAL_NAME)); + mParser->m_vMaterials.emplace_back(AI_DEFAULT_MATERIAL_NAME); ASE::Material &mat = mParser->m_vMaterials.back(); mat.mDiffuse = aiColor3D(0.6f, 0.6f, 0.6f); @@ -1005,8 +1005,8 @@ void ASEImporter::ConvertMeshes(ASE::Mesh &mesh, std::vector &avOutMes blubb != mesh.mBoneVertices[iIndex2].mBoneWeights.end(); ++blubb) { // NOTE: illegal cases have already been filtered out - avOutputBones[(*blubb).first].push_back(std::pair( - iBase, (*blubb).second)); + avOutputBones[(*blubb).first].emplace_back( + iBase, (*blubb).second); } } } diff --git a/code/AssetLib/ASE/ASEParser.cpp b/code/AssetLib/ASE/ASEParser.cpp index af90f9dd4..96346bdcb 100644 --- a/code/AssetLib/ASE/ASEParser.cpp +++ b/code/AssetLib/ASE/ASEParser.cpp @@ -264,7 +264,7 @@ void Parser::Parse() { if (TokenMatch(filePtr, "GEOMOBJECT", 10)) { - m_vMeshes.push_back(Mesh("UNNAMED")); + m_vMeshes.emplace_back("UNNAMED"); ParseLV1ObjectBlock(m_vMeshes.back()); continue; } @@ -272,7 +272,7 @@ void Parser::Parse() { if (TokenMatch(filePtr, "HELPEROBJECT", 12)) { - m_vDummies.push_back(Dummy()); + m_vDummies.emplace_back(); ParseLV1ObjectBlock(m_vDummies.back()); continue; } @@ -280,13 +280,13 @@ void Parser::Parse() { if (TokenMatch(filePtr, "LIGHTOBJECT", 11)) { - m_vLights.push_back(Light("UNNAMED")); + m_vLights.emplace_back("UNNAMED"); ParseLV1ObjectBlock(m_vLights.back()); continue; } // camera object if (TokenMatch(filePtr, "CAMERAOBJECT", 12)) { - m_vCameras.push_back(Camera("UNNAMED")); + m_vCameras.emplace_back("UNNAMED"); ParseLV1ObjectBlock(m_vCameras.back()); continue; } @@ -385,7 +385,7 @@ void Parser::ParseLV1SoftSkinBlock() { unsigned int numWeights; ParseLV4MeshLong(numWeights); - curMesh->mBoneVertices.push_back(ASE::BoneVertex()); + curMesh->mBoneVertices.emplace_back(); ASE::BoneVertex &vert = curMesh->mBoneVertices.back(); // Reserve enough storage @@ -409,7 +409,7 @@ void Parser::ParseLV1SoftSkinBlock() { if (-1 == me.first) { // We don't have this bone yet, so add it to the list me.first = static_cast(curMesh->mBones.size()); - curMesh->mBones.push_back(ASE::Bone(bone)); + curMesh->mBones.emplace_back(bone); } ParseLV4MeshFloat(me.second); @@ -1011,7 +1011,7 @@ void Parser::ParseLV3ScaleAnimationBlock(ASE::Animation &anim) { anim.mScalingType = ASE::Animation::TCB; } if (b) { - anim.akeyScaling.push_back(aiVectorKey()); + anim.akeyScaling.emplace_back(); aiVectorKey &key = anim.akeyScaling.back(); ParseLV4MeshFloatTriple(&key.mValue.x, iIndex); key.mTime = (double)iIndex; @@ -1050,7 +1050,7 @@ void Parser::ParseLV3PosAnimationBlock(ASE::Animation &anim) { anim.mPositionType = ASE::Animation::TCB; } if (b) { - anim.akeyPositions.push_back(aiVectorKey()); + anim.akeyPositions.emplace_back(); aiVectorKey &key = anim.akeyPositions.back(); ParseLV4MeshFloatTriple(&key.mValue.x, iIndex); key.mTime = (double)iIndex; @@ -1089,7 +1089,7 @@ void Parser::ParseLV3RotAnimationBlock(ASE::Animation &anim) { anim.mRotationType = ASE::Animation::TCB; } if (b) { - anim.akeyRotations.push_back(aiQuatKey()); + anim.akeyRotations.emplace_back(); aiQuatKey &key = anim.akeyRotations.back(); aiVector3D v; ai_real f; diff --git a/code/AssetLib/Assjson/mesh_splitter.cpp b/code/AssetLib/Assjson/mesh_splitter.cpp index 978437c41..a35bb5b82 100644 --- a/code/AssetLib/Assjson/mesh_splitter.cpp +++ b/code/AssetLib/Assjson/mesh_splitter.cpp @@ -304,7 +304,7 @@ void MeshSplitter :: SplitMesh(unsigned int a, aiMesh* in_mesh, std::vectormNumFaces) { break; diff --git a/code/AssetLib/B3D/B3DImporter.cpp b/code/AssetLib/B3D/B3DImporter.cpp index c4ef75be3..b572a61e4 100644 --- a/code/AssetLib/B3D/B3DImporter.cpp +++ b/code/AssetLib/B3D/B3DImporter.cpp @@ -479,13 +479,13 @@ void B3DImporter::ReadKEYS(aiNodeAnim *nodeAnim) { while (ChunkSize()) { int frame = ReadInt(); if (flags & 1) { - trans.push_back(aiVectorKey(frame, ReadVec3())); + trans.emplace_back(frame, ReadVec3()); } if (flags & 2) { - scale.push_back(aiVectorKey(frame, ReadVec3())); + scale.emplace_back(frame, ReadVec3()); } if (flags & 4) { - rot.push_back(aiQuatKey(frame, ReadQuat())); + rot.emplace_back(frame, ReadQuat()); } } diff --git a/code/AssetLib/BVH/BVHLoader.cpp b/code/AssetLib/BVH/BVHLoader.cpp index 174836847..0b9e286b7 100644 --- a/code/AssetLib/BVH/BVHLoader.cpp +++ b/code/AssetLib/BVH/BVHLoader.cpp @@ -186,7 +186,7 @@ aiNode *BVHLoader::ReadNode() { std::vector childNodes; // and create an bone entry for it - mNodes.push_back(Node(node)); + mNodes.emplace_back(node); Node &internNode = mNodes.back(); // now read the node's contents diff --git a/code/AssetLib/COB/COBLoader.cpp b/code/AssetLib/COB/COBLoader.cpp index 1c8310061..687f1cbd0 100644 --- a/code/AssetLib/COB/COBLoader.cpp +++ b/code/AssetLib/COB/COBLoader.cpp @@ -753,7 +753,7 @@ void COBImporter::ReadPolH_Ascii(Scene &out, LineSplitter &splitter, const Chunk ThrowException("Expected Face line"); } - msh.faces.push_back(Face()); + msh.faces.emplace_back(); Face &face = msh.faces.back(); face.indices.resize(strtoul10(splitter[2])); @@ -956,7 +956,7 @@ void COBImporter::ReadPolH_Binary(COB::Scene &out, StreamReaderLE &reader, const ThrowException(format("A hole is the first entity in the `PolH` chunk with id ") << nfo.id); } } else - msh.faces.push_back(Face()); + msh.faces.emplace_back(); Face &f = msh.faces.back(); const size_t num = reader.GetI2(); @@ -968,7 +968,7 @@ void COBImporter::ReadPolH_Binary(COB::Scene &out, StreamReaderLE &reader, const } for (size_t x = 0; x < num; ++x) { - f.indices.push_back(VertexIndex()); + f.indices.emplace_back(); VertexIndex &v = f.indices.back(); v.pos_idx = reader.GetI4(); diff --git a/code/AssetLib/Collada/ColladaExporter.cpp b/code/AssetLib/Collada/ColladaExporter.cpp index 5c91daa1a..7a620fd53 100644 --- a/code/AssetLib/Collada/ColladaExporter.cpp +++ b/code/AssetLib/Collada/ColladaExporter.cpp @@ -1330,9 +1330,9 @@ void ColladaExporter::WriteAnimationLibrary(size_t pIndex) { std::vector names; for (size_t i = 0; i < nodeAnim->mNumPositionKeys; ++i) { if (nodeAnim->mPreState == aiAnimBehaviour_DEFAULT || nodeAnim->mPreState == aiAnimBehaviour_LINEAR || nodeAnim->mPreState == aiAnimBehaviour_REPEAT) { - names.push_back("LINEAR"); + names.emplace_back("LINEAR"); } else if (nodeAnim->mPostState == aiAnimBehaviour_CONSTANT) { - names.push_back("STEP"); + names.emplace_back("STEP"); } } diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 52e9b4978..fd2662ddb 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -1929,7 +1929,7 @@ void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, siz switch (pInput.mType) { case IT_Position: // ignore all position streams except 0 - there can be only one position if (pInput.mIndex == 0) { - pMesh.mPositions.push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mPositions.emplace_back(obj[0], obj[1], obj[2]); } else { ASSIMP_LOG_ERROR("Collada: just one vertex position stream supported"); } @@ -1941,7 +1941,7 @@ void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, siz // ignore all normal streams except 0 - there can be only one normal if (pInput.mIndex == 0) { - pMesh.mNormals.push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mNormals.emplace_back(obj[0], obj[1], obj[2]); } else { ASSIMP_LOG_ERROR("Collada: just one vertex normal stream supported"); } @@ -1953,7 +1953,7 @@ void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, siz // ignore all tangent streams except 0 - there can be only one tangent if (pInput.mIndex == 0) { - pMesh.mTangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mTangents.emplace_back(obj[0], obj[1], obj[2]); } else { ASSIMP_LOG_ERROR("Collada: just one vertex tangent stream supported"); } @@ -1966,7 +1966,7 @@ void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, siz // ignore all bitangent streams except 0 - there can be only one bitangent if (pInput.mIndex == 0) { - pMesh.mBitangents.push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mBitangents.emplace_back(obj[0], obj[1], obj[2]); } else { ASSIMP_LOG_ERROR("Collada: just one vertex bitangent stream supported"); } @@ -1979,7 +1979,7 @@ void ColladaParser::ExtractDataObjectFromChannel(const InputChannel &pInput, siz pMesh.mTexCoords[pInput.mIndex].insert(pMesh.mTexCoords[pInput.mIndex].end(), pMesh.mPositions.size() - pMesh.mTexCoords[pInput.mIndex].size() - 1, aiVector3D(0, 0, 0)); - pMesh.mTexCoords[pInput.mIndex].push_back(aiVector3D(obj[0], obj[1], obj[2])); + pMesh.mTexCoords[pInput.mIndex].emplace_back(obj[0], obj[1], obj[2]); if (0 != acc.mSubOffset[2] || 0 != acc.mSubOffset[3]) { pMesh.mNumUVComponents[pInput.mIndex] = 3; } @@ -2113,7 +2113,7 @@ void ColladaParser::ReadSceneNode(XmlNode &node, Node *pNode) { if (s[0] != '#') { ASSIMP_LOG_ERROR("Collada: Unresolved reference format of node"); } else { - pNode->mNodeInstances.push_back(NodeInstance()); + pNode->mNodeInstances.emplace_back(); pNode->mNodeInstances.back().mNode = s.c_str() + 1; } } @@ -2129,7 +2129,7 @@ void ColladaParser::ReadSceneNode(XmlNode &node, Node *pNode) { throw DeadlyImportError("Unknown reference format in element"); } - pNode->mLights.push_back(LightInstance()); + pNode->mLights.emplace_back(); pNode->mLights.back().mLight = url.c_str() + 1; } } else if (currentName == "instance_camera") { @@ -2140,7 +2140,7 @@ void ColladaParser::ReadSceneNode(XmlNode &node, Node *pNode) { if (url[0] != '#') { throw DeadlyImportError("Unknown reference format in element"); } - pNode->mCameras.push_back(CameraInstance()); + pNode->mCameras.emplace_back(); pNode->mCameras.back().mCamera = url.c_str() + 1; } } diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp index 2f1ec35b4..bdc48e36c 100644 --- a/code/AssetLib/DXF/DXFLoader.cpp +++ b/code/AssetLib/DXF/DXFLoader.cpp @@ -475,7 +475,7 @@ void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) { // ------------------------------------------------------------------------------------------------ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) { // push a new block onto the stack. - output.blocks.push_back( DXF::Block() ); + output.blocks.emplace_back( ); DXF::Block& block = output.blocks.back(); while( !reader.End() && !reader.Is(0,"ENDBLK")) { @@ -520,7 +520,7 @@ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) { // ------------------------------------------------------------------------------------------------ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) { // Push a new block onto the stack. - output.blocks.push_back( DXF::Block() ); + output.blocks.emplace_back( ); DXF::Block& block = output.blocks.back(); block.name = AI_DXF_ENTITIES_MAGIC_BLOCK; @@ -550,7 +550,7 @@ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) } void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output) { - output.blocks.back().insertions.push_back( DXF::InsertBlock() ); + output.blocks.back().insertions.emplace_back( ); DXF::InsertBlock& bl = output.blocks.back().insertions.back(); while( !reader.End() && !reader.Is(0)) { diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index 3ae96d54d..d8dbb6244 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -242,7 +242,7 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node) ai_assert(nodes_chain.size()); if (need_additional_node) { - nodes_chain.emplace_back(PotentialNode(node_name)); + nodes_chain.emplace_back(node_name); } //setup metadata on newest node diff --git a/code/AssetLib/FBX/FBXParser.cpp b/code/AssetLib/FBX/FBXParser.cpp index 488e075dc..da6d3889a 100644 --- a/code/AssetLib/FBX/FBXParser.cpp +++ b/code/AssetLib/FBX/FBXParser.cpp @@ -619,9 +619,9 @@ void ParseVectorDataArray(std::vector& out, const Element& el) if (type == 'd') { const double* d = reinterpret_cast(&buff[0]); for (unsigned int i = 0; i < count3; ++i, d += 3) { - out.push_back(aiVector3D(static_cast(d[0]), + out.emplace_back(static_cast(d[0]), static_cast(d[1]), - static_cast(d[2]))); + static_cast(d[2])); } // for debugging /*for ( size_t i = 0; i < out.size(); i++ ) { @@ -634,7 +634,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el) else if (type == 'f') { const float* f = reinterpret_cast(&buff[0]); for (unsigned int i = 0; i < count3; ++i, f += 3) { - out.push_back(aiVector3D(f[0],f[1],f[2])); + out.emplace_back(f[0],f[1],f[2]); } } @@ -708,16 +708,16 @@ void ParseVectorDataArray(std::vector& out, const Element& el) if (type == 'd') { const double* d = reinterpret_cast(&buff[0]); for (unsigned int i = 0; i < count4; ++i, d += 4) { - out.push_back(aiColor4D(static_cast(d[0]), + out.emplace_back(static_cast(d[0]), static_cast(d[1]), static_cast(d[2]), - static_cast(d[3]))); + static_cast(d[3])); } } else if (type == 'f') { const float* f = reinterpret_cast(&buff[0]); for (unsigned int i = 0; i < count4; ++i, f += 4) { - out.push_back(aiColor4D(f[0],f[1],f[2],f[3])); + out.emplace_back(f[0],f[1],f[2],f[3]); } } return; @@ -789,13 +789,13 @@ void ParseVectorDataArray(std::vector& out, const Element& el) { if (type == 'd') { const double* d = reinterpret_cast(&buff[0]); for (unsigned int i = 0; i < count2; ++i, d += 2) { - out.push_back(aiVector2D(static_cast(d[0]), - static_cast(d[1]))); + out.emplace_back(static_cast(d[0]), + static_cast(d[1])); } } else if (type == 'f') { const float* f = reinterpret_cast(&buff[0]); for (unsigned int i = 0; i < count2; ++i, f += 2) { - out.push_back(aiVector2D(f[0],f[1])); + out.emplace_back(f[0],f[1]); } } diff --git a/code/AssetLib/IFC/IFCBoolean.cpp b/code/AssetLib/IFC/IFCBoolean.cpp index 36912a7d8..2a8456719 100644 --- a/code/AssetLib/IFC/IFCBoolean.cpp +++ b/code/AssetLib/IFC/IFCBoolean.cpp @@ -310,7 +310,7 @@ bool IntersectsBoundaryProfile(const IfcVector3 &e0, const IfcVector3 &e1, const if (IfcVector2(diff.x, diff.y).SquareLength() < 1e-10) continue; } - intersect_results.push_back(std::make_pair(i, e0)); + intersect_results.emplace_back(i, e0); continue; } @@ -324,7 +324,7 @@ bool IntersectsBoundaryProfile(const IfcVector3 &e0, const IfcVector3 &e1, const if (IfcVector2(diff.x, diff.y).SquareLength() < 1e-10) continue; } - intersect_results.push_back(std::make_pair(i, p)); + intersect_results.emplace_back(i, p); } } @@ -504,7 +504,7 @@ void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const Schema_2x3::IfcPoly } // now add them to the list of intersections for (size_t b = 0; b < intersected_boundary.size(); ++b) - intersections.push_back(std::make_tuple(a, proj_inv * intersected_boundary[b].second, intersected_boundary[b].first)); + intersections.emplace_back(a, proj_inv * intersected_boundary[b].second, intersected_boundary[b].first); // and calculate our new inside/outside state if (intersected_boundary.size() & 1) diff --git a/code/AssetLib/IFC/IFCCurve.cpp b/code/AssetLib/IFC/IFCCurve.cpp index ff84bb59b..59774eb11 100644 --- a/code/AssetLib/IFC/IFCCurve.cpp +++ b/code/AssetLib/IFC/IFCCurve.cpp @@ -224,7 +224,7 @@ public: IFCImporter::LogVerboseDebug("ignoring transition code on composite curve segment, only continuous transitions are supported"); } - curves.push_back( CurveEntry(bc,IsTrue(curveSegment.SameSense)) ); + curves.emplace_back(bc,IsTrue(curveSegment.SameSense) ); total += bc->GetParametricRangeDelta(); } diff --git a/code/AssetLib/IFC/IFCGeometry.cpp b/code/AssetLib/IFC/IFCGeometry.cpp index ef5954251..b3620fe81 100644 --- a/code/AssetLib/IFC/IFCGeometry.cpp +++ b/code/AssetLib/IFC/IFCGeometry.cpp @@ -170,7 +170,7 @@ void ProcessPolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t m continue; } - fake_openings.push_back(TempOpening()); + fake_openings.emplace_back(); TempOpening& opening = fake_openings.back(); opening.extrusionDir = master_normal; @@ -612,7 +612,7 @@ void ProcessExtrudedArea(const Schema_2x3::IfcExtrudedAreaSolid& solid, const Te TempMesh& bounds = *t.profileMesh.get(); if( bounds.mVerts.size() <= 2 ) { - nors.push_back(IfcVector3()); + nors.emplace_back(); continue; } auto nor = ((bounds.mVerts[2] - bounds.mVerts[0]) ^ (bounds.mVerts[1] - bounds.mVerts[0])).Normalize(); diff --git a/code/AssetLib/IFC/IFCOpenings.cpp b/code/AssetLib/IFC/IFCOpenings.cpp index 3c4a0b3cd..7c36fd79f 100644 --- a/code/AssetLib/IFC/IFCOpenings.cpp +++ b/code/AssetLib/IFC/IFCOpenings.cpp @@ -114,9 +114,9 @@ void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField& if (!found) { // the rectangle [pmin,pend] is opaque, fill it out.push_back(pmin); - out.push_back(IfcVector2(pmin.x,pmax.y)); + out.emplace_back(pmin.x,pmax.y); out.push_back(pmax); - out.push_back(IfcVector2(pmax.x,pmin.y)); + out.emplace_back(pmax.x,pmin.y); return; } @@ -126,9 +126,9 @@ void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField& // see if there's an offset to fill at the top of our quad if (xs - pmin.x) { out.push_back(pmin); - out.push_back(IfcVector2(pmin.x,pmax.y)); - out.push_back(IfcVector2(xs,pmax.y)); - out.push_back(IfcVector2(xs,pmin.y)); + out.emplace_back(pmin.x,pmax.y); + out.emplace_back(xs,pmax.y); + out.emplace_back(xs,pmin.y); } // search along the y-axis for all openings that overlap xs and our quad @@ -159,10 +159,10 @@ void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField& } if (!found) { // the rectangle [pmin,pend] is opaque, fill it - out.push_back(IfcVector2(xs,pmin.y)); - out.push_back(IfcVector2(xs,pmax.y)); - out.push_back(IfcVector2(xe,pmax.y)); - out.push_back(IfcVector2(xe,pmin.y)); + out.emplace_back(xs,pmin.y); + out.emplace_back(xs,pmax.y); + out.emplace_back(xe,pmax.y); + out.emplace_back(xe,pmin.y); return; } if (ylast < pmax.y) { @@ -342,7 +342,7 @@ void InsertWindowContours(const ContourVector& contours, if ((contour[a] - edge).SquareLength() > diag*diag*0.7) { continue; } - curmesh.mVerts.push_back(IfcVector3(contour[a].x, contour[a].y, 0.0f)); + curmesh.mVerts.emplace_back(contour[a].x, contour[a].y, 0.0f); } if (edge != contour[last_hit]) { @@ -363,7 +363,7 @@ void InsertWindowContours(const ContourVector& contours, corner.y = bb.second.y; } - curmesh.mVerts.push_back(IfcVector3(corner.x, corner.y, 0.0f)); + curmesh.mVerts.emplace_back(corner.x, corner.y, 0.0f); } else if (cnt == 1) { // avoid degenerate polygons (also known as lines or points) @@ -558,10 +558,10 @@ void CleanupOuterContour(const std::vector& contour_flat, TempMesh& for(const ClipperLib::ExPolygon& ex : clipped) { iold.push_back(static_cast(ex.outer.size())); for(const ClipperLib::IntPoint& point : ex.outer) { - vold.push_back(IfcVector3( + vold.emplace_back( from_int64(point.X), from_int64(point.Y), - 0.0f)); + 0.0f); } } @@ -1039,7 +1039,7 @@ void Quadrify(const std::vector< BoundingBox >& bbs, TempMesh& curmesh) curmesh.mVertcnt.resize(quads.size()/4,4); curmesh.mVerts.reserve(quads.size()); for(const IfcVector2& v2 : quads) { - curmesh.mVerts.push_back(IfcVector3(v2.x, v2.y, static_cast(0.0))); + curmesh.mVerts.emplace_back(v2.x, v2.y, static_cast(0.0)); } } @@ -1095,7 +1095,7 @@ IfcMatrix4 ProjectOntoPlane(std::vector& out_contour, const TempMesh vmin = std::min(vv, vmin); vmax = std::max(vv, vmax); - out_contour.push_back(IfcVector2(vv.x,vv.y)); + out_contour.emplace_back(vv.x,vv.y); } zcoord /= in_verts.size(); @@ -1128,7 +1128,7 @@ IfcMatrix4 ProjectOntoPlane(std::vector& out_contour, const TempMesh for(const IfcVector3& x : in_verts) { const IfcVector3& vv = m * x; - out_contour2.push_back(IfcVector2(vv.x,vv.y)); + out_contour2.emplace_back(vv.x,vv.y); ai_assert(std::fabs(vv.z) < vmax.z + 1e-8); } @@ -1469,7 +1469,7 @@ std::vector GetContourInPlane2D(const std::shared_ptr& mes // XXX should not be necessary - but it is. Why? For precision reasons? vv = is_extruded_side ? vv_extr : vv; - contour.push_back(IfcVector2(vv.x,vv.y)); + contour.emplace_back(vv.x,vv.y); } ok = true; @@ -1758,7 +1758,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings, vmin = std::min(IfcVector2(vv.x, vv.y), vmin); vmax = std::max(IfcVector2(vv.x, vv.y), vmax); - contour_flat.push_back(IfcVector2(vv.x,vv.y)); + contour_flat.emplace_back(vv.x,vv.y); } // With the current code in DerivePlaneCoordinateSpace, @@ -1891,7 +1891,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings, // Build the poly2tri inner contours for all holes we got from ClipperLib for(ClipperLib::Polygon& opening : clip.holes) { - contours.push_back(std::vector()); + contours.emplace_back(); std::vector& contour = contours.back(); for(ClipperLib::IntPoint& point : opening) { diff --git a/code/AssetLib/IFC/IFCProfile.cpp b/code/AssetLib/IFC/IFCProfile.cpp index aa31124ed..cee36c022 100644 --- a/code/AssetLib/IFC/IFCProfile.cpp +++ b/code/AssetLib/IFC/IFCProfile.cpp @@ -108,10 +108,10 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de const IfcFloat x = cprofile->XDim*0.5f, y = cprofile->YDim*0.5f; meshout.mVerts.reserve(meshout.mVerts.size()+4); - meshout.mVerts.push_back( IfcVector3( x, y, 0.f )); - meshout.mVerts.push_back( IfcVector3(-x, y, 0.f )); - meshout.mVerts.push_back( IfcVector3(-x,-y, 0.f )); - meshout.mVerts.push_back( IfcVector3( x,-y, 0.f )); + meshout.mVerts.emplace_back( x, y, 0.f ); + meshout.mVerts.emplace_back(-x, y, 0.f ); + meshout.mVerts.emplace_back(-x,-y, 0.f ); + meshout.mVerts.emplace_back( x,-y, 0.f ); meshout.mVertcnt.push_back(4); } else if( const Schema_2x3::IfcCircleProfileDef* const circle = def.ToPtr()) { @@ -125,7 +125,7 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de IfcFloat angle = 0.f; for(size_t i = 0; i < segments; ++i, angle += delta) { - meshout.mVerts.push_back( IfcVector3( std::cos(angle)*radius, std::sin(angle)*radius, 0.f )); + meshout.mVerts.emplace_back( std::cos(angle)*radius, std::sin(angle)*radius, 0.f ); } meshout.mVertcnt.push_back(static_cast(segments)); @@ -136,18 +136,18 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de const IfcFloat inner_height = ishape->OverallDepth - ishape->FlangeThickness * 2; meshout.mVerts.reserve(12); - meshout.mVerts.push_back(IfcVector3(0,0,0)); - meshout.mVerts.push_back(IfcVector3(0,ishape->FlangeThickness,0)); - meshout.mVerts.push_back(IfcVector3(offset,ishape->FlangeThickness,0)); - meshout.mVerts.push_back(IfcVector3(offset,ishape->FlangeThickness + inner_height,0)); - meshout.mVerts.push_back(IfcVector3(0,ishape->FlangeThickness + inner_height,0)); - meshout.mVerts.push_back(IfcVector3(0,ishape->OverallDepth,0)); - meshout.mVerts.push_back(IfcVector3(ishape->OverallWidth,ishape->OverallDepth,0)); - meshout.mVerts.push_back(IfcVector3(ishape->OverallWidth,ishape->FlangeThickness + inner_height,0)); - meshout.mVerts.push_back(IfcVector3(offset+ishape->WebThickness,ishape->FlangeThickness + inner_height,0)); - meshout.mVerts.push_back(IfcVector3(offset+ishape->WebThickness,ishape->FlangeThickness,0)); - meshout.mVerts.push_back(IfcVector3(ishape->OverallWidth,ishape->FlangeThickness,0)); - meshout.mVerts.push_back(IfcVector3(ishape->OverallWidth,0,0)); + meshout.mVerts.emplace_back(0,0,0); + meshout.mVerts.emplace_back(0,ishape->FlangeThickness,0); + meshout.mVerts.emplace_back(offset,ishape->FlangeThickness,0); + meshout.mVerts.emplace_back(offset,ishape->FlangeThickness + inner_height,0); + meshout.mVerts.emplace_back(0,ishape->FlangeThickness + inner_height,0); + meshout.mVerts.emplace_back(0,ishape->OverallDepth,0); + meshout.mVerts.emplace_back(ishape->OverallWidth,ishape->OverallDepth,0); + meshout.mVerts.emplace_back(ishape->OverallWidth,ishape->FlangeThickness + inner_height,0); + meshout.mVerts.emplace_back(offset+ishape->WebThickness,ishape->FlangeThickness + inner_height,0); + meshout.mVerts.emplace_back(offset+ishape->WebThickness,ishape->FlangeThickness,0); + meshout.mVerts.emplace_back(ishape->OverallWidth,ishape->FlangeThickness,0); + meshout.mVerts.emplace_back(ishape->OverallWidth,0,0); meshout.mVertcnt.push_back(12); } diff --git a/code/AssetLib/IFC/IFCUtil.cpp b/code/AssetLib/IFC/IFCUtil.cpp index 6b378c1da..6cf104833 100644 --- a/code/AssetLib/IFC/IFCUtil.cpp +++ b/code/AssetLib/IFC/IFCUtil.cpp @@ -201,7 +201,7 @@ void TempMesh::ComputePolygonNormals(std::vector& normals, size_t vidx = std::accumulate(mVertcnt.begin(),begin,0); for(iit = begin; iit != end; vidx += *iit++) { if (!*iit) { - normals.push_back(IfcVector3()); + normals.emplace_back(); continue; } for(size_t vofs = 0, cnt = 0; vofs < *iit; ++vofs) { @@ -215,7 +215,7 @@ void TempMesh::ComputePolygonNormals(std::vector& normals, ++cnt; } - normals.push_back(IfcVector3()); + normals.emplace_back(); NewellNormal<4,4,4>(normals.back(),*iit,&temp[0],&temp[1],&temp[2]); } diff --git a/code/AssetLib/Irr/IRRLoader.cpp b/code/AssetLib/Irr/IRRLoader.cpp index b16565559..3103a6cc8 100644 --- a/code/AssetLib/Irr/IRRLoader.cpp +++ b/code/AssetLib/Irr/IRRLoader.cpp @@ -628,7 +628,7 @@ void IRRImporter::GenerateGraph(Node *root, aiNode *rootOut, aiScene *scene, ASSIMP_LOG_ERROR("IRR: Unable to load external file: ", root->meshPath); break; } - attach.push_back(AttachmentInfo(localScene, rootOut)); + attach.emplace_back(localScene, rootOut); // Now combine the material we've loaded for this mesh // with the real materials we got from the file. As we @@ -979,7 +979,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy // Materials can occur for nearly any type of node if (inMaterials && curNode->type != Node::DUMMY) { // This is a material description - parse it! - curNode->materials.push_back(std::pair()); + curNode->materials.emplace_back(); std::pair &p = curNode->materials.back(); p.first = ParseMaterial(p.second); @@ -988,7 +988,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy } else if (inAnimator) { // This is an animation path - add a new animator // to the list. - curNode->animators.push_back(Animator()); + curNode->animators.emplace_back(); curAnim = &curNode->animators.back(); ++guessedAnimCnt; @@ -1015,7 +1015,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy // here N is the ONE-based index of the point if (prop.name.length() >= 6 && prop.name.substr(0, 5) == "Point") { // Add a new key to the list - curAnim->splineKeys.push_back(aiVectorKey()); + curAnim->splineKeys.emplace_back(); aiVectorKey &key = curAnim->splineKeys.back(); // and parse its properties diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp index 77589d63c..31b0befca 100644 --- a/code/AssetLib/LWO/LWOLoader.cpp +++ b/code/AssetLib/LWO/LWOLoader.cpp @@ -1292,7 +1292,7 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length) { case AI_LWO_KEY: { AI_LWO_VALIDATE_CHUNK_LENGTH(head.length, KEY, 8); - envelope.keys.push_back(LWO::Key()); + envelope.keys.emplace_back(); LWO::Key &key = envelope.keys.back(); key.time = GetF4(); @@ -1390,7 +1390,7 @@ void LWOImporter::LoadLWO3Envelope(unsigned int length) { case AI_LWO_KEY: { AI_LWO_VALIDATE_CHUNK_LENGTH(head.length, KEY, 10); - envelope.keys.push_back(LWO::Key()); + envelope.keys.emplace_back(); LWO::Key &key = envelope.keys.back(); key.time = GetF4(); diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp index 0e29bb38f..f830fc7b6 100644 --- a/code/AssetLib/LWS/LWSLoader.cpp +++ b/code/AssetLib/LWS/LWSLoader.cpp @@ -90,7 +90,7 @@ void LWS::Element::Parse(const char *&buffer) { } else if (*buffer == '}') return; - children.push_back(Element()); + children.emplace_back(); // copy data line - read token per token @@ -199,7 +199,7 @@ void LWSImporter::ReadEnvelope(const LWS::Element &dad, LWO::Envelope &fill) { const char *c = (*it).tokens[1].c_str(); if ((*it).tokens[0] == "Key") { - fill.keys.push_back(LWO::Key()); + fill.keys.emplace_back(); LWO::Key &key = fill.keys.back(); float f; @@ -262,7 +262,7 @@ void LWSImporter::ReadEnvelope_Old( num = strtoul10((*it).tokens[0].c_str()); for (unsigned int i = 0; i < num; ++i) { - nodes.channels.push_back(LWO::Envelope()); + nodes.channels.emplace_back(); LWO::Envelope &envl = nodes.channels.back(); envl.index = i; @@ -384,7 +384,7 @@ void LWSImporter::BuildGraph(aiNode *nd, LWS::NodeDesc &src, std::vectormaps.push_back(Q3Shader::ShaderMapBlock()); + curData->maps.emplace_back(); curMap = &curData->maps.back(); for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) { @@ -209,7 +209,7 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem * } } else { // add new section - fill.blocks.push_back(Q3Shader::ShaderDataBlock()); + fill.blocks.emplace_back(); curData = &fill.blocks.back(); // get the name of this section @@ -249,7 +249,7 @@ bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io) if (!::strncmp(&ss[0], "tag_", std::min((size_t)4, ss.length()))) continue; - fill.textures.push_back(SkinData::TextureEntry()); + fill.textures.emplace_back(); SkinData::TextureEntry &entry = fill.textures.back(); entry.first = ss; @@ -584,7 +584,7 @@ bool MD3Importer::ReadMultipartFile() { // original root scene_lower->mRootNode->mName.Set("lower"); - attach.push_back(AttachmentInfo(scene_lower, nd)); + attach.emplace_back(scene_lower, nd); // tag_torso tag_torso = scene_lower->mRootNode->FindNode("tag_torso"); @@ -593,7 +593,7 @@ bool MD3Importer::ReadMultipartFile() { goto error_cleanup; } scene_upper->mRootNode->mName.Set("upper"); - attach.push_back(AttachmentInfo(scene_upper, tag_torso)); + attach.emplace_back(scene_upper, tag_torso); // tag_head tag_head = scene_upper->mRootNode->FindNode("tag_head"); @@ -602,7 +602,7 @@ bool MD3Importer::ReadMultipartFile() { goto error_cleanup; } scene_head->mRootNode->mName.Set("head"); - attach.push_back(AttachmentInfo(scene_head, tag_head)); + attach.emplace_back(scene_head, tag_head); // Remove tag_head and tag_torso from all other model parts ... // this ensures (together with AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) diff --git a/code/AssetLib/MDC/MDCLoader.cpp b/code/AssetLib/MDC/MDCLoader.cpp index 7810800de..c96cc78fc 100644 --- a/code/AssetLib/MDC/MDCLoader.cpp +++ b/code/AssetLib/MDC/MDCLoader.cpp @@ -271,13 +271,13 @@ void MDCImporter::InternReadFile( pcMesh->mMaterialIndex = (unsigned int)aszShaders.size(); // create a new shader - aszShaders.push_back(std::string(pcShader->ucName, - ::strnlen(pcShader->ucName, sizeof(pcShader->ucName)))); + aszShaders.emplace_back(pcShader->ucName, + ::strnlen(pcShader->ucName, sizeof(pcShader->ucName))); } // need to create a default material else if (UINT_MAX == iDefaultMatIndex) { pcMesh->mMaterialIndex = iDefaultMatIndex = (unsigned int)aszShaders.size(); - aszShaders.push_back(std::string()); + aszShaders.emplace_back(); } // otherwise assign a reference to the default material else diff --git a/code/AssetLib/MS3D/MS3DLoader.cpp b/code/AssetLib/MS3D/MS3DLoader.cpp index fc2ed042b..6ffc07aea 100644 --- a/code/AssetLib/MS3D/MS3DLoader.cpp +++ b/code/AssetLib/MS3D/MS3DLoader.cpp @@ -399,7 +399,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, // if one of the groups has no material assigned, but there are other // groups with materials, a default material needs to be added ( // scenepreprocessor adds a default material only if nummat==0). - materials.push_back(TempMaterial()); + materials.emplace_back(); TempMaterial& m = materials.back(); strcpy(m.name,""); diff --git a/code/AssetLib/NDO/NDOLoader.cpp b/code/AssetLib/NDO/NDOLoader.cpp index 07953b04d..6594fe32c 100644 --- a/code/AssetLib/NDO/NDOLoader.cpp +++ b/code/AssetLib/NDO/NDOLoader.cpp @@ -171,7 +171,7 @@ void NDOImporter::InternReadFile( const std::string& pFile, obj.edges.reserve(temp); for (unsigned int e = 0; e < temp; ++e) { - obj.edges.push_back(Edge()); + obj.edges.emplace_back(); Edge& edge = obj.edges.back(); for (unsigned int i = 0; i< 8; ++i) { @@ -188,7 +188,7 @@ void NDOImporter::InternReadFile( const std::string& pFile, obj.faces.reserve(temp); for (unsigned int e = 0; e < temp; ++e) { - obj.faces.push_back(Face()); + obj.faces.emplace_back(); Face& face = obj.faces.back(); face.elem = file_format >= 12 ? reader.GetU4() : reader.GetU2(); @@ -199,7 +199,7 @@ void NDOImporter::InternReadFile( const std::string& pFile, obj.vertices.reserve(temp); for (unsigned int e = 0; e < temp; ++e) { - obj.vertices.push_back(Vertex()); + obj.vertices.emplace_back(); Vertex& v = obj.vertices.back(); v.num = file_format >= 12 ? reader.GetU4() : reader.GetU2(); diff --git a/code/AssetLib/NFF/NFFLoader.cpp b/code/AssetLib/NFF/NFFLoader.cpp index 48271d137..3fd12fa2e 100644 --- a/code/AssetLib/NFF/NFFLoader.cpp +++ b/code/AssetLib/NFF/NFFLoader.cpp @@ -167,7 +167,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector &output, // 'matdef' starts a new material in the file else if (TokenMatch(sz, "matdef", 6)) { // add a new material to the list - output.push_back(ShadingInfo()); + output.emplace_back(); curShader = &output.back(); // parse the name of the material @@ -549,7 +549,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } } if (!mesh) { - meshes.push_back(MeshInfo(PatchType_Simple, false)); + meshes.emplace_back(PatchType_Simple, false); mesh = &meshes.back(); mesh->matIndex = matIdx; @@ -614,7 +614,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } if (!currentMeshWithUVCoords) { - meshesWithUVCoords.push_back(MeshInfo(PatchType_UVAndNormals)); + meshesWithUVCoords.emplace_back(PatchType_UVAndNormals); currentMeshWithUVCoords = &meshesWithUVCoords.back(); currentMeshWithUVCoords->shader = s; } @@ -631,7 +631,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } if (!currentMeshWithNormals) { - meshesWithNormals.push_back(MeshInfo(PatchType_Normals)); + meshesWithNormals.emplace_back(PatchType_Normals); currentMeshWithNormals = &meshesWithNormals.back(); currentMeshWithNormals->shader = s; } @@ -649,7 +649,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } if (!currentMesh) { - meshes.push_back(MeshInfo(PatchType_Simple)); + meshes.emplace_back(PatchType_Simple); currentMesh = &meshes.back(); currentMesh->shader = s; } @@ -749,7 +749,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } // 'l' - light source else if (TokenMatch(sz, "l", 1)) { - lights.push_back(Light()); + lights.emplace_back(); Light &light = lights.back(); AI_NFF_PARSE_TRIPLE(light.position); @@ -758,7 +758,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } // 's' - sphere else if (TokenMatch(sz, "s", 1)) { - meshesLocked.push_back(MeshInfo(PatchType_Simple, true)); + meshesLocked.emplace_back(PatchType_Simple, true); MeshInfo &curMesh = meshesLocked.back(); curMesh.shader = s; curMesh.shader.mapping = aiTextureMapping_SPHERE; @@ -774,7 +774,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } // 'dod' - dodecahedron else if (TokenMatch(sz, "dod", 3)) { - meshesLocked.push_back(MeshInfo(PatchType_Simple, true)); + meshesLocked.emplace_back(PatchType_Simple, true); MeshInfo &curMesh = meshesLocked.back(); curMesh.shader = s; curMesh.shader.mapping = aiTextureMapping_SPHERE; @@ -791,7 +791,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, // 'oct' - octahedron else if (TokenMatch(sz, "oct", 3)) { - meshesLocked.push_back(MeshInfo(PatchType_Simple, true)); + meshesLocked.emplace_back(PatchType_Simple, true); MeshInfo &curMesh = meshesLocked.back(); curMesh.shader = s; curMesh.shader.mapping = aiTextureMapping_SPHERE; @@ -808,7 +808,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, // 'tet' - tetrahedron else if (TokenMatch(sz, "tet", 3)) { - meshesLocked.push_back(MeshInfo(PatchType_Simple, true)); + meshesLocked.emplace_back(PatchType_Simple, true); MeshInfo &curMesh = meshesLocked.back(); curMesh.shader = s; curMesh.shader.mapping = aiTextureMapping_SPHERE; @@ -825,7 +825,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, // 'hex' - hexahedron else if (TokenMatch(sz, "hex", 3)) { - meshesLocked.push_back(MeshInfo(PatchType_Simple, true)); + meshesLocked.emplace_back(PatchType_Simple, true); MeshInfo &curMesh = meshesLocked.back(); curMesh.shader = s; curMesh.shader.mapping = aiTextureMapping_BOX; @@ -841,7 +841,7 @@ void NFFImporter::InternReadFile(const std::string &pFile, } // 'c' - cone else if (TokenMatch(sz, "c", 1)) { - meshesLocked.push_back(MeshInfo(PatchType_Simple, true)); + meshesLocked.emplace_back(PatchType_Simple, true); MeshInfo &curMesh = meshesLocked.back(); curMesh.shader = s; curMesh.shader.mapping = aiTextureMapping_CYLINDER; diff --git a/code/AssetLib/Obj/ObjExporter.cpp b/code/AssetLib/Obj/ObjExporter.cpp index 882f3a917..a678110fc 100644 --- a/code/AssetLib/Obj/ObjExporter.cpp +++ b/code/AssetLib/Obj/ObjExporter.cpp @@ -333,7 +333,7 @@ void ObjExporter::WriteGeometryFile(bool noMtl) { // ------------------------------------------------------------------------------------------------ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat) { - mMeshes.push_back(MeshInstance() ); + mMeshes.emplace_back( ); MeshInstance& mesh = mMeshes.back(); if ( nullptr != m->mColors[ 0 ] ) { diff --git a/code/AssetLib/Obj/ObjFileParser.cpp b/code/AssetLib/Obj/ObjFileParser.cpp index 167cab544..7b0282c43 100644 --- a/code/AssetLib/Obj/ObjFileParser.cpp +++ b/code/AssetLib/Obj/ObjFileParser.cpp @@ -90,7 +90,7 @@ ObjFileParser::ObjFileParser(IOStreamBuffer &streamBuffer, const std::stri // create default material and store it m_pModel->mDefaultMaterial = new ObjFile::Material; m_pModel->mDefaultMaterial->MaterialName.Set(DEFAULT_MATERIAL); - m_pModel->mMaterialLib.push_back(DEFAULT_MATERIAL); + m_pModel->mMaterialLib.emplace_back(DEFAULT_MATERIAL); m_pModel->mMaterialMap[DEFAULT_MATERIAL] = m_pModel->mDefaultMaterial; // Start parsing the file diff --git a/code/AssetLib/Ogre/OgreStructs.cpp b/code/AssetLib/Ogre/OgreStructs.cpp index d63dd934a..444f7d14a 100644 --- a/code/AssetLib/Ogre/OgreStructs.cpp +++ b/code/AssetLib/Ogre/OgreStructs.cpp @@ -256,7 +256,7 @@ AssimpVertexBoneWeightList IVertexData::AssimpBoneWeights(size_t vertices) { for (VertexBoneAssignmentList::const_iterator iter = vertexWeights.begin(), end = vertexWeights.end(); iter != end; ++iter) { std::vector &boneWeights = weights[iter->boneIndex]; - boneWeights.push_back(aiVertexWeight(static_cast(vi), iter->weight)); + boneWeights.emplace_back(static_cast(vi), iter->weight); } } return weights; diff --git a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp index db9a4a02f..30f281a44 100644 --- a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp +++ b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp @@ -560,9 +560,9 @@ bool Q3BSPFileImporter::importTextureFromArchive(const Q3BSP::Q3BSPModel *model, } std::vector supportedExtensions; - supportedExtensions.push_back(".jpg"); - supportedExtensions.push_back(".png"); - supportedExtensions.push_back(".tga"); + supportedExtensions.emplace_back(".jpg"); + supportedExtensions.emplace_back(".png"); + supportedExtensions.emplace_back(".tga"); std::string textureName, ext; if (expandFile(archive, pTexture->strName, supportedExtensions, textureName, ext)) { IOStream *pTextureStream = archive->Open(textureName.c_str()); diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp index 0bfe16162..0e12620dc 100644 --- a/code/AssetLib/Q3D/Q3DLoader.cpp +++ b/code/AssetLib/Q3D/Q3DLoader.cpp @@ -157,7 +157,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile, // Meshes chunk case 'm': { for (unsigned int quak = 0; quak < numMeshes; ++quak) { - meshes.push_back(Mesh()); + meshes.emplace_back(); Mesh &mesh = meshes.back(); // read all vertices @@ -184,7 +184,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile, // number of indices for (unsigned int i = 0; i < numVerts; ++i) { - faces.push_back(Face(stream.GetI2())); + faces.emplace_back(stream.GetI2()); if (faces.back().indices.empty()) throw DeadlyImportError("Quick3D: Found face with zero indices"); } @@ -248,7 +248,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile, case 'c': for (unsigned int i = 0; i < numMats; ++i) { - materials.push_back(Material()); + materials.emplace_back(); Material &mat = materials.back(); // read the material name @@ -402,7 +402,7 @@ outer: // If we have no materials loaded - generate a default mat if (materials.empty()) { ASSIMP_LOG_INFO("Quick3D: No material found, generating one"); - materials.push_back(Material()); + materials.emplace_back(); materials.back().diffuse = fgColor; } diff --git a/code/AssetLib/Raw/RawLoader.cpp b/code/AssetLib/Raw/RawLoader.cpp index bfd2e6d6e..83d8ce37f 100644 --- a/code/AssetLib/Raw/RawLoader.cpp +++ b/code/AssetLib/Raw/RawLoader.cpp @@ -138,7 +138,7 @@ void RAWImporter::InternReadFile(const std::string &pFile, } } if (sz2) { - outGroups.push_back(GroupInformation(std::string(sz, length))); + outGroups.emplace_back(std::string(sz, length)); curGroup = outGroups.end() - 1; } } else { @@ -179,7 +179,7 @@ void RAWImporter::InternReadFile(const std::string &pFile, } // if we don't have the mesh, create it if (!output) { - (*curGroup).meshes.push_back(MeshInformation(std::string(sz, length))); + (*curGroup).meshes.emplace_back(std::string(sz, length)); output = &((*curGroup).meshes.back()); } if (12 == num) { @@ -188,13 +188,13 @@ void RAWImporter::InternReadFile(const std::string &pFile, output->colors.push_back(v); output->colors.push_back(v); - output->vertices.push_back(aiVector3D(data[3], data[4], data[5])); - output->vertices.push_back(aiVector3D(data[6], data[7], data[8])); - output->vertices.push_back(aiVector3D(data[9], data[10], data[11])); + output->vertices.emplace_back(data[3], data[4], data[5]); + output->vertices.emplace_back(data[6], data[7], data[8]); + output->vertices.emplace_back(data[9], data[10], data[11]); } else { - output->vertices.push_back(aiVector3D(data[0], data[1], data[2])); - output->vertices.push_back(aiVector3D(data[3], data[4], data[5])); - output->vertices.push_back(aiVector3D(data[6], data[7], data[8])); + output->vertices.emplace_back(data[0], data[1], data[2]); + output->vertices.emplace_back(data[3], data[4], data[5]); + output->vertices.emplace_back(data[6], data[7], data[8]); } } } diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index 46fd968c8..30154c8b8 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -227,7 +227,7 @@ void SMDImporter::FixTimeValues() { // create output meshes void SMDImporter::CreateOutputMeshes() { if (aszTextures.empty()) { - aszTextures.push_back(std::string()); + aszTextures.emplace_back(); } // we need to sort all faces by their material index @@ -589,7 +589,7 @@ void SMDImporter::GetAnimationFileList(const std::string &pFile, IOSystem* pIOHa animPath = p; animName = DefaultIOSystem::completeBaseName(animPath); } - outList.push_back(std::make_tuple(animName, base + "/" + animPath)); + outList.emplace_back(animName, base + "/" + animPath); } tok1 = strtok_s(nullptr, "\r\n", &context1); } @@ -799,7 +799,7 @@ void SMDImporter::ParseVASection(const char* szCurrent, const char** szCurrentOu SkipLine(szCurrent,&szCurrent); } else { if(0 == iCurIndex) { - asTriangles.push_back(SMD::Face()); + asTriangles.emplace_back(); } if (++iCurIndex == 3) { iCurIndex = 0; @@ -919,7 +919,7 @@ void SMDImporter::ParseSkeletonElement(const char* szCurrent, const char** szCur } SMD::Bone& bone = asBones[iBone]; - bone.sAnim.asKeys.push_back(SMD::Bone::Animation::MatrixKey()); + bone.sAnim.asKeys.emplace_back(); SMD::Bone::Animation::MatrixKey& key = bone.sAnim.asKeys.back(); key.dTime = (double)iTime; @@ -964,7 +964,7 @@ void SMDImporter::ParseSkeletonElement(const char* szCurrent, const char** szCur // ------------------------------------------------------------------------------------------------ // Parse a triangle void SMDImporter::ParseTriangle(const char* szCurrent, const char** szCurrentOut) { - asTriangles.push_back(SMD::Face()); + asTriangles.emplace_back(); SMD::Face& face = asTriangles.back(); if(!SkipSpaces(szCurrent,&szCurrent)) { diff --git a/code/AssetLib/Unreal/UnrealLoader.cpp b/code/AssetLib/Unreal/UnrealLoader.cpp index 661952b3d..6166701d6 100644 --- a/code/AssetLib/Unreal/UnrealLoader.cpp +++ b/code/AssetLib/Unreal/UnrealLoader.cpp @@ -335,7 +335,7 @@ void UnrealImporter::InternReadFile(const std::string &pFile, SkipSpacesAndLineEnd(&data); if (TokenMatchI(data, "IMPORT", 6)) { - tempTextures.push_back(std::pair()); + tempTextures.emplace_back(); std::pair &me = tempTextures.back(); for (; !IsLineEnd(*data); ++data) { if (!::ASSIMP_strincmp(data, "NAME=", 5)) { @@ -361,7 +361,7 @@ void UnrealImporter::InternReadFile(const std::string &pFile, if (TokenMatchI(data, "SETTEXTURE", 10)) { - textures.push_back(std::pair()); + textures.emplace_back(); std::pair &me = textures.back(); for (; !IsLineEnd(*data); ++data) { diff --git a/code/AssetLib/X/XFileImporter.cpp b/code/AssetLib/X/XFileImporter.cpp index d23eb576c..e1070d826 100644 --- a/code/AssetLib/X/XFileImporter.cpp +++ b/code/AssetLib/X/XFileImporter.cpp @@ -380,7 +380,7 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec // does the new vertex stem from an old vertex which was influenced by this bone? ai_real w = oldWeights[orgPoints[d]]; if ( w > 0.0 ) { - newWeights.push_back( aiVertexWeight( d, w ) ); + newWeights.emplace_back( d, w ); } } diff --git a/code/AssetLib/X/XFileParser.cpp b/code/AssetLib/X/XFileParser.cpp index 558b97958..808bb9efd 100644 --- a/code/AssetLib/X/XFileParser.cpp +++ b/code/AssetLib/X/XFileParser.cpp @@ -454,7 +454,7 @@ void XFileParser::ParseDataObjectSkinWeights(Mesh *pMesh) { std::string transformNodeName; GetNextTokenAsString(transformNodeName); - pMesh->mBones.push_back(Bone()); + pMesh->mBones.emplace_back(); Bone &bone = pMesh->mBones.back(); bone.mName = transformNodeName; @@ -640,7 +640,7 @@ void XFileParser::ParseDataObjectMeshMaterialList(Mesh *pMesh) { CheckForClosingBrace(); // skip } } else if (objectName == "Material") { - pMesh->mMaterials.push_back(Material()); + pMesh->mMaterials.emplace_back(); ParseDataObjectMaterial(&pMesh->mMaterials.back()); } else if (objectName == ";") { // ignore @@ -678,12 +678,12 @@ void XFileParser::ParseDataObjectMaterial(Material *pMaterial) { // some exporters write "TextureFileName" instead. std::string texname; ParseDataObjectTextureFilename(texname); - pMaterial->mTextures.push_back(TexEntry(texname)); + pMaterial->mTextures.emplace_back(texname); } else if (objectName == "NormalmapFilename" || objectName == "NormalmapFileName") { // one exporter writes out the normal map in a separate filename tag std::string texname; ParseDataObjectTextureFilename(texname); - pMaterial->mTextures.push_back(TexEntry(texname, true)); + pMaterial->mTextures.emplace_back(texname, true); } else { ASSIMP_LOG_WARN("Unknown data object in material in x file"); ParseUnknownDataObject(); diff --git a/code/AssetLib/X3D/X3DExporter.cpp b/code/AssetLib/X3D/X3DExporter.cpp index b3278a528..0c5ed1268 100644 --- a/code/AssetLib/X3D/X3DExporter.cpp +++ b/code/AssetLib/X3D/X3DExporter.cpp @@ -131,7 +131,7 @@ void X3DExporter::AttrHelper_Color3ToAttrList(std::list &pList, cons if (pValue == pDefaultValue) return; AttrHelper_Col3DArrToString(&pValue, 1, tstr); - pList.push_back({ pName, tstr }); + pList.emplace_back( pName, tstr ); } void X3DExporter::AttrHelper_FloatToAttrList(std::list &pList, const string &pName, const float pValue, const float pDefaultValue) { @@ -140,7 +140,7 @@ void X3DExporter::AttrHelper_FloatToAttrList(std::list &pList, const if (pValue == pDefaultValue) return; AttrHelper_FloatToString(pValue, tstr); - pList.push_back({ pName, tstr }); + pList.emplace_back( pName, tstr ); } void X3DExporter::NodeHelper_OpenNode(const string &pNodeName, const size_t pTabLevel, const bool pEmptyElement, const list &pAttrList) { @@ -186,7 +186,7 @@ void X3DExporter::Export_Node(const aiNode *pNode, const size_t pTabLevel) { if (CheckAndExport_Light(*pNode, pTabLevel)) return; // Check if need DEF. - if (pNode->mName.length) attr_list.push_back({ "DEF", pNode->mName.C_Str() }); + if (pNode->mName.length) attr_list.emplace_back( "DEF", pNode->mName.C_Str() ); // Check if need node against . if (!pNode->mTransformation.IsIdentity()) { @@ -213,13 +213,13 @@ void X3DExporter::Export_Node(const aiNode *pNode, const size_t pTabLevel) { pNode->mTransformation.Decompose(scale, rotate_axis, rotate_angle, translate); // Check if values different from default if ((rotate_angle != 0) && (rotate_axis.Length() > 0)) - attr_list.push_back({ "rotation", Rotation2String(rotate_axis, rotate_angle) }); + attr_list.emplace_back( "rotation", Rotation2String(rotate_axis, rotate_angle) ); if (!scale.Equal({ 1.0, 1.0, 1.0 })) { - attr_list.push_back({ "scale", Vector2String(scale) }); + attr_list.emplace_back( "scale", Vector2String(scale) ); } if (translate.Length() > 0) { - attr_list.push_back({ "translation", Vector2String(translate) }); + attr_list.emplace_back( "translation", Vector2String(translate) ); } } @@ -284,7 +284,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) { // Check if mesh already defined early. if (mDEF_Map_Mesh.find(pIdxMesh) != mDEF_Map_Mesh.end()) { // Mesh already defined, just refer to it - attr_list.push_back({ "USE", mDEF_Map_Mesh.at(pIdxMesh) }); + attr_list.emplace_back( "USE", mDEF_Map_Mesh.at(pIdxMesh) ); NodeHelper_OpenNode(NodeName_Shape, pTabLevel, true, attr_list); return; @@ -293,7 +293,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) { string mesh_name(mesh.mName.C_Str() + string("_IDX_") + to_string(pIdxMesh)); // Create mesh name // Define mesh name. - attr_list.push_back({ "DEF", mesh_name }); + attr_list.emplace_back( "DEF", mesh_name ); mDEF_Map_Mesh[pIdxMesh] = mesh_name; // @@ -327,7 +327,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) { // remove last space symbol. coordIndex.resize(coordIndex.length() - 1); - attr_list.push_back({ "coordIndex", coordIndex }); + attr_list.emplace_back( "coordIndex", coordIndex ); // create node NodeHelper_OpenNode(NodeName_IFS, pTabLevel + 1, false, attr_list); attr_list.clear(); @@ -336,14 +336,14 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) { // Export AttrHelper_Vec3DArrToString(mesh.mVertices, mesh.mNumVertices, attr_value); - attr_list.push_back({ "point", attr_value }); + attr_list.emplace_back( "point", attr_value ); NodeHelper_OpenNode("Coordinate", pTabLevel + 2, true, attr_list); attr_list.clear(); // Export if (mesh.HasVertexColors(0)) { AttrHelper_Col4DArrToString(mesh.mColors[0], mesh.mNumVertices, attr_value); - attr_list.push_back({ "color", attr_value }); + attr_list.emplace_back( "color", attr_value ); NodeHelper_OpenNode("ColorRGBA", pTabLevel + 2, true, attr_list); attr_list.clear(); } @@ -351,7 +351,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) { // Export if (mesh.HasTextureCoords(0)) { AttrHelper_Vec3DAsVec2fArrToString(mesh.mTextureCoords[0], mesh.mNumVertices, attr_value); - attr_list.push_back({ "point", attr_value }); + attr_list.emplace_back( "point", attr_value ); NodeHelper_OpenNode("TextureCoordinate", pTabLevel + 2, true, attr_list); attr_list.clear(); } @@ -359,7 +359,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) { // Export if (mesh.HasNormals()) { AttrHelper_Vec3DArrToString(mesh.mNormals, mesh.mNumVertices, attr_value); - attr_list.push_back({ "vector", attr_value }); + attr_list.emplace_back( "vector", attr_value ); NodeHelper_OpenNode("Normal", pTabLevel + 2, true, attr_list); attr_list.clear(); } @@ -380,7 +380,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe // Check if material already defined early. if (mDEF_Map_Material.find(pIdxMaterial) != mDEF_Map_Material.end()) { // Material already defined, just refer to it - attr_list.push_back({ "USE", mDEF_Map_Material.at(pIdxMaterial) }); + attr_list.emplace_back( "USE", mDEF_Map_Material.at(pIdxMaterial) ); NodeHelper_OpenNode(NodeName_A, pTabLevel, true, attr_list); return; @@ -392,7 +392,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe if (material.Get(AI_MATKEY_NAME, ai_mat_name) == AI_SUCCESS) material_name.insert(0, ai_mat_name.C_Str()); // Define material name. - attr_list.push_back({ "DEF", material_name }); + attr_list.emplace_back( "DEF", material_name ); mDEF_Map_Material[pIdxMaterial] = material_name; // @@ -410,7 +410,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe if (aiColor3D(pAttrValue.r, pAttrValue.g, pAttrValue.b) != pAttrDefaultValue) { AttrHelper_Col4DArrToString(&pAttrValue, 1, tstr); - attr_list.push_back({ pAttrName, tstr }); + attr_list.emplace_back( pAttrName, tstr ); } }; @@ -462,7 +462,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe // { auto RepeatToAttrList = [&](const string &pAttrName, const bool pAttrValue) { - if (!pAttrValue) attr_list.push_back({ pAttrName, "false" }); + if (!pAttrValue) attr_list.emplace_back( pAttrName, "false" ); }; bool tvalb; @@ -473,7 +473,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe if (strncmp(tstring.C_Str(), AI_EMBEDDED_TEXNAME_PREFIX, strlen(AI_EMBEDDED_TEXNAME_PREFIX)) == 0) LogError("Embedded texture is not supported"); else - attr_list.push_back({ "url", string("\"") + tstring.C_Str() + "\"" }); + attr_list.emplace_back( "url", string("\"") + tstring.C_Str() + "\"" ); } // repeatS="true" SFBool @@ -495,7 +495,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe if (pAttrValue != pAttrDefaultValue) { AttrHelper_Vec2DArrToString(&pAttrValue, 1, tstr); - attr_list.push_back({ pAttrName, tstr }); + attr_list.emplace_back( pAttrName, tstr ); } }; @@ -520,40 +520,40 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe void X3DExporter::Export_MetadataBoolean(const aiString &pKey, const bool pValue, const size_t pTabLevel) { list attr_list; - attr_list.push_back({ "name", pKey.C_Str() }); - attr_list.push_back({ "value", pValue ? "true" : "false" }); + attr_list.emplace_back( "name", pKey.C_Str() ); + attr_list.emplace_back( "value", pValue ? "true" : "false" ); NodeHelper_OpenNode("MetadataBoolean", pTabLevel, true, attr_list); } void X3DExporter::Export_MetadataDouble(const aiString &pKey, const double pValue, const size_t pTabLevel) { list attr_list; - attr_list.push_back({ "name", pKey.C_Str() }); - attr_list.push_back({ "value", to_string(pValue) }); + attr_list.emplace_back( "name", pKey.C_Str() ); + attr_list.emplace_back( "value", to_string(pValue) ); NodeHelper_OpenNode("MetadataDouble", pTabLevel, true, attr_list); } void X3DExporter::Export_MetadataFloat(const aiString &pKey, const float pValue, const size_t pTabLevel) { list attr_list; - attr_list.push_back({ "name", pKey.C_Str() }); - attr_list.push_back({ "value", to_string(pValue) }); + attr_list.emplace_back( "name", pKey.C_Str() ); + attr_list.emplace_back( "value", to_string(pValue) ); NodeHelper_OpenNode("MetadataFloat", pTabLevel, true, attr_list); } void X3DExporter::Export_MetadataInteger(const aiString &pKey, const int32_t pValue, const size_t pTabLevel) { list attr_list; - attr_list.push_back({ "name", pKey.C_Str() }); - attr_list.push_back({ "value", to_string(pValue) }); + attr_list.emplace_back( "name", pKey.C_Str() ); + attr_list.emplace_back( "value", to_string(pValue) ); NodeHelper_OpenNode("MetadataInteger", pTabLevel, true, attr_list); } void X3DExporter::Export_MetadataString(const aiString &pKey, const aiString &pValue, const size_t pTabLevel) { list attr_list; - attr_list.push_back({ "name", pKey.C_Str() }); - attr_list.push_back({ "value", pValue.C_Str() }); + attr_list.emplace_back( "name", pKey.C_Str() ); + attr_list.emplace_back( "value", pValue.C_Str() ); NodeHelper_OpenNode("MetadataString", pTabLevel, true, attr_list); } @@ -565,7 +565,7 @@ bool X3DExporter::CheckAndExport_Light(const aiNode &pNode, const size_t pTabLev if (pAttrValue != pAttrDefaultValue) { AttrHelper_Vec3DArrToString(&pAttrValue, 1, tstr); - attr_list.push_back({ pAttrName, tstr }); + attr_list.emplace_back( pAttrName, tstr ); } }; @@ -590,8 +590,8 @@ bool X3DExporter::CheckAndExport_Light(const aiNode &pNode, const size_t pTabLev aiMatrix4x4 trafo_mat = Matrix_GlobalToCurrent(pNode).Inverse(); - attr_list.push_back({ "DEF", light.mName.C_Str() }); - attr_list.push_back({ "global", "true" }); // "false" is not supported. + attr_list.emplace_back( "DEF", light.mName.C_Str() ); + attr_list.emplace_back( "global", "true" ); // "false" is not supported. // ambientIntensity="0" SFFloat [inputOutput] AttrHelper_FloatToAttrList(attr_list, "ambientIntensity", aiVector3D(light.mColorAmbient.r, light.mColorAmbient.g, light.mColorAmbient.b).Length(), 0); // color="1 1 1" SFColor [inputOutput] @@ -648,10 +648,10 @@ X3DExporter::X3DExporter(const char *pFileName, IOSystem *pIOSystem, const aiSce XML_Write("\n"); XML_Write("\n"); // Root node - attr_list.push_back({ "profile", "Interchange" }); - attr_list.push_back({ "version", "3.3" }); - attr_list.push_back({ "xmlns:xsd", "http://www.w3.org/2001/XMLSchema-instance" }); - attr_list.push_back({ "xsd:noNamespaceSchemaLocation", "http://www.web3d.org/specifications/x3d-3.3.xsd" }); + attr_list.emplace_back( "profile", "Interchange" ); + attr_list.emplace_back( "version", "3.3" ); + attr_list.emplace_back( "xmlns:xsd", "http://www.w3.org/2001/XMLSchema-instance" ); + attr_list.emplace_back( "xsd:noNamespaceSchemaLocation", "http://www.web3d.org/specifications/x3d-3.3.xsd" ); NodeHelper_OpenNode("X3D", 0, false, attr_list); attr_list.clear(); // : meta data. diff --git a/code/AssetLib/X3D/X3DGeoHelper.cpp b/code/AssetLib/X3D/X3DGeoHelper.cpp index a9ac57e06..e89aeb428 100644 --- a/code/AssetLib/X3D/X3DGeoHelper.cpp +++ b/code/AssetLib/X3D/X3DGeoHelper.cpp @@ -193,7 +193,7 @@ void X3DGeoHelper::add_color(aiMesh &pMesh, const std::list &pColors, // create RGBA array from RGB. for (std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it) - tcol.push_back(aiColor4D((*it).r, (*it).g, (*it).b, 1)); + tcol.emplace_back((*it).r, (*it).g, (*it).b, 1); // call existing function for adding RGBA colors add_color(pMesh, tcol, pColorPerVertex); @@ -238,7 +238,7 @@ void X3DGeoHelper::add_color(aiMesh &pMesh, const std::vector &pCoordId // create RGBA array from RGB. for (std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it) { - tcol.push_back(aiColor4D((*it).r, (*it).g, (*it).b, 1)); + tcol.emplace_back((*it).r, (*it).g, (*it).b, 1); } // call existing function for adding RGBA colors @@ -440,7 +440,7 @@ void X3DGeoHelper::add_tex_coord(aiMesh &pMesh, const std::vector &pCoo // copy list to array because we are need indexed access to normals. texcoord_arr_copy.reserve(pTexCoords.size()); for (std::list::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) { - texcoord_arr_copy.push_back(aiVector3D((*it).x, (*it).y, 0)); + texcoord_arr_copy.emplace_back((*it).x, (*it).y, 0); } if (pTexCoordIdx.size() > 0) { @@ -480,7 +480,7 @@ void X3DGeoHelper::add_tex_coord(aiMesh &pMesh, const std::list &pTe // copy list to array because we are need convert aiVector2D to aiVector3D and also get indexed access as a bonus. tc_arr_copy.reserve(pTexCoords.size()); for (std::list::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) { - tc_arr_copy.push_back(aiVector3D((*it).x, (*it).y, 0)); + tc_arr_copy.emplace_back((*it).x, (*it).y, 0); } // copy texture coordinates to mesh diff --git a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp index 8d0f5bad9..e9a06c5e8 100644 --- a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp +++ b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp @@ -152,7 +152,7 @@ void X3DImporter::readArcClose2D(XmlNode &node) { std::list &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias. if ((closureType == "PIE") || (closureType == "\"PIE\"")) - vlist.push_back(aiVector3D(0, 0, 0)); // center point - first radial line + vlist.emplace_back(0, 0, 0); // center point - first radial line else if ((closureType != "CHORD") && (closureType != "\"CHORD\"")) Throw_IncorrectAttrValue("ArcClose2D", "closureType"); @@ -321,7 +321,7 @@ void X3DImporter::readPolyline2D(XmlNode &node) { // convert vec2 to vec3 for (std::list::iterator it2 = lineSegments.begin(); it2 != lineSegments.end(); ++it2) - tlist.push_back(aiVector3D(it2->x, it2->y, 0)); + tlist.emplace_back(it2->x, it2->y, 0); // convert point set to line set X3DGeoHelper::extend_point_to_line(tlist, ((X3DNodeElementGeometry2D *)ne)->Vertices); @@ -359,7 +359,7 @@ void X3DImporter::readPolypoint2D(XmlNode &node) { // convert vec2 to vec3 for (std::list::iterator it2 = point.begin(); it2 != point.end(); ++it2) { - ((X3DNodeElementGeometry2D *)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0)); + ((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, 0); } ((X3DNodeElementGeometry2D *)ne)->NumIndices = 1; @@ -403,10 +403,10 @@ void X3DImporter::readRectangle2D(XmlNode &node) { float y2 = size.y / 2.0f; std::list &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias. - vlist.push_back(aiVector3D(x2, y1, 0)); // 1st point - vlist.push_back(aiVector3D(x2, y2, 0)); // 2nd point - vlist.push_back(aiVector3D(x1, y2, 0)); // 3rd point - vlist.push_back(aiVector3D(x1, y1, 0)); // 4th point + vlist.emplace_back(x2, y1, 0); // 1st point + vlist.emplace_back(x2, y2, 0); // 2nd point + vlist.emplace_back(x1, y2, 0); // 3rd point + vlist.emplace_back(x1, y1, 0); // 4th point ((X3DNodeElementGeometry2D *)ne)->Solid = solid; ((X3DNodeElementGeometry2D *)ne)->NumIndices = 4; // check for X3DMetadataObject childs. @@ -447,7 +447,7 @@ void X3DImporter::readTriangleSet2D(XmlNode &node) { // convert vec2 to vec3 for (std::list::iterator it2 = vertices.begin(); it2 != vertices.end(); ++it2) { - ((X3DNodeElementGeometry2D *)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0)); + ((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, 0); } ((X3DNodeElementGeometry2D *)ne)->Solid = solid; diff --git a/code/Common/Exporter.cpp b/code/Common/Exporter.cpp index 9a4e2cf3d..afcefc3a7 100644 --- a/code/Common/Exporter.cpp +++ b/code/Common/Exporter.cpp @@ -146,73 +146,73 @@ static void setupExporterArray(std::vector &exporte (void)exporters; #ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada)); + exporters.emplace_back("collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada); #endif #ifndef ASSIMP_BUILD_NO_X_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("x", "X Files", "x", &ExportSceneXFile, - aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs)); + exporters.emplace_back("x", "X Files", "x", &ExportSceneXFile, + aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs); #endif #ifndef ASSIMP_BUILD_NO_STEP_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("stp", "Step Files", "stp", &ExportSceneStep, 0)); + exporters.emplace_back("stp", "Step Files", "stp", &ExportSceneStep, 0); #endif #ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("obj", "Wavefront OBJ format", "obj", &ExportSceneObj, - aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */)); - exporters.push_back(Exporter::ExportFormatEntry("objnomtl", "Wavefront OBJ format without material file", "obj", &ExportSceneObjNoMtl, - aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */)); + exporters.emplace_back("obj", "Wavefront OBJ format", "obj", &ExportSceneObj, + aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */); + exporters.emplace_back("objnomtl", "Wavefront OBJ format without material file", "obj", &ExportSceneObjNoMtl, + aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */); #endif #ifndef ASSIMP_BUILD_NO_STL_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("stl", "Stereolithography", "stl", &ExportSceneSTL, - aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices)); - exporters.push_back(Exporter::ExportFormatEntry("stlb", "Stereolithography (binary)", "stl", &ExportSceneSTLBinary, - aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices)); + exporters.emplace_back("stl", "Stereolithography", "stl", &ExportSceneSTL, + aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices); + exporters.emplace_back("stlb", "Stereolithography (binary)", "stl", &ExportSceneSTLBinary, + aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices); #endif #ifndef ASSIMP_BUILD_NO_PLY_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("ply", "Stanford Polygon Library", "ply", &ExportScenePly, - aiProcess_PreTransformVertices)); - exporters.push_back(Exporter::ExportFormatEntry("plyb", "Stanford Polygon Library (binary)", "ply", &ExportScenePlyBinary, - aiProcess_PreTransformVertices)); + exporters.emplace_back("ply", "Stanford Polygon Library", "ply", &ExportScenePly, + aiProcess_PreTransformVertices); + exporters.emplace_back("plyb", "Stanford Polygon Library (binary)", "ply", &ExportScenePlyBinary, + aiProcess_PreTransformVertices); #endif #ifndef ASSIMP_BUILD_NO_3DS_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("3ds", "Autodesk 3DS (legacy)", "3ds", &ExportScene3DS, - aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices)); + exporters.emplace_back("3ds", "Autodesk 3DS (legacy)", "3ds", &ExportScene3DS, + aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices); #endif #if !defined(ASSIMP_BUILD_NO_GLTF_EXPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_EXPORTER) - exporters.push_back(Exporter::ExportFormatEntry("gltf2", "GL Transmission Format v. 2", "gltf", &ExportSceneGLTF2, - aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType)); - exporters.push_back(Exporter::ExportFormatEntry("glb2", "GL Transmission Format v. 2 (binary)", "glb", &ExportSceneGLB2, - aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType)); + exporters.emplace_back("gltf2", "GL Transmission Format v. 2", "gltf", &ExportSceneGLTF2, + aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType); + exporters.emplace_back("glb2", "GL Transmission Format v. 2 (binary)", "glb", &ExportSceneGLB2, + aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType); #endif #if !defined(ASSIMP_BUILD_NO_GLTF_EXPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_EXPORTER) - exporters.push_back(Exporter::ExportFormatEntry("gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF, - aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType)); - exporters.push_back(Exporter::ExportFormatEntry("glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB, - aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType)); + exporters.emplace_back("gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF, + aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType); + exporters.emplace_back("glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB, + aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType); #endif #ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("assbin", "Assimp Binary File", "assbin", &ExportSceneAssbin, 0)); + exporters.emplace_back("assbin", "Assimp Binary File", "assbin", &ExportSceneAssbin, 0); #endif #ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("assxml", "Assimp XML Document", "assxml", &ExportSceneAssxml, 0)); + exporters.emplace_back("assxml", "Assimp XML Document", "assxml", &ExportSceneAssxml, 0); #endif #ifndef ASSIMP_BUILD_NO_X3D_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("x3d", "Extensible 3D", "x3d", &ExportSceneX3D, 0)); + exporters.emplace_back("x3d", "Extensible 3D", "x3d", &ExportSceneX3D, 0); #endif #ifndef ASSIMP_BUILD_NO_FBX_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("fbx", "Autodesk FBX (binary)", "fbx", &ExportSceneFBX, 0)); - exporters.push_back(Exporter::ExportFormatEntry("fbxa", "Autodesk FBX (ascii)", "fbx", &ExportSceneFBXA, 0)); + exporters.emplace_back("fbx", "Autodesk FBX (binary)", "fbx", &ExportSceneFBX, 0); + exporters.emplace_back("fbxa", "Autodesk FBX (ascii)", "fbx", &ExportSceneFBXA, 0); #endif #ifndef ASSIMP_BUILD_NO_M3D_EXPORTER @@ -221,15 +221,15 @@ static void setupExporterArray(std::vector &exporte #endif #ifndef ASSIMP_BUILD_NO_3MF_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0)); + exporters.emplace_back("3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0); #endif #ifndef ASSIMP_BUILD_NO_PBRT_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("pbrt", "pbrt-v4 scene description file", "pbrt", &ExportScenePbrt, aiProcess_Triangulate | aiProcess_SortByPType)); + exporters.emplace_back("pbrt", "pbrt-v4 scene description file", "pbrt", &ExportScenePbrt, aiProcess_Triangulate | aiProcess_SortByPType); #endif #ifndef ASSIMP_BUILD_NO_ASSJSON_EXPORTER - exporters.push_back(Exporter::ExportFormatEntry("assjson", "Assimp JSON Document", "json", &ExportAssimp2Json, 0)); + exporters.emplace_back("assjson", "Assimp JSON Document", "json", &ExportAssimp2Json, 0); #endif } diff --git a/code/Common/SGSpatialSort.cpp b/code/Common/SGSpatialSort.cpp index 0d16d6fe8..5a830b4dd 100644 --- a/code/Common/SGSpatialSort.cpp +++ b/code/Common/SGSpatialSort.cpp @@ -69,8 +69,8 @@ void SGSpatialSort::Add(const aiVector3D& vPosition, unsigned int index, { // store position by index and distance float distance = vPosition * mPlaneNormal; - mPositions.push_back( Entry( index, vPosition, - distance, smoothingGroup)); + mPositions.emplace_back( index, vPosition, + distance, smoothingGroup); } // ------------------------------------------------------------------------------------------------ void SGSpatialSort::Prepare() diff --git a/code/Common/SceneCombiner.cpp b/code/Common/SceneCombiner.cpp index 2c2539e54..0f5386b26 100644 --- a/code/Common/SceneCombiner.cpp +++ b/code/Common/SceneCombiner.cpp @@ -510,7 +510,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector &asBones, for (; it2 != end2; ++it2) { if ((*it2).first == itml) { - (*it2).pSrcBones.push_back(BoneSrcIndex(p, iOffset)); + (*it2).pSrcBones.emplace_back(p, iOffset); break; } } if (end2 == it2) { // need to begin a new bone entry - asBones.push_back(BoneWithHash()); + asBones.emplace_back(); BoneWithHash &btz = asBones.back(); // setup members btz.first = itml; btz.second = &p->mName; - btz.pSrcBones.push_back(BoneSrcIndex(p, iOffset)); + btz.pSrcBones.emplace_back(p, iOffset); } } iOffset += (*it)->mNumVertices; diff --git a/code/Common/SkeletonMeshBuilder.cpp b/code/Common/SkeletonMeshBuilder.cpp index d00b96d2d..bdb926b75 100644 --- a/code/Common/SkeletonMeshBuilder.cpp +++ b/code/Common/SkeletonMeshBuilder.cpp @@ -122,50 +122,50 @@ void SkeletonMeshBuilder::CreateGeometry(const aiNode *pNode) { mVertices.push_back(childpos); mVertices.push_back(-front * distanceToChild * (ai_real)0.1); - mFaces.push_back(Face(localVertexStart + 0, localVertexStart + 1, localVertexStart + 2)); - mFaces.push_back(Face(localVertexStart + 3, localVertexStart + 4, localVertexStart + 5)); - mFaces.push_back(Face(localVertexStart + 6, localVertexStart + 7, localVertexStart + 8)); - mFaces.push_back(Face(localVertexStart + 9, localVertexStart + 10, localVertexStart + 11)); + mFaces.emplace_back(localVertexStart + 0, localVertexStart + 1, localVertexStart + 2); + mFaces.emplace_back(localVertexStart + 3, localVertexStart + 4, localVertexStart + 5); + mFaces.emplace_back(localVertexStart + 6, localVertexStart + 7, localVertexStart + 8); + mFaces.emplace_back(localVertexStart + 9, localVertexStart + 10, localVertexStart + 11); } } else { // if the node has no children, it's an end node. Put a little knob there instead aiVector3D ownpos(pNode->mTransformation.a4, pNode->mTransformation.b4, pNode->mTransformation.c4); ai_real sizeEstimate = ownpos.Length() * ai_real(0.18); - mVertices.push_back(aiVector3D(-sizeEstimate, 0.0, 0.0)); - mVertices.push_back(aiVector3D(0.0, sizeEstimate, 0.0)); - mVertices.push_back(aiVector3D(0.0, 0.0, -sizeEstimate)); - mVertices.push_back(aiVector3D(0.0, sizeEstimate, 0.0)); - mVertices.push_back(aiVector3D(sizeEstimate, 0.0, 0.0)); - mVertices.push_back(aiVector3D(0.0, 0.0, -sizeEstimate)); - mVertices.push_back(aiVector3D(sizeEstimate, 0.0, 0.0)); - mVertices.push_back(aiVector3D(0.0, -sizeEstimate, 0.0)); - mVertices.push_back(aiVector3D(0.0, 0.0, -sizeEstimate)); - mVertices.push_back(aiVector3D(0.0, -sizeEstimate, 0.0)); - mVertices.push_back(aiVector3D(-sizeEstimate, 0.0, 0.0)); - mVertices.push_back(aiVector3D(0.0, 0.0, -sizeEstimate)); + mVertices.emplace_back(-sizeEstimate, 0.0, 0.0); + mVertices.emplace_back(0.0, sizeEstimate, 0.0); + mVertices.emplace_back(0.0, 0.0, -sizeEstimate); + mVertices.emplace_back(0.0, sizeEstimate, 0.0); + mVertices.emplace_back(sizeEstimate, 0.0, 0.0); + mVertices.emplace_back(0.0, 0.0, -sizeEstimate); + mVertices.emplace_back(sizeEstimate, 0.0, 0.0); + mVertices.emplace_back(0.0, -sizeEstimate, 0.0); + mVertices.emplace_back(0.0, 0.0, -sizeEstimate); + mVertices.emplace_back(0.0, -sizeEstimate, 0.0); + mVertices.emplace_back(-sizeEstimate, 0.0, 0.0); + mVertices.emplace_back(0.0, 0.0, -sizeEstimate); - mVertices.push_back(aiVector3D(-sizeEstimate, 0.0, 0.0)); - mVertices.push_back(aiVector3D(0.0, 0.0, sizeEstimate)); - mVertices.push_back(aiVector3D(0.0, sizeEstimate, 0.0)); - mVertices.push_back(aiVector3D(0.0, sizeEstimate, 0.0)); - mVertices.push_back(aiVector3D(0.0, 0.0, sizeEstimate)); - mVertices.push_back(aiVector3D(sizeEstimate, 0.0, 0.0)); - mVertices.push_back(aiVector3D(sizeEstimate, 0.0, 0.0)); - mVertices.push_back(aiVector3D(0.0, 0.0, sizeEstimate)); - mVertices.push_back(aiVector3D(0.0, -sizeEstimate, 0.0)); - mVertices.push_back(aiVector3D(0.0, -sizeEstimate, 0.0)); - mVertices.push_back(aiVector3D(0.0, 0.0, sizeEstimate)); - mVertices.push_back(aiVector3D(-sizeEstimate, 0.0, 0.0)); + mVertices.emplace_back(-sizeEstimate, 0.0, 0.0); + mVertices.emplace_back(0.0, 0.0, sizeEstimate); + mVertices.emplace_back(0.0, sizeEstimate, 0.0); + mVertices.emplace_back(0.0, sizeEstimate, 0.0); + mVertices.emplace_back(0.0, 0.0, sizeEstimate); + mVertices.emplace_back(sizeEstimate, 0.0, 0.0); + mVertices.emplace_back(sizeEstimate, 0.0, 0.0); + mVertices.emplace_back(0.0, 0.0, sizeEstimate); + mVertices.emplace_back(0.0, -sizeEstimate, 0.0); + mVertices.emplace_back(0.0, -sizeEstimate, 0.0); + mVertices.emplace_back(0.0, 0.0, sizeEstimate); + mVertices.emplace_back(-sizeEstimate, 0.0, 0.0); - mFaces.push_back(Face(vertexStartIndex + 0, vertexStartIndex + 1, vertexStartIndex + 2)); - mFaces.push_back(Face(vertexStartIndex + 3, vertexStartIndex + 4, vertexStartIndex + 5)); - mFaces.push_back(Face(vertexStartIndex + 6, vertexStartIndex + 7, vertexStartIndex + 8)); - mFaces.push_back(Face(vertexStartIndex + 9, vertexStartIndex + 10, vertexStartIndex + 11)); - mFaces.push_back(Face(vertexStartIndex + 12, vertexStartIndex + 13, vertexStartIndex + 14)); - mFaces.push_back(Face(vertexStartIndex + 15, vertexStartIndex + 16, vertexStartIndex + 17)); - mFaces.push_back(Face(vertexStartIndex + 18, vertexStartIndex + 19, vertexStartIndex + 20)); - mFaces.push_back(Face(vertexStartIndex + 21, vertexStartIndex + 22, vertexStartIndex + 23)); + mFaces.emplace_back(vertexStartIndex + 0, vertexStartIndex + 1, vertexStartIndex + 2); + mFaces.emplace_back(vertexStartIndex + 3, vertexStartIndex + 4, vertexStartIndex + 5); + mFaces.emplace_back(vertexStartIndex + 6, vertexStartIndex + 7, vertexStartIndex + 8); + mFaces.emplace_back(vertexStartIndex + 9, vertexStartIndex + 10, vertexStartIndex + 11); + mFaces.emplace_back(vertexStartIndex + 12, vertexStartIndex + 13, vertexStartIndex + 14); + mFaces.emplace_back(vertexStartIndex + 15, vertexStartIndex + 16, vertexStartIndex + 17); + mFaces.emplace_back(vertexStartIndex + 18, vertexStartIndex + 19, vertexStartIndex + 20); + mFaces.emplace_back(vertexStartIndex + 21, vertexStartIndex + 22, vertexStartIndex + 23); } unsigned int numVertices = static_cast(mVertices.size() - vertexStartIndex); diff --git a/code/Common/SpatialSort.cpp b/code/Common/SpatialSort.cpp index 6103002cc..676c5e202 100644 --- a/code/Common/SpatialSort.cpp +++ b/code/Common/SpatialSort.cpp @@ -116,7 +116,7 @@ void SpatialSort::Append(const aiVector3D *pPositions, unsigned int pNumPosition for (unsigned int a = 0; a < pNumPositions; a++) { const char *tempPointer = reinterpret_cast(pPositions); const aiVector3D *vec = reinterpret_cast(tempPointer + a * pElementOffset); - mPositions.push_back(Entry(static_cast(a + initial), *vec)); + mPositions.emplace_back(static_cast(a + initial), *vec); } if (pFinalize) { diff --git a/code/Common/StandardShapes.cpp b/code/Common/StandardShapes.cpp index e94b5b9af..351f03f87 100644 --- a/code/Common/StandardShapes.cpp +++ b/code/Common/StandardShapes.cpp @@ -422,15 +422,15 @@ void StandardShapes::MakeCone(ai_real height, ai_real radius1, if (!bOpen) { // generate the end 'cap' - positions.push_back(aiVector3D(s * radius2, halfHeight, t * radius2)); - positions.push_back(aiVector3D(s2 * radius2, halfHeight, t2 * radius2)); - positions.push_back(aiVector3D(0.0, halfHeight, 0.0)); + positions.emplace_back(s * radius2, halfHeight, t * radius2); + positions.emplace_back(s2 * radius2, halfHeight, t2 * radius2); + positions.emplace_back(0.0, halfHeight, 0.0); if (radius1) { // generate the other end 'cap' - positions.push_back(aiVector3D(s * radius1, -halfHeight, t * radius1)); - positions.push_back(aiVector3D(s2 * radius1, -halfHeight, t2 * radius1)); - positions.push_back(aiVector3D(0.0, -halfHeight, 0.0)); + positions.emplace_back(s * radius1, -halfHeight, t * radius1); + positions.emplace_back(s2 * radius1, -halfHeight, t2 * radius1); + positions.emplace_back(0.0, -halfHeight, 0.0); } } s = s2; @@ -466,13 +466,13 @@ void StandardShapes::MakeCircle(ai_real radius, unsigned int tess, ai_real t = 0.0; // std::sin(angle == 0); for (ai_real angle = 0.0; angle < angle_max;) { - positions.push_back(aiVector3D(s * radius, 0.0, t * radius)); + positions.emplace_back(s * radius, 0.0, t * radius); angle += angle_delta; s = std::cos(angle); t = std::sin(angle); - positions.push_back(aiVector3D(s * radius, 0.0, t * radius)); + positions.emplace_back(s * radius, 0.0, t * radius); - positions.push_back(aiVector3D(0.0, 0.0, 0.0)); + positions.emplace_back(0.0, 0.0, 0.0); } } diff --git a/code/PostProcessing/ProcessHelper.cpp b/code/PostProcessing/ProcessHelper.cpp index 6f0a79825..d819012d9 100644 --- a/code/PostProcessing/ProcessHelper.cpp +++ b/code/PostProcessing/ProcessHelper.cpp @@ -63,7 +63,7 @@ void ConvertListToStrings(const std::string &in, std::list &out) { return; } } - out.push_back(std::string(base, (size_t)(s - base))); + out.emplace_back(base, (size_t)(s - base)); ++s; } else { out.push_back(GetNextToken(s)); diff --git a/code/PostProcessing/SplitLargeMeshes.cpp b/code/PostProcessing/SplitLargeMeshes.cpp index 508a82669..b25bbf06d 100644 --- a/code/PostProcessing/SplitLargeMeshes.cpp +++ b/code/PostProcessing/SplitLargeMeshes.cpp @@ -316,13 +316,13 @@ void SplitLargeMeshesProcess_Triangle::SplitMesh( } // add the newly created mesh to the list - avList.push_back(std::pair(pcMesh,a)); + avList.emplace_back(pcMesh,a); } // now delete the old mesh data delete pMesh; } else { - avList.push_back(std::pair(pMesh,a)); + avList.emplace_back(pMesh,a); } } @@ -484,7 +484,7 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh( break; } - vFaces.push_back(aiFace()); + vFaces.emplace_back(); aiFace& rFace = vFaces.back(); // setup face type and number of indices @@ -605,7 +605,7 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh( } // add the newly created mesh to the list - avList.push_back(std::pair(pcMesh,a)); + avList.emplace_back(pcMesh,a); if (iBase == pMesh->mNumFaces) { // have all faces ... finish the outer loop, too @@ -620,5 +620,5 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh( delete pMesh; return; } - avList.push_back(std::pair(pMesh,a)); + avList.emplace_back(pMesh,a); } From b176061c4121a85545d0966ac14b67fcd957562d Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Tue, 23 Aug 2022 11:46:30 -0400 Subject: [PATCH 20/39] Remove extra space in emplace insertions --- code/AssetLib/DXF/DXFLoader.cpp | 6 +++--- code/AssetLib/Obj/ObjExporter.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp index bdc48e36c..3b77e0ea9 100644 --- a/code/AssetLib/DXF/DXFLoader.cpp +++ b/code/AssetLib/DXF/DXFLoader.cpp @@ -475,7 +475,7 @@ void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) { // ------------------------------------------------------------------------------------------------ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) { // push a new block onto the stack. - output.blocks.emplace_back( ); + output.blocks.emplace_back(); DXF::Block& block = output.blocks.back(); while( !reader.End() && !reader.Is(0,"ENDBLK")) { @@ -520,7 +520,7 @@ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) { // ------------------------------------------------------------------------------------------------ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) { // Push a new block onto the stack. - output.blocks.emplace_back( ); + output.blocks.emplace_back(); DXF::Block& block = output.blocks.back(); block.name = AI_DXF_ENTITIES_MAGIC_BLOCK; @@ -550,7 +550,7 @@ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) } void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output) { - output.blocks.back().insertions.emplace_back( ); + output.blocks.back().insertions.emplace_back(); DXF::InsertBlock& bl = output.blocks.back().insertions.back(); while( !reader.End() && !reader.Is(0)) { diff --git a/code/AssetLib/Obj/ObjExporter.cpp b/code/AssetLib/Obj/ObjExporter.cpp index a678110fc..502960a0b 100644 --- a/code/AssetLib/Obj/ObjExporter.cpp +++ b/code/AssetLib/Obj/ObjExporter.cpp @@ -333,7 +333,7 @@ void ObjExporter::WriteGeometryFile(bool noMtl) { // ------------------------------------------------------------------------------------------------ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat) { - mMeshes.emplace_back( ); + mMeshes.emplace_back(); MeshInstance& mesh = mMeshes.back(); if ( nullptr != m->mColors[ 0 ] ) { From 654ae3af4e7bc28f306416a7a36fe9bf3068ded8 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 24 Aug 2022 10:42:01 +0300 Subject: [PATCH 21/39] Fix out of bounds access in X3D loader --- code/AssetLib/X3D/X3DImporter_Geometry2D.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp index 8d0f5bad9..d8551de35 100644 --- a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp +++ b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp @@ -274,10 +274,10 @@ void X3DImporter::readDisk2D(XmlNode &node) { } // add last quad - vlist.push_back(*tlist_i.end()); // 1st point - vlist.push_back(*tlist_o.end()); // 2nd point - vlist.push_back(*tlist_o.begin()); // 3rd point - vlist.push_back(*tlist_o.begin()); // 4th point + vlist.push_back(tlist_i.back()); // 1st point + vlist.push_back(tlist_o.back()); // 2nd point + vlist.push_back(tlist_o.front()); // 3rd point + vlist.push_back(tlist_o.front()); // 4th point ((X3DNodeElementGeometry2D *)ne)->NumIndices = 4; } From 0d8723a3eba772a8f5b3f673b9a4d3f298c6a806 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 24 Aug 2022 10:43:40 +0300 Subject: [PATCH 22/39] Add FIXME comment --- code/AssetLib/X3D/X3DImporter_Geometry2D.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp index d8551de35..eda0f4f78 100644 --- a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp +++ b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp @@ -276,6 +276,7 @@ void X3DImporter::readDisk2D(XmlNode &node) { // add last quad vlist.push_back(tlist_i.back()); // 1st point vlist.push_back(tlist_o.back()); // 2nd point + // FIXME: one of these should probably be tlist_i.front() vlist.push_back(tlist_o.front()); // 3rd point vlist.push_back(tlist_o.front()); // 4th point From 659195d852938a21b469e6ef2fed3f65c6cd02b1 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 24 Aug 2022 11:17:10 +0200 Subject: [PATCH 23/39] Fix the fixme - Based on the implementation in top of the last one I guess I know how to fix that. - Replacing push_back by emplace_back --- code/AssetLib/X3D/X3DImporter_Geometry2D.cpp | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp index eda0f4f78..661202a8c 100644 --- a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp +++ b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp @@ -2,8 +2,7 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2019, assimp team - +Copyright (c) 2006-2022, assimp team All rights reserved. @@ -262,23 +261,25 @@ void X3DImporter::readDisk2D(XmlNode &node) { // // 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 for (std::list::iterator it_i = tlist_i.begin(), it_o = tlist_o.begin(); it_i != tlist_i.end();) { // do not forget - CCW direction - vlist.push_back(*it_i++); // 1st point - vlist.push_back(*it_o++); // 2nd point - vlist.push_back(*it_o); // 3rd point - vlist.push_back(*it_i); // 4th point + vlist.emplace_back(*it_i++); // 1st point + vlist.emplace_back(*it_o++); // 2nd point + vlist.emplace_back(*it_o); // 3rd point + vlist.emplace_back(*it_i); // 4th point } // add last quad - vlist.push_back(tlist_i.back()); // 1st point - vlist.push_back(tlist_o.back()); // 2nd point - // FIXME: one of these should probably be tlist_i.front() - vlist.push_back(tlist_o.front()); // 3rd point - vlist.push_back(tlist_o.front()); // 4th point + vlist.emplace_back(tlist_i.back()); // 1st point + vlist.emplace_back(tlist_o.back()); // 2nd point + vlist.emplace_back(tlist_o.front()); // 3rd point + vlist.emplace_back(tlist_i.front()); // 4th point ((X3DNodeElementGeometry2D *)ne)->NumIndices = 4; } From 6fa21dcc6ecca14ee9c09ef40cc3b3f02640d2bf Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Thu, 25 Aug 2022 11:19:26 -0400 Subject: [PATCH 24/39] Explicitly default all empty dtors --- code/AssetLib/BVH/BVHLoader.cpp | 2 +- code/AssetLib/Blender/BlenderTessellator.cpp | 4 +-- code/AssetLib/CSM/CSMLoader.cpp | 3 +- code/AssetLib/Collada/ColladaExporter.cpp | 3 +- code/AssetLib/FBX/FBXDeformer.cpp | 27 +++------------- code/AssetLib/FBX/FBXProperties.cpp | 32 ++++++++----------- code/AssetLib/FBX/FBXTokenizer.cpp | 4 +-- code/AssetLib/IFC/IFCLoader.cpp | 5 ++- code/AssetLib/Irr/IRRMeshLoader.cpp | 2 +- code/AssetLib/MD2/MD2Loader.cpp | 3 +- code/AssetLib/MD3/MD3Loader.cpp | 2 +- .../MDL/HalfLife/UniqueNameGenerator.cpp | 3 +- code/AssetLib/MS3D/MS3DLoader.cpp | 3 +- code/AssetLib/NDO/NDOLoader.cpp | 6 ++-- code/AssetLib/NFF/NFFLoader.cpp | 4 +-- code/AssetLib/OFF/OFFLoader.cpp | 6 ++-- code/AssetLib/Obj/ObjFileParser.cpp | 3 +- code/AssetLib/Ogre/OgreStructs.cpp | 6 ++-- code/AssetLib/OpenGEX/OpenGEXExporter.cpp | 6 ++-- code/Common/ZipArchiveIOSystem.cpp | 3 +- code/PostProcessing/ConvertToLHProcess.cpp | 17 ++++------ code/PostProcessing/FindInstancesProcess.cpp | 3 +- code/PostProcessing/RemoveVCProcess.cpp | 2 +- code/PostProcessing/ValidateDataStructure.cpp | 2 +- 24 files changed, 51 insertions(+), 100 deletions(-) diff --git a/code/AssetLib/BVH/BVHLoader.cpp b/code/AssetLib/BVH/BVHLoader.cpp index 0b9e286b7..0ce60ea1c 100644 --- a/code/AssetLib/BVH/BVHLoader.cpp +++ b/code/AssetLib/BVH/BVHLoader.cpp @@ -88,7 +88,7 @@ BVHLoader::BVHLoader() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -BVHLoader::~BVHLoader() {} +BVHLoader::~BVHLoader() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Blender/BlenderTessellator.cpp b/code/AssetLib/Blender/BlenderTessellator.cpp index d3d463ece..595d735d6 100644 --- a/code/AssetLib/Blender/BlenderTessellator.cpp +++ b/code/AssetLib/Blender/BlenderTessellator.cpp @@ -274,9 +274,7 @@ BlenderTessellatorP2T::BlenderTessellatorP2T( BlenderBMeshConverter& converter ) } // ------------------------------------------------------------------------------------------------ -BlenderTessellatorP2T::~BlenderTessellatorP2T( ) -{ -} +BlenderTessellatorP2T::~BlenderTessellatorP2T() = default; // ------------------------------------------------------------------------------------------------ void BlenderTessellatorP2T::Tessellate( const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices ) diff --git a/code/AssetLib/CSM/CSMLoader.cpp b/code/AssetLib/CSM/CSMLoader.cpp index 681f8602d..7bf736298 100644 --- a/code/AssetLib/CSM/CSMLoader.cpp +++ b/code/AssetLib/CSM/CSMLoader.cpp @@ -85,8 +85,7 @@ CSMImporter::CSMImporter() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -CSMImporter::~CSMImporter() -{} +CSMImporter::~CSMImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Collada/ColladaExporter.cpp b/code/AssetLib/Collada/ColladaExporter.cpp index 7a620fd53..40f49e65f 100644 --- a/code/AssetLib/Collada/ColladaExporter.cpp +++ b/code/AssetLib/Collada/ColladaExporter.cpp @@ -154,8 +154,7 @@ ColladaExporter::ColladaExporter(const aiScene *pScene, IOSystem *pIOSystem, con // ------------------------------------------------------------------------------------------------ // Destructor -ColladaExporter::~ColladaExporter() { -} +ColladaExporter::~ColladaExporter() = default; // ------------------------------------------------------------------------------------------------ // Starts writing the contents diff --git a/code/AssetLib/FBX/FBXDeformer.cpp b/code/AssetLib/FBX/FBXDeformer.cpp index ed6330666..df134a401 100644 --- a/code/AssetLib/FBX/FBXDeformer.cpp +++ b/code/AssetLib/FBX/FBXDeformer.cpp @@ -66,11 +66,7 @@ Deformer::Deformer(uint64_t id, const Element& element, const Document& doc, con } // ------------------------------------------------------------------------------------------------ -Deformer::~Deformer() -{ - -} - +Deformer::~Deformer() = default; // ------------------------------------------------------------------------------------------------ Cluster::Cluster(uint64_t id, const Element& element, const Document& doc, const std::string& name) @@ -119,11 +115,7 @@ Cluster::Cluster(uint64_t id, const Element& element, const Document& doc, const // ------------------------------------------------------------------------------------------------ -Cluster::~Cluster() -{ - -} - +Cluster::~Cluster() = default; // ------------------------------------------------------------------------------------------------ Skin::Skin(uint64_t id, const Element& element, const Document& doc, const std::string& name) @@ -152,10 +144,7 @@ Skin::Skin(uint64_t id, const Element& element, const Document& doc, const std:: // ------------------------------------------------------------------------------------------------ -Skin::~Skin() -{ - -} +Skin::~Skin() = default; // ------------------------------------------------------------------------------------------------ BlendShape::BlendShape(uint64_t id, const Element& element, const Document& doc, const std::string& name) : Deformer(id, element, doc, name) @@ -171,10 +160,7 @@ BlendShape::BlendShape(uint64_t id, const Element& element, const Document& doc, } } // ------------------------------------------------------------------------------------------------ -BlendShape::~BlendShape() -{ - -} +BlendShape::~BlendShape() = default; // ------------------------------------------------------------------------------------------------ BlendShapeChannel::BlendShapeChannel(uint64_t id, const Element& element, const Document& doc, const std::string& name) : Deformer(id, element, doc, name) @@ -199,10 +185,7 @@ BlendShapeChannel::BlendShapeChannel(uint64_t id, const Element& element, const } } // ------------------------------------------------------------------------------------------------ -BlendShapeChannel::~BlendShapeChannel() -{ - -} +BlendShapeChannel::~BlendShapeChannel() = default; // ------------------------------------------------------------------------------------------------ } } diff --git a/code/AssetLib/FBX/FBXProperties.cpp b/code/AssetLib/FBX/FBXProperties.cpp index 7803c27ff..1c050617d 100644 --- a/code/AssetLib/FBX/FBXProperties.cpp +++ b/code/AssetLib/FBX/FBXProperties.cpp @@ -60,29 +60,23 @@ namespace FBX { using namespace Util; // ------------------------------------------------------------------------------------------------ -Property::Property() -{ -} + Property::Property() = default; -// ------------------------------------------------------------------------------------------------ -Property::~Property() -{ -} + // ------------------------------------------------------------------------------------------------ + Property::~Property() = default; -namespace { + namespace { -void checkTokenCount(const TokenList& tok, unsigned int expectedCount) -{ - ai_assert(expectedCount >= 2); - if (tok.size() < expectedCount) { - const std::string& s = ParseTokenAsString(*tok[1]); - if (tok[1]->IsBinary()) { - throw DeadlyImportError("Not enough tokens for property of type ", s, " at offset ", tok[1]->Offset()); + void checkTokenCount(const TokenList &tok, unsigned int expectedCount) { + ai_assert(expectedCount >= 2); + if (tok.size() < expectedCount) { + const std::string &s = ParseTokenAsString(*tok[1]); + if (tok[1]->IsBinary()) { + throw DeadlyImportError("Not enough tokens for property of type ", s, " at offset ", tok[1]->Offset()); + } else { + throw DeadlyImportError("Not enough tokens for property of type ", s, " at line ", tok[1]->Line()); + } } - else { - throw DeadlyImportError("Not enough tokens for property of type ", s, " at line ", tok[1]->Line()); - } - } } // ------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/FBX/FBXTokenizer.cpp b/code/AssetLib/FBX/FBXTokenizer.cpp index 8698abac6..4ef4aff95 100644 --- a/code/AssetLib/FBX/FBXTokenizer.cpp +++ b/code/AssetLib/FBX/FBXTokenizer.cpp @@ -79,9 +79,7 @@ Token::Token(const char* sbegin, const char* send, TokenType type, unsigned int } // ------------------------------------------------------------------------------------------------ -Token::~Token() -{ -} +Token::~Token() = default; namespace { diff --git a/code/AssetLib/IFC/IFCLoader.cpp b/code/AssetLib/IFC/IFCLoader.cpp index 0c20686f4..90b627df8 100644 --- a/code/AssetLib/IFC/IFCLoader.cpp +++ b/code/AssetLib/IFC/IFCLoader.cpp @@ -120,12 +120,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -IFCImporter::IFCImporter() {} +IFCImporter::IFCImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -IFCImporter::~IFCImporter() { -} +IFCImporter::~IFCImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Irr/IRRMeshLoader.cpp b/code/AssetLib/Irr/IRRMeshLoader.cpp index 90b4d85af..c219e26f2 100644 --- a/code/AssetLib/Irr/IRRMeshLoader.cpp +++ b/code/AssetLib/Irr/IRRMeshLoader.cpp @@ -79,7 +79,7 @@ IRRMeshImporter::IRRMeshImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -IRRMeshImporter::~IRRMeshImporter() {} +IRRMeshImporter::~IRRMeshImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/MD2/MD2Loader.cpp b/code/AssetLib/MD2/MD2Loader.cpp index 99ab3f521..d3c9c67c9 100644 --- a/code/AssetLib/MD2/MD2Loader.cpp +++ b/code/AssetLib/MD2/MD2Loader.cpp @@ -102,8 +102,7 @@ MD2Importer::MD2Importer() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -MD2Importer::~MD2Importer() -{} +MD2Importer::~MD2Importer() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/MD3/MD3Loader.cpp b/code/AssetLib/MD3/MD3Loader.cpp index 4bd0a8a65..eae580ed8 100644 --- a/code/AssetLib/MD3/MD3Loader.cpp +++ b/code/AssetLib/MD3/MD3Loader.cpp @@ -345,7 +345,7 @@ MD3Importer::MD3Importer() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -MD3Importer::~MD3Importer() {} +MD3Importer::~MD3Importer() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp index 6fc8b118e..3cca8c558 100644 --- a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp +++ b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp @@ -68,8 +68,7 @@ UniqueNameGenerator::UniqueNameGenerator(const char *template_name, const char * separator_(separator) { } -UniqueNameGenerator::~UniqueNameGenerator() { -} +UniqueNameGenerator::~UniqueNameGenerator() = default; void UniqueNameGenerator::make_unique(std::vector &names) { struct DuplicateInfo { diff --git a/code/AssetLib/MS3D/MS3DLoader.cpp b/code/AssetLib/MS3D/MS3DLoader.cpp index 6ffc07aea..577078158 100644 --- a/code/AssetLib/MS3D/MS3DLoader.cpp +++ b/code/AssetLib/MS3D/MS3DLoader.cpp @@ -86,8 +86,7 @@ MS3DImporter::MS3DImporter() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -MS3DImporter::~MS3DImporter() -{} +MS3DImporter::~MS3DImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. bool MS3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const diff --git a/code/AssetLib/NDO/NDOLoader.cpp b/code/AssetLib/NDO/NDOLoader.cpp index 6594fe32c..1fac224b8 100644 --- a/code/AssetLib/NDO/NDOLoader.cpp +++ b/code/AssetLib/NDO/NDOLoader.cpp @@ -70,13 +70,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -NDOImporter::NDOImporter() -{} +NDOImporter::NDOImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -NDOImporter::~NDOImporter() -{} +NDOImporter::~NDOImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/NFF/NFFLoader.cpp b/code/AssetLib/NFF/NFFLoader.cpp index 3fd12fa2e..953b0d48e 100644 --- a/code/AssetLib/NFF/NFFLoader.cpp +++ b/code/AssetLib/NFF/NFFLoader.cpp @@ -73,11 +73,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -NFFImporter::NFFImporter() {} +NFFImporter::NFFImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -NFFImporter::~NFFImporter() {} +NFFImporter::~NFFImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/OFF/OFFLoader.cpp b/code/AssetLib/OFF/OFFLoader.cpp index 640e79249..f137f992d 100644 --- a/code/AssetLib/OFF/OFFLoader.cpp +++ b/code/AssetLib/OFF/OFFLoader.cpp @@ -73,13 +73,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -OFFImporter::OFFImporter() -{} +OFFImporter::OFFImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -OFFImporter::~OFFImporter() -{} +OFFImporter::~OFFImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Obj/ObjFileParser.cpp b/code/AssetLib/Obj/ObjFileParser.cpp index 7b0282c43..42bd23689 100644 --- a/code/AssetLib/Obj/ObjFileParser.cpp +++ b/code/AssetLib/Obj/ObjFileParser.cpp @@ -97,8 +97,7 @@ ObjFileParser::ObjFileParser(IOStreamBuffer &streamBuffer, const std::stri parseFile(streamBuffer); } -ObjFileParser::~ObjFileParser() { -} +ObjFileParser::~ObjFileParser() = default; void ObjFileParser::setBuffer(std::vector &buffer) { m_DataIt = buffer.begin(); diff --git a/code/AssetLib/Ogre/OgreStructs.cpp b/code/AssetLib/Ogre/OgreStructs.cpp index 444f7d14a..e2edc4f32 100644 --- a/code/AssetLib/Ogre/OgreStructs.cpp +++ b/code/AssetLib/Ogre/OgreStructs.cpp @@ -272,8 +272,7 @@ std::set IVertexData::ReferencedBonesByWeights() const { // VertexData -VertexData::VertexData() { -} +VertexData::VertexData() = default; VertexData::~VertexData() { Reset(); @@ -310,8 +309,7 @@ VertexElement *VertexData::GetVertexElement(VertexElement::Semantic semantic, ui // VertexDataXml -VertexDataXml::VertexDataXml() { -} +VertexDataXml::VertexDataXml() = default; bool VertexDataXml::HasPositions() const { return !positions.empty(); diff --git a/code/AssetLib/OpenGEX/OpenGEXExporter.cpp b/code/AssetLib/OpenGEX/OpenGEXExporter.cpp index 328c3c460..dae0dc056 100644 --- a/code/AssetLib/OpenGEX/OpenGEXExporter.cpp +++ b/code/AssetLib/OpenGEX/OpenGEXExporter.cpp @@ -46,11 +46,9 @@ namespace OpenGEX { #ifndef ASSIMP_BUILD_NO_OPENGEX_EXPORTER -OpenGEXExporter::OpenGEXExporter() { -} +OpenGEXExporter::OpenGEXExporter() = default; -OpenGEXExporter::~OpenGEXExporter() { -} +OpenGEXExporter::~OpenGEXExporter() = default; bool OpenGEXExporter::exportScene( const char * /*filename*/, const aiScene* /*pScene*/ ) { return true; diff --git a/code/Common/ZipArchiveIOSystem.cpp b/code/Common/ZipArchiveIOSystem.cpp index a29380838..3d5c72e27 100644 --- a/code/Common/ZipArchiveIOSystem.cpp +++ b/code/Common/ZipArchiveIOSystem.cpp @@ -279,8 +279,7 @@ ZipFile::ZipFile(std::string &filename, size_t size) : m_Buffer = std::unique_ptr(new uint8_t[m_Size]); } -ZipFile::~ZipFile() { -} +ZipFile::~ZipFile() = default; size_t ZipFile::Read(void *pvBuffer, size_t pSize, size_t pCount) { // Should be impossible diff --git a/code/PostProcessing/ConvertToLHProcess.cpp b/code/PostProcessing/ConvertToLHProcess.cpp index 4ded0fc15..359c5a284 100644 --- a/code/PostProcessing/ConvertToLHProcess.cpp +++ b/code/PostProcessing/ConvertToLHProcess.cpp @@ -81,16 +81,11 @@ void flipUVs(aiMeshType *pMesh) { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -MakeLeftHandedProcess::MakeLeftHandedProcess() : - BaseProcess() { - // empty -} +MakeLeftHandedProcess::MakeLeftHandedProcess() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -MakeLeftHandedProcess::~MakeLeftHandedProcess() { - // empty -} +MakeLeftHandedProcess::~MakeLeftHandedProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. @@ -250,11 +245,11 @@ void MakeLeftHandedProcess::ProcessAnimation(aiNodeAnim *pAnim) { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -FlipUVsProcess::FlipUVsProcess() {} +FlipUVsProcess::FlipUVsProcess() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -FlipUVsProcess::~FlipUVsProcess() {} +FlipUVsProcess::~FlipUVsProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. @@ -312,11 +307,11 @@ void FlipUVsProcess::ProcessMesh(aiMesh *pMesh) { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -FlipWindingOrderProcess::FlipWindingOrderProcess() {} +FlipWindingOrderProcess::FlipWindingOrderProcess() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -FlipWindingOrderProcess::~FlipWindingOrderProcess() {} +FlipWindingOrderProcess::~FlipWindingOrderProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/FindInstancesProcess.cpp b/code/PostProcessing/FindInstancesProcess.cpp index 7f8c93f77..07a0f66db 100644 --- a/code/PostProcessing/FindInstancesProcess.cpp +++ b/code/PostProcessing/FindInstancesProcess.cpp @@ -60,8 +60,7 @@ FindInstancesProcess::FindInstancesProcess() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -FindInstancesProcess::~FindInstancesProcess() -{} +FindInstancesProcess::~FindInstancesProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/RemoveVCProcess.cpp b/code/PostProcessing/RemoveVCProcess.cpp index 1107736e9..8bbe791f6 100644 --- a/code/PostProcessing/RemoveVCProcess.cpp +++ b/code/PostProcessing/RemoveVCProcess.cpp @@ -58,7 +58,7 @@ RemoveVCProcess::RemoveVCProcess() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -RemoveVCProcess::~RemoveVCProcess() {} +RemoveVCProcess::~RemoveVCProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/ValidateDataStructure.cpp b/code/PostProcessing/ValidateDataStructure.cpp index ebcfbbf5a..54889f34b 100644 --- a/code/PostProcessing/ValidateDataStructure.cpp +++ b/code/PostProcessing/ValidateDataStructure.cpp @@ -65,7 +65,7 @@ ValidateDSProcess::ValidateDSProcess() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -ValidateDSProcess::~ValidateDSProcess() {} +ValidateDSProcess::~ValidateDSProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. From e93fa6699a0ab029ca09e4ea04e5b281187086b7 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Thu, 25 Aug 2022 12:20:13 -0400 Subject: [PATCH 25/39] Manually fix up 100 more instances where it should be defaulted --- code/AssetLib/3DS/3DSExporter.cpp | 4 +--- code/AssetLib/3DS/3DSLoader.cpp | 4 +--- code/AssetLib/3MF/D3MFImporter.cpp | 9 ++------- code/AssetLib/AC/ACLoader.cpp | 4 +--- code/AssetLib/ASE/ASELoader.cpp | 4 +--- code/AssetLib/Blender/BlenderTessellator.cpp | 2 +- code/AssetLib/Blender/BlenderTessellator.h | 2 +- code/AssetLib/COB/COBLoader.cpp | 8 ++------ code/AssetLib/Collada/ColladaLoader.cpp | 4 +--- code/AssetLib/DXF/DXFLoader.cpp | 9 ++------- code/AssetLib/FBX/FBXMaterial.cpp | 12 +++--------- code/AssetLib/FBX/FBXMeshGeometry.cpp | 8 ++------ code/AssetLib/FBX/FBXTokenizer.cpp | 2 +- code/AssetLib/FBX/FBXTokenizer.h | 2 +- code/AssetLib/HMP/HMPLoader.cpp | 8 ++------ code/AssetLib/Irr/IRRLoader.cpp | 4 +--- code/AssetLib/LWO/LWOLoader.cpp | 4 +--- code/AssetLib/LWS/LWSLoader.cpp | 4 +--- code/AssetLib/MD5/MD5Loader.cpp | 4 +--- code/AssetLib/MDC/MDCLoader.cpp | 4 +--- code/AssetLib/MDL/MDLLoader.cpp | 4 +--- code/AssetLib/MMD/MMDImporter.cpp | 4 +--- code/AssetLib/Obj/ObjExporter.cpp | 4 +--- code/AssetLib/Obj/ObjFileMtlImporter.cpp | 4 +--- code/AssetLib/OpenGEX/OpenGEXExporter.cpp | 2 +- code/AssetLib/OpenGEX/OpenGEXExporter.h | 2 +- code/AssetLib/Ply/PlyExporter.cpp | 4 +--- code/AssetLib/Ply/PlyLoader.cpp | 4 +--- code/AssetLib/Q3D/Q3DLoader.cpp | 8 ++------ code/AssetLib/Raw/RawLoader.cpp | 8 ++------ code/AssetLib/SIB/SIBImporter.cpp | 8 ++------ code/AssetLib/SMD/SMDLoader.cpp | 9 +++------ code/AssetLib/Terragen/TerragenLoader.cpp | 4 +--- code/AssetLib/Unreal/UnrealLoader.cpp | 4 +--- code/AssetLib/X/XFileImporter.cpp | 4 +--- code/AssetLib/glTF/glTFImporter.cpp | 4 +--- code/AssetLib/glTF2/glTF2Exporter.cpp | 4 +--- code/AssetLib/glTF2/glTF2Importer.cpp | 4 +--- code/Common/BaseImporter.cpp | 4 +--- code/Common/Exporter.cpp | 13 ++----------- code/Common/SpatialSort.cpp | 4 +--- code/Pbrt/PbrtExporter.cpp | 4 +--- code/PostProcessing/ArmaturePopulate.cpp | 9 ++------- code/PostProcessing/CalcTangentsProcess.cpp | 4 +--- code/PostProcessing/ComputeUVMappingProcess.cpp | 10 ++-------- code/PostProcessing/DeboneProcess.cpp | 5 +---- code/PostProcessing/DropFaceNormalsProcess.cpp | 10 ++-------- code/PostProcessing/EmbedTexturesProcess.cpp | 9 ++------- code/PostProcessing/FindDegenerates.cpp | 4 +--- code/PostProcessing/FindInvalidDataProcess.cpp | 4 +--- code/PostProcessing/FixNormalsStep.cpp | 10 ++-------- code/PostProcessing/GenBoundingBoxesProcess.cpp | 9 ++------- code/PostProcessing/GenFaceNormalsProcess.cpp | 8 ++------ code/PostProcessing/GenVertexNormalsProcess.cpp | 4 +--- code/PostProcessing/ImproveCacheLocality.cpp | 4 +--- code/PostProcessing/JoinVerticesProcess.cpp | 8 ++------ code/PostProcessing/LimitBoneWeightsProcess.cpp | 5 +---- code/PostProcessing/MakeVerboseFormat.cpp | 8 ++------ code/PostProcessing/OptimizeGraph.cpp | 4 +--- code/PostProcessing/OptimizeMeshes.cpp | 4 +--- code/PostProcessing/RemoveRedundantMaterials.cpp | 5 +---- code/PostProcessing/ScaleProcess.cpp | 4 +--- code/PostProcessing/SortByPTypeProcess.cpp | 4 +--- code/PostProcessing/SplitByBoneCountProcess.cpp | 5 +---- code/PostProcessing/SplitLargeMeshes.cpp | 8 ++------ code/PostProcessing/TextureTransform.cpp | 5 +---- code/PostProcessing/TriangulateProcess.cpp | 10 ++-------- include/assimp/IOSystem.hpp | 4 +--- include/assimp/LogStream.hpp | 8 ++------ include/assimp/aabb.h | 4 +--- tools/assimp_cmd/CompareDump.cpp | 3 +-- 71 files changed, 96 insertions(+), 295 deletions(-) diff --git a/code/AssetLib/3DS/3DSExporter.cpp b/code/AssetLib/3DS/3DSExporter.cpp index 71588f935..1b335a272 100644 --- a/code/AssetLib/3DS/3DSExporter.cpp +++ b/code/AssetLib/3DS/3DSExporter.cpp @@ -209,9 +209,7 @@ Discreet3DSExporter::Discreet3DSExporter(std::shared_ptr &outfile, con } // ------------------------------------------------------------------------------------------------ -Discreet3DSExporter::~Discreet3DSExporter() { - // empty -} +Discreet3DSExporter::~Discreet3DSExporter() = default; // ------------------------------------------------------------------------------------------------ int Discreet3DSExporter::WriteHierarchy(const aiNode &node, int seq, int sibling_level) { diff --git a/code/AssetLib/3DS/3DSLoader.cpp b/code/AssetLib/3DS/3DSLoader.cpp index e6bc3a171..769e8a6ee 100644 --- a/code/AssetLib/3DS/3DSLoader.cpp +++ b/code/AssetLib/3DS/3DSLoader.cpp @@ -105,9 +105,7 @@ Discreet3DSImporter::Discreet3DSImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -Discreet3DSImporter::~Discreet3DSImporter() { - // empty -} +Discreet3DSImporter::~Discreet3DSImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/3MF/D3MFImporter.cpp b/code/AssetLib/3MF/D3MFImporter.cpp index 5b0f34c3a..5d9644fa5 100644 --- a/code/AssetLib/3MF/D3MFImporter.cpp +++ b/code/AssetLib/3MF/D3MFImporter.cpp @@ -81,14 +81,9 @@ static const aiImporterDesc desc = { "3mf" }; -D3MFImporter::D3MFImporter() : - BaseImporter() { - // empty -} +D3MFImporter::D3MFImporter() = default; -D3MFImporter::~D3MFImporter() { - // empty -} +D3MFImporter::~D3MFImporter() = default; bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool /*checkSig*/) const { if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) { diff --git a/code/AssetLib/AC/ACLoader.cpp b/code/AssetLib/AC/ACLoader.cpp index 410e04c2a..26bc2e9d5 100644 --- a/code/AssetLib/AC/ACLoader.cpp +++ b/code/AssetLib/AC/ACLoader.cpp @@ -146,9 +146,7 @@ AC3DImporter::AC3DImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -AC3DImporter::~AC3DImporter() { - // nothing to be done here -} +AC3DImporter::~AC3DImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/ASE/ASELoader.cpp b/code/AssetLib/ASE/ASELoader.cpp index 41f5639b5..f78ff99fb 100644 --- a/code/AssetLib/ASE/ASELoader.cpp +++ b/code/AssetLib/ASE/ASELoader.cpp @@ -89,9 +89,7 @@ ASEImporter::ASEImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -ASEImporter::~ASEImporter() { - // empty -} +ASEImporter::~ASEImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Blender/BlenderTessellator.cpp b/code/AssetLib/Blender/BlenderTessellator.cpp index 595d735d6..d3ef5ae5e 100644 --- a/code/AssetLib/Blender/BlenderTessellator.cpp +++ b/code/AssetLib/Blender/BlenderTessellator.cpp @@ -274,7 +274,7 @@ BlenderTessellatorP2T::BlenderTessellatorP2T( BlenderBMeshConverter& converter ) } // ------------------------------------------------------------------------------------------------ -BlenderTessellatorP2T::~BlenderTessellatorP2T() = default; + // ------------------------------------------------------------------------------------------------ void BlenderTessellatorP2T::Tessellate( const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices ) diff --git a/code/AssetLib/Blender/BlenderTessellator.h b/code/AssetLib/Blender/BlenderTessellator.h index 0d0ba320e..87703f99d 100644 --- a/code/AssetLib/Blender/BlenderTessellator.h +++ b/code/AssetLib/Blender/BlenderTessellator.h @@ -186,7 +186,7 @@ namespace Assimp { public: BlenderTessellatorP2T( BlenderBMeshConverter& converter ); - ~BlenderTessellatorP2T( ); + ~BlenderTessellatorP2T( ) = default; void Tessellate( const Blender::MLoop* polyLoop, int vertexCount, const std::vector< Blender::MVert >& vertices ); diff --git a/code/AssetLib/COB/COBLoader.cpp b/code/AssetLib/COB/COBLoader.cpp index 687f1cbd0..3e4c63b63 100644 --- a/code/AssetLib/COB/COBLoader.cpp +++ b/code/AssetLib/COB/COBLoader.cpp @@ -91,15 +91,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -COBImporter::COBImporter() { - // empty -} +COBImporter::COBImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -COBImporter::~COBImporter() { - // empty -} +COBImporter::~COBImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Collada/ColladaLoader.cpp b/code/AssetLib/Collada/ColladaLoader.cpp index fdc9c1c8f..405944f29 100644 --- a/code/AssetLib/Collada/ColladaLoader.cpp +++ b/code/AssetLib/Collada/ColladaLoader.cpp @@ -111,9 +111,7 @@ ColladaLoader::ColladaLoader() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -ColladaLoader::~ColladaLoader() { - // empty -} +ColladaLoader::~ColladaLoader() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp index 3b77e0ea9..f0091f01e 100644 --- a/code/AssetLib/DXF/DXFLoader.cpp +++ b/code/AssetLib/DXF/DXFLoader.cpp @@ -110,16 +110,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -DXFImporter::DXFImporter() -: BaseImporter() { - // empty -} +DXFImporter::DXFImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -DXFImporter::~DXFImporter() { - // empty -} +DXFImporter::~DXFImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp index 2162670f8..0db0ec6d7 100644 --- a/code/AssetLib/FBX/FBXMaterial.cpp +++ b/code/AssetLib/FBX/FBXMaterial.cpp @@ -136,9 +136,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con // ------------------------------------------------------------------------------------------------ -Material::~Material() { - // empty -} +Material::~Material() = default; aiVector2D uvTrans; aiVector2D uvScaling; @@ -255,9 +253,7 @@ Texture::Texture(uint64_t id, const Element& element, const Document& doc, const } -Texture::~Texture() { - // empty -} +Texture::~Texture() = default; LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Document& /*doc*/, const std::string& name) : Object(id,element,name), @@ -276,9 +272,7 @@ LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Docume } } -LayeredTexture::~LayeredTexture() { - // empty -} +LayeredTexture::~LayeredTexture() = default; void LayeredTexture::fillTexture(const Document& doc) { const std::vector& conns = doc.GetConnectionsByDestinationSequenced(ID()); diff --git a/code/AssetLib/FBX/FBXMeshGeometry.cpp b/code/AssetLib/FBX/FBXMeshGeometry.cpp index a0fb0e57e..58bacfad4 100644 --- a/code/AssetLib/FBX/FBXMeshGeometry.cpp +++ b/code/AssetLib/FBX/FBXMeshGeometry.cpp @@ -665,9 +665,7 @@ ShapeGeometry::ShapeGeometry(uint64_t id, const Element& element, const std::str } // ------------------------------------------------------------------------------------------------ -ShapeGeometry::~ShapeGeometry() { - // empty -} +ShapeGeometry::~ShapeGeometry() = default; // ------------------------------------------------------------------------------------------------ const std::vector& ShapeGeometry::GetVertices() const { return m_vertices; @@ -695,9 +693,7 @@ LineGeometry::LineGeometry(uint64_t id, const Element& element, const std::strin } // ------------------------------------------------------------------------------------------------ -LineGeometry::~LineGeometry() { - // empty -} +LineGeometry::~LineGeometry() = default; // ------------------------------------------------------------------------------------------------ const std::vector& LineGeometry::GetVertices() const { return m_vertices; diff --git a/code/AssetLib/FBX/FBXTokenizer.cpp b/code/AssetLib/FBX/FBXTokenizer.cpp index 4ef4aff95..f63e687e8 100644 --- a/code/AssetLib/FBX/FBXTokenizer.cpp +++ b/code/AssetLib/FBX/FBXTokenizer.cpp @@ -79,7 +79,7 @@ Token::Token(const char* sbegin, const char* send, TokenType type, unsigned int } // ------------------------------------------------------------------------------------------------ -Token::~Token() = default; + namespace { diff --git a/code/AssetLib/FBX/FBXTokenizer.h b/code/AssetLib/FBX/FBXTokenizer.h index 877950945..5ed48e61d 100644 --- a/code/AssetLib/FBX/FBXTokenizer.h +++ b/code/AssetLib/FBX/FBXTokenizer.h @@ -96,7 +96,7 @@ public: /** construct a binary token */ Token(const char* sbegin, const char* send, TokenType type, size_t offset); - ~Token(); + ~Token() = default; public: std::string StringContents() const { diff --git a/code/AssetLib/HMP/HMPLoader.cpp b/code/AssetLib/HMP/HMPLoader.cpp index 1625cb359..79fdae807 100644 --- a/code/AssetLib/HMP/HMPLoader.cpp +++ b/code/AssetLib/HMP/HMPLoader.cpp @@ -72,15 +72,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -HMPImporter::HMPImporter() { - // nothing to do here -} +HMPImporter::HMPImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -HMPImporter::~HMPImporter() { - // nothing to do here -} +HMPImporter::~HMPImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Irr/IRRLoader.cpp b/code/AssetLib/Irr/IRRLoader.cpp index 3103a6cc8..c4058a4c2 100644 --- a/code/AssetLib/Irr/IRRLoader.cpp +++ b/code/AssetLib/Irr/IRRLoader.cpp @@ -88,9 +88,7 @@ IRRImporter::IRRImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -IRRImporter::~IRRImporter() { - // empty -} +IRRImporter::~IRRImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp index 31b0befca..be7d54700 100644 --- a/code/AssetLib/LWO/LWOLoader.cpp +++ b/code/AssetLib/LWO/LWOLoader.cpp @@ -100,9 +100,7 @@ LWOImporter::LWOImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -LWOImporter::~LWOImporter() { - // empty -} +LWOImporter::~LWOImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp index f830fc7b6..c5de55035 100644 --- a/code/AssetLib/LWS/LWSLoader.cpp +++ b/code/AssetLib/LWS/LWSLoader.cpp @@ -141,9 +141,7 @@ LWSImporter::LWSImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -LWSImporter::~LWSImporter() { - // nothing to do here -} +LWSImporter::~LWSImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/MD5/MD5Loader.cpp b/code/AssetLib/MD5/MD5Loader.cpp index 2d5da4d92..6c6758356 100644 --- a/code/AssetLib/MD5/MD5Loader.cpp +++ b/code/AssetLib/MD5/MD5Loader.cpp @@ -94,9 +94,7 @@ MD5Importer::MD5Importer() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -MD5Importer::~MD5Importer() { - // empty -} +MD5Importer::~MD5Importer() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/MDC/MDCLoader.cpp b/code/AssetLib/MDC/MDCLoader.cpp index c96cc78fc..b107516de 100644 --- a/code/AssetLib/MDC/MDCLoader.cpp +++ b/code/AssetLib/MDC/MDCLoader.cpp @@ -105,9 +105,7 @@ MDCImporter::MDCImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -MDCImporter::~MDCImporter() { - // empty -} +MDCImporter::~MDCImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index 9c9cf910c..b2bd2d2f1 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -98,9 +98,7 @@ MDLImporter::MDLImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -MDLImporter::~MDLImporter() { - // empty -} +MDLImporter::~MDLImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/MMD/MMDImporter.cpp b/code/AssetLib/MMD/MMDImporter.cpp index 4445c2993..7a9030b64 100644 --- a/code/AssetLib/MMD/MMDImporter.cpp +++ b/code/AssetLib/MMD/MMDImporter.cpp @@ -83,9 +83,7 @@ MMDImporter::MMDImporter() : // ------------------------------------------------------------------------------------------------ // Destructor. -MMDImporter::~MMDImporter() { - // empty -} +MMDImporter::~MMDImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns true, if file is an pmx file. diff --git a/code/AssetLib/Obj/ObjExporter.cpp b/code/AssetLib/Obj/ObjExporter.cpp index 502960a0b..189164769 100644 --- a/code/AssetLib/Obj/ObjExporter.cpp +++ b/code/AssetLib/Obj/ObjExporter.cpp @@ -137,9 +137,7 @@ ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMt } // ------------------------------------------------------------------------------------------------ -ObjExporter::~ObjExporter() { - // empty -} +ObjExporter::~ObjExporter() = default; // ------------------------------------------------------------------------------------------------ std::string ObjExporter::GetMaterialLibName() { diff --git a/code/AssetLib/Obj/ObjFileMtlImporter.cpp b/code/AssetLib/Obj/ObjFileMtlImporter.cpp index 49a3af603..a0f6035ac 100644 --- a/code/AssetLib/Obj/ObjFileMtlImporter.cpp +++ b/code/AssetLib/Obj/ObjFileMtlImporter.cpp @@ -108,9 +108,7 @@ ObjFileMtlImporter::ObjFileMtlImporter(std::vector &buffer, // ------------------------------------------------------------------- // Destructor -ObjFileMtlImporter::~ObjFileMtlImporter() { - // empty -} +ObjFileMtlImporter::~ObjFileMtlImporter() = default; // ------------------------------------------------------------------- // Loads the material description diff --git a/code/AssetLib/OpenGEX/OpenGEXExporter.cpp b/code/AssetLib/OpenGEX/OpenGEXExporter.cpp index dae0dc056..f812d0ddb 100644 --- a/code/AssetLib/OpenGEX/OpenGEXExporter.cpp +++ b/code/AssetLib/OpenGEX/OpenGEXExporter.cpp @@ -48,7 +48,7 @@ namespace OpenGEX { OpenGEXExporter::OpenGEXExporter() = default; -OpenGEXExporter::~OpenGEXExporter() = default; + bool OpenGEXExporter::exportScene( const char * /*filename*/, const aiScene* /*pScene*/ ) { return true; diff --git a/code/AssetLib/OpenGEX/OpenGEXExporter.h b/code/AssetLib/OpenGEX/OpenGEXExporter.h index cc22c7d21..8e31b9ae3 100644 --- a/code/AssetLib/OpenGEX/OpenGEXExporter.h +++ b/code/AssetLib/OpenGEX/OpenGEXExporter.h @@ -55,7 +55,7 @@ namespace OpenGEX { class OpenGEXExporter { public: OpenGEXExporter(); - ~OpenGEXExporter(); + ~OpenGEXExporter() = default; bool exportScene( const char *filename, const aiScene* pScene ); }; diff --git a/code/AssetLib/Ply/PlyExporter.cpp b/code/AssetLib/Ply/PlyExporter.cpp index a98b83f67..9453e0d4d 100644 --- a/code/AssetLib/Ply/PlyExporter.cpp +++ b/code/AssetLib/Ply/PlyExporter.cpp @@ -245,9 +245,7 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina } // ------------------------------------------------------------------------------------------------ -PlyExporter::~PlyExporter() { - // empty -} +PlyExporter::~PlyExporter() = default; // ------------------------------------------------------------------------------------------------ void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components) diff --git a/code/AssetLib/Ply/PlyLoader.cpp b/code/AssetLib/Ply/PlyLoader.cpp index 6cf1a1c74..97ebca1fc 100644 --- a/code/AssetLib/Ply/PlyLoader.cpp +++ b/code/AssetLib/Ply/PlyLoader.cpp @@ -94,9 +94,7 @@ PLYImporter::PLYImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -PLYImporter::~PLYImporter() { - // empty -} +PLYImporter::~PLYImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp index 0e12620dc..5ea4f00e1 100644 --- a/code/AssetLib/Q3D/Q3DLoader.cpp +++ b/code/AssetLib/Q3D/Q3DLoader.cpp @@ -72,15 +72,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -Q3DImporter::Q3DImporter() { - // empty -} +Q3DImporter::Q3DImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -Q3DImporter::~Q3DImporter() { - // empty -} +Q3DImporter::~Q3DImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Raw/RawLoader.cpp b/code/AssetLib/Raw/RawLoader.cpp index 83d8ce37f..41a8f14db 100644 --- a/code/AssetLib/Raw/RawLoader.cpp +++ b/code/AssetLib/Raw/RawLoader.cpp @@ -72,15 +72,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -RAWImporter::RAWImporter() { - // empty -} +RAWImporter::RAWImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -RAWImporter::~RAWImporter() { - // empty -} +RAWImporter::~RAWImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/SIB/SIBImporter.cpp b/code/AssetLib/SIB/SIBImporter.cpp index 7b66afa44..323a69a00 100644 --- a/code/AssetLib/SIB/SIBImporter.cpp +++ b/code/AssetLib/SIB/SIBImporter.cpp @@ -202,15 +202,11 @@ static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -SIBImporter::SIBImporter() { - // empty -} +SIBImporter::SIBImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -SIBImporter::~SIBImporter() { - // empty -} +SIBImporter::~SIBImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index b4b6d3684..cbbc894ad 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -95,9 +95,7 @@ SMDImporter::SMDImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -SMDImporter::~SMDImporter() { - // empty -} +SMDImporter::~SMDImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. @@ -322,7 +320,7 @@ void SMDImporter::CreateOutputMeshes() { "to the vertex' parent node"); continue; } - aaiBones[pairval.first].push_back(TempWeightListEntry(iNum,pairval.second)); + aaiBones[pairval.first].emplace_back(iNum,pairval.second); fSum += pairval.second; } // ****************************************************************** @@ -350,8 +348,7 @@ void SMDImporter::CreateOutputMeshes() { } } } else { - aaiBones[face.avVertices[iVert].iParentNode].push_back( - TempWeightListEntry(iNum,1.0f-fSum)); + aaiBones[face.avVertices[iVert].iParentNode].emplace_back(iNum,1.0f-fSum); } } pcMesh->mFaces[iFace].mIndices[iVert] = iNum++; diff --git a/code/AssetLib/Terragen/TerragenLoader.cpp b/code/AssetLib/Terragen/TerragenLoader.cpp index c9c91db8f..dcf01461a 100644 --- a/code/AssetLib/Terragen/TerragenLoader.cpp +++ b/code/AssetLib/Terragen/TerragenLoader.cpp @@ -75,9 +75,7 @@ TerragenImporter::TerragenImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -TerragenImporter::~TerragenImporter() { - // empty -} +TerragenImporter::~TerragenImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Unreal/UnrealLoader.cpp b/code/AssetLib/Unreal/UnrealLoader.cpp index 6166701d6..439ac2988 100644 --- a/code/AssetLib/Unreal/UnrealLoader.cpp +++ b/code/AssetLib/Unreal/UnrealLoader.cpp @@ -174,9 +174,7 @@ UnrealImporter::UnrealImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -UnrealImporter::~UnrealImporter() { - // empty -} +UnrealImporter::~UnrealImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/X/XFileImporter.cpp b/code/AssetLib/X/XFileImporter.cpp index e1070d826..83e9a74f2 100644 --- a/code/AssetLib/X/XFileImporter.cpp +++ b/code/AssetLib/X/XFileImporter.cpp @@ -82,9 +82,7 @@ XFileImporter::XFileImporter() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -XFileImporter::~XFileImporter() { - // empty -} +XFileImporter::~XFileImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/glTF/glTFImporter.cpp b/code/AssetLib/glTF/glTFImporter.cpp index 4ba54ac23..20ff7e7c8 100644 --- a/code/AssetLib/glTF/glTFImporter.cpp +++ b/code/AssetLib/glTF/glTFImporter.cpp @@ -84,9 +84,7 @@ glTFImporter::glTFImporter() : // empty } -glTFImporter::~glTFImporter() { - // empty -} +glTFImporter::~glTFImporter() = default; const aiImporterDesc *glTFImporter::GetInfo() const { return &desc; diff --git a/code/AssetLib/glTF2/glTF2Exporter.cpp b/code/AssetLib/glTF2/glTF2Exporter.cpp index da7591d52..3bfe49fba 100644 --- a/code/AssetLib/glTF2/glTF2Exporter.cpp +++ b/code/AssetLib/glTF2/glTF2Exporter.cpp @@ -124,9 +124,7 @@ glTF2Exporter::glTF2Exporter(const char *filename, IOSystem *pIOSystem, const ai } } -glTF2Exporter::~glTF2Exporter() { - // empty -} +glTF2Exporter::~glTF2Exporter() = default; /* * Copy a 4x4 matrix from struct aiMatrix to typedef mat4. diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 4788ecd97..947edc8d5 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -103,9 +103,7 @@ glTF2Importer::glTF2Importer() : // empty } -glTF2Importer::~glTF2Importer() { - // empty -} +glTF2Importer::~glTF2Importer() = default; const aiImporterDesc *glTF2Importer::GetInfo() const { return &desc; diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index 383300ef1..0266b50a1 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -70,9 +70,7 @@ BaseImporter::BaseImporter() AI_NO_EXCEPT // ------------------------------------------------------------------------------------------------ // Destructor, private as well -BaseImporter::~BaseImporter() { - // nothing to do here -} +BaseImporter::~BaseImporter() = default; void BaseImporter::UpdateImporterScale(Importer *pImp) { ai_assert(pImp != nullptr); diff --git a/code/Common/Exporter.cpp b/code/Common/Exporter.cpp index afcefc3a7..b25b37d57 100644 --- a/code/Common/Exporter.cpp +++ b/code/Common/Exporter.cpp @@ -585,19 +585,10 @@ void Exporter::UnregisterExporter(const char* id) { } // ------------------------------------------------------------------------------------------------ -ExportProperties::ExportProperties() { - // empty -} +ExportProperties::ExportProperties() = default; // ------------------------------------------------------------------------------------------------ -ExportProperties::ExportProperties(const ExportProperties &other) -: mIntProperties(other.mIntProperties) -, mFloatProperties(other.mFloatProperties) -, mStringProperties(other.mStringProperties) -, mMatrixProperties(other.mMatrixProperties) -, mCallbackProperties(other.mCallbackProperties){ - // empty -} +ExportProperties::ExportProperties(const ExportProperties &other) = default; bool ExportProperties::SetPropertyCallback(const char *szName, const std::function &f) { return SetGenericProperty>(mCallbackProperties, szName, f); diff --git a/code/Common/SpatialSort.cpp b/code/Common/SpatialSort.cpp index 676c5e202..a35ebb055 100644 --- a/code/Common/SpatialSort.cpp +++ b/code/Common/SpatialSort.cpp @@ -73,9 +73,7 @@ SpatialSort::SpatialSort() : // ------------------------------------------------------------------------------------------------ // Destructor -SpatialSort::~SpatialSort() { - // empty -} +SpatialSort::~SpatialSort() = default; // ------------------------------------------------------------------------------------------------ void SpatialSort::Fill(const aiVector3D *pPositions, unsigned int pNumPositions, diff --git a/code/Pbrt/PbrtExporter.cpp b/code/Pbrt/PbrtExporter.cpp index 6a26d3261..a9f8656a4 100644 --- a/code/Pbrt/PbrtExporter.cpp +++ b/code/Pbrt/PbrtExporter.cpp @@ -162,9 +162,7 @@ PbrtExporter::PbrtExporter( } // Destructor -PbrtExporter::~PbrtExporter() { - // Empty -} +PbrtExporter::~PbrtExporter() = default; void PbrtExporter::WriteMetaData() { mOutput << "#############################\n"; diff --git a/code/PostProcessing/ArmaturePopulate.cpp b/code/PostProcessing/ArmaturePopulate.cpp index 44f1e2e14..a05cd91e9 100644 --- a/code/PostProcessing/ArmaturePopulate.cpp +++ b/code/PostProcessing/ArmaturePopulate.cpp @@ -48,15 +48,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { /// The default class constructor. -ArmaturePopulate::ArmaturePopulate() : - BaseProcess() { - // do nothing -} +ArmaturePopulate::ArmaturePopulate() = default; /// The class destructor. -ArmaturePopulate::~ArmaturePopulate() { - // do nothing -} +ArmaturePopulate::~ArmaturePopulate() = default; bool ArmaturePopulate::IsActive(unsigned int pFlags) const { return (pFlags & aiProcess_PopulateArmatureData) != 0; diff --git a/code/PostProcessing/CalcTangentsProcess.cpp b/code/PostProcessing/CalcTangentsProcess.cpp index b8847e473..efc457766 100644 --- a/code/PostProcessing/CalcTangentsProcess.cpp +++ b/code/PostProcessing/CalcTangentsProcess.cpp @@ -62,9 +62,7 @@ CalcTangentsProcess::CalcTangentsProcess() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -CalcTangentsProcess::~CalcTangentsProcess() { - // nothing to do here -} +CalcTangentsProcess::~CalcTangentsProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/ComputeUVMappingProcess.cpp b/code/PostProcessing/ComputeUVMappingProcess.cpp index ec8783041..237409f02 100644 --- a/code/PostProcessing/ComputeUVMappingProcess.cpp +++ b/code/PostProcessing/ComputeUVMappingProcess.cpp @@ -59,17 +59,11 @@ namespace { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -ComputeUVMappingProcess::ComputeUVMappingProcess() -{ - // nothing to do here -} +ComputeUVMappingProcess::ComputeUVMappingProcess() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -ComputeUVMappingProcess::~ComputeUVMappingProcess() -{ - // nothing to do here -} +ComputeUVMappingProcess::~ComputeUVMappingProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/DeboneProcess.cpp b/code/PostProcessing/DeboneProcess.cpp index e8cfb16b0..2412eb9d8 100644 --- a/code/PostProcessing/DeboneProcess.cpp +++ b/code/PostProcessing/DeboneProcess.cpp @@ -66,10 +66,7 @@ DeboneProcess::DeboneProcess() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -DeboneProcess::~DeboneProcess() -{ - // nothing to do here -} +DeboneProcess::~DeboneProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/DropFaceNormalsProcess.cpp b/code/PostProcessing/DropFaceNormalsProcess.cpp index 0cf17f909..f85daa588 100644 --- a/code/PostProcessing/DropFaceNormalsProcess.cpp +++ b/code/PostProcessing/DropFaceNormalsProcess.cpp @@ -56,17 +56,11 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -DropFaceNormalsProcess::DropFaceNormalsProcess() -{ - // nothing to do here -} +DropFaceNormalsProcess::DropFaceNormalsProcess() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -DropFaceNormalsProcess::~DropFaceNormalsProcess() -{ - // nothing to do here -} +DropFaceNormalsProcess::~DropFaceNormalsProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/EmbedTexturesProcess.cpp b/code/PostProcessing/EmbedTexturesProcess.cpp index 7ac4ddd4e..dc7e54ac1 100644 --- a/code/PostProcessing/EmbedTexturesProcess.cpp +++ b/code/PostProcessing/EmbedTexturesProcess.cpp @@ -49,14 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; -EmbedTexturesProcess::EmbedTexturesProcess() : - BaseProcess() { - // empty -} +EmbedTexturesProcess::EmbedTexturesProcess() = default; -EmbedTexturesProcess::~EmbedTexturesProcess() { - // empty -} +EmbedTexturesProcess::~EmbedTexturesProcess() = default; bool EmbedTexturesProcess::IsActive(unsigned int pFlags) const { return (pFlags & aiProcess_EmbedTextures) != 0; diff --git a/code/PostProcessing/FindDegenerates.cpp b/code/PostProcessing/FindDegenerates.cpp index 0bbf421d2..344979949 100644 --- a/code/PostProcessing/FindDegenerates.cpp +++ b/code/PostProcessing/FindDegenerates.cpp @@ -65,9 +65,7 @@ FindDegeneratesProcess::FindDegeneratesProcess() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -FindDegeneratesProcess::~FindDegeneratesProcess() { - // nothing to do here -} +FindDegeneratesProcess::~FindDegeneratesProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/FindInvalidDataProcess.cpp b/code/PostProcessing/FindInvalidDataProcess.cpp index b42cbe9a0..c65208cbd 100644 --- a/code/PostProcessing/FindInvalidDataProcess.cpp +++ b/code/PostProcessing/FindInvalidDataProcess.cpp @@ -62,9 +62,7 @@ FindInvalidDataProcess::FindInvalidDataProcess() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -FindInvalidDataProcess::~FindInvalidDataProcess() { - // nothing to do here -} +FindInvalidDataProcess::~FindInvalidDataProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/FixNormalsStep.cpp b/code/PostProcessing/FixNormalsStep.cpp index be0104214..3791bd35a 100644 --- a/code/PostProcessing/FixNormalsStep.cpp +++ b/code/PostProcessing/FixNormalsStep.cpp @@ -59,17 +59,11 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -FixInfacingNormalsProcess::FixInfacingNormalsProcess() -{ - // nothing to do here -} +FixInfacingNormalsProcess::FixInfacingNormalsProcess() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -FixInfacingNormalsProcess::~FixInfacingNormalsProcess() -{ - // nothing to do here -} +FixInfacingNormalsProcess::~FixInfacingNormalsProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/GenBoundingBoxesProcess.cpp b/code/PostProcessing/GenBoundingBoxesProcess.cpp index 1c20b6f94..52a0861e5 100644 --- a/code/PostProcessing/GenBoundingBoxesProcess.cpp +++ b/code/PostProcessing/GenBoundingBoxesProcess.cpp @@ -48,14 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { -GenBoundingBoxesProcess::GenBoundingBoxesProcess() -: BaseProcess() { +GenBoundingBoxesProcess::GenBoundingBoxesProcess() = default; -} - -GenBoundingBoxesProcess::~GenBoundingBoxesProcess() { - // empty -} +GenBoundingBoxesProcess::~GenBoundingBoxesProcess() = default; bool GenBoundingBoxesProcess::IsActive(unsigned int pFlags) const { return 0 != ( pFlags & aiProcess_GenBoundingBoxes ); diff --git a/code/PostProcessing/GenFaceNormalsProcess.cpp b/code/PostProcessing/GenFaceNormalsProcess.cpp index 517dd3b63..f104b98b6 100644 --- a/code/PostProcessing/GenFaceNormalsProcess.cpp +++ b/code/PostProcessing/GenFaceNormalsProcess.cpp @@ -56,15 +56,11 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -GenFaceNormalsProcess::GenFaceNormalsProcess() { - // nothing to do here -} +GenFaceNormalsProcess::GenFaceNormalsProcess() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -GenFaceNormalsProcess::~GenFaceNormalsProcess() { - // nothing to do here -} +GenFaceNormalsProcess::~GenFaceNormalsProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/GenVertexNormalsProcess.cpp b/code/PostProcessing/GenVertexNormalsProcess.cpp index 1a8afc597..0cb2bddb1 100644 --- a/code/PostProcessing/GenVertexNormalsProcess.cpp +++ b/code/PostProcessing/GenVertexNormalsProcess.cpp @@ -62,9 +62,7 @@ GenVertexNormalsProcess::GenVertexNormalsProcess() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -GenVertexNormalsProcess::~GenVertexNormalsProcess() { - // nothing to do here -} +GenVertexNormalsProcess::~GenVertexNormalsProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/ImproveCacheLocality.cpp b/code/PostProcessing/ImproveCacheLocality.cpp index 56bdfc447..197856171 100644 --- a/code/PostProcessing/ImproveCacheLocality.cpp +++ b/code/PostProcessing/ImproveCacheLocality.cpp @@ -70,9 +70,7 @@ ImproveCacheLocalityProcess::ImproveCacheLocalityProcess() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -ImproveCacheLocalityProcess::~ImproveCacheLocalityProcess() { - // nothing to do here -} +ImproveCacheLocalityProcess::~ImproveCacheLocalityProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/JoinVerticesProcess.cpp b/code/PostProcessing/JoinVerticesProcess.cpp index 745ce1a5e..fa4811c29 100644 --- a/code/PostProcessing/JoinVerticesProcess.cpp +++ b/code/PostProcessing/JoinVerticesProcess.cpp @@ -57,15 +57,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -JoinVerticesProcess::JoinVerticesProcess() { - // nothing to do here -} +JoinVerticesProcess::JoinVerticesProcess() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -JoinVerticesProcess::~JoinVerticesProcess() { - // nothing to do here -} +JoinVerticesProcess::~JoinVerticesProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/LimitBoneWeightsProcess.cpp b/code/PostProcessing/LimitBoneWeightsProcess.cpp index 63f6bf9f3..3192e07bc 100644 --- a/code/PostProcessing/LimitBoneWeightsProcess.cpp +++ b/code/PostProcessing/LimitBoneWeightsProcess.cpp @@ -62,10 +62,7 @@ LimitBoneWeightsProcess::LimitBoneWeightsProcess() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -LimitBoneWeightsProcess::~LimitBoneWeightsProcess() -{ - // nothing to do here -} +LimitBoneWeightsProcess::~LimitBoneWeightsProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/MakeVerboseFormat.cpp b/code/PostProcessing/MakeVerboseFormat.cpp index 75e2a0f06..085979fe9 100644 --- a/code/PostProcessing/MakeVerboseFormat.cpp +++ b/code/PostProcessing/MakeVerboseFormat.cpp @@ -50,13 +50,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; // ------------------------------------------------------------------------------------------------ -MakeVerboseFormatProcess::MakeVerboseFormatProcess() { - // nothing to do here -} +MakeVerboseFormatProcess::MakeVerboseFormatProcess() = default; // ------------------------------------------------------------------------------------------------ -MakeVerboseFormatProcess::~MakeVerboseFormatProcess() { - // nothing to do here -} +MakeVerboseFormatProcess::~MakeVerboseFormatProcess() = default; // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. void MakeVerboseFormatProcess::Execute(aiScene *pScene) { diff --git a/code/PostProcessing/OptimizeGraph.cpp b/code/PostProcessing/OptimizeGraph.cpp index ea44eb3c1..26b06e9b6 100644 --- a/code/PostProcessing/OptimizeGraph.cpp +++ b/code/PostProcessing/OptimizeGraph.cpp @@ -80,9 +80,7 @@ OptimizeGraphProcess::OptimizeGraphProcess() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -OptimizeGraphProcess::~OptimizeGraphProcess() { - // empty -} +OptimizeGraphProcess::~OptimizeGraphProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/OptimizeMeshes.cpp b/code/PostProcessing/OptimizeMeshes.cpp index e624bb1cf..a8c01e2d7 100644 --- a/code/PostProcessing/OptimizeMeshes.cpp +++ b/code/PostProcessing/OptimizeMeshes.cpp @@ -71,9 +71,7 @@ OptimizeMeshesProcess::OptimizeMeshesProcess() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -OptimizeMeshesProcess::~OptimizeMeshesProcess() { - // empty -} +OptimizeMeshesProcess::~OptimizeMeshesProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/RemoveRedundantMaterials.cpp b/code/PostProcessing/RemoveRedundantMaterials.cpp index ac2fa9790..3c3cd59e0 100644 --- a/code/PostProcessing/RemoveRedundantMaterials.cpp +++ b/code/PostProcessing/RemoveRedundantMaterials.cpp @@ -64,10 +64,7 @@ RemoveRedundantMatsProcess::RemoveRedundantMatsProcess() // ------------------------------------------------------------------------------------------------ // Destructor, private as well -RemoveRedundantMatsProcess::~RemoveRedundantMatsProcess() -{ - // nothing to do here -} +RemoveRedundantMatsProcess::~RemoveRedundantMatsProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/ScaleProcess.cpp b/code/PostProcessing/ScaleProcess.cpp index 0090f8dd7..34f68539a 100644 --- a/code/PostProcessing/ScaleProcess.cpp +++ b/code/PostProcessing/ScaleProcess.cpp @@ -52,9 +52,7 @@ ScaleProcess::ScaleProcess() , mScale( AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT ) { } -ScaleProcess::~ScaleProcess() { - // empty -} +ScaleProcess::~ScaleProcess() = default; void ScaleProcess::setScale( ai_real scale ) { mScale = scale; diff --git a/code/PostProcessing/SortByPTypeProcess.cpp b/code/PostProcessing/SortByPTypeProcess.cpp index c9268093e..0c5d78350 100644 --- a/code/PostProcessing/SortByPTypeProcess.cpp +++ b/code/PostProcessing/SortByPTypeProcess.cpp @@ -61,9 +61,7 @@ SortByPTypeProcess::SortByPTypeProcess() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -SortByPTypeProcess::~SortByPTypeProcess() { - // nothing to do here -} +SortByPTypeProcess::~SortByPTypeProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/SplitByBoneCountProcess.cpp b/code/PostProcessing/SplitByBoneCountProcess.cpp index ace62ae90..5e052b76a 100644 --- a/code/PostProcessing/SplitByBoneCountProcess.cpp +++ b/code/PostProcessing/SplitByBoneCountProcess.cpp @@ -67,10 +67,7 @@ SplitByBoneCountProcess::SplitByBoneCountProcess() // ------------------------------------------------------------------------------------------------ // Destructor -SplitByBoneCountProcess::~SplitByBoneCountProcess() -{ - // nothing to do here -} +SplitByBoneCountProcess::~SplitByBoneCountProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag. diff --git a/code/PostProcessing/SplitLargeMeshes.cpp b/code/PostProcessing/SplitLargeMeshes.cpp index b25bbf06d..151ac4991 100644 --- a/code/PostProcessing/SplitLargeMeshes.cpp +++ b/code/PostProcessing/SplitLargeMeshes.cpp @@ -56,9 +56,7 @@ SplitLargeMeshesProcess_Triangle::SplitLargeMeshesProcess_Triangle() { } // ------------------------------------------------------------------------------------------------ -SplitLargeMeshesProcess_Triangle::~SplitLargeMeshesProcess_Triangle() { - // nothing to do here -} +SplitLargeMeshesProcess_Triangle::~SplitLargeMeshesProcess_Triangle() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. @@ -332,9 +330,7 @@ SplitLargeMeshesProcess_Vertex::SplitLargeMeshesProcess_Vertex() { } // ------------------------------------------------------------------------------------------------ -SplitLargeMeshesProcess_Vertex::~SplitLargeMeshesProcess_Vertex() { - // nothing to do here -} +SplitLargeMeshesProcess_Vertex::~SplitLargeMeshesProcess_Vertex() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/TextureTransform.cpp b/code/PostProcessing/TextureTransform.cpp index 653506ec6..2699863d1 100644 --- a/code/PostProcessing/TextureTransform.cpp +++ b/code/PostProcessing/TextureTransform.cpp @@ -64,10 +64,7 @@ TextureTransformStep::TextureTransformStep() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -TextureTransformStep::~TextureTransformStep() -{ - // nothing to do here -} +TextureTransformStep::~TextureTransformStep() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/TriangulateProcess.cpp b/code/PostProcessing/TriangulateProcess.cpp index a18bf1c24..52e760361 100644 --- a/code/PostProcessing/TriangulateProcess.cpp +++ b/code/PostProcessing/TriangulateProcess.cpp @@ -159,17 +159,11 @@ namespace { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -TriangulateProcess::TriangulateProcess() -{ - // nothing to do here -} +TriangulateProcess::TriangulateProcess() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well -TriangulateProcess::~TriangulateProcess() -{ - // nothing to do here -} +TriangulateProcess::~TriangulateProcess() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/include/assimp/IOSystem.hpp b/include/assimp/IOSystem.hpp index e67a07515..b4531f96a 100644 --- a/include/assimp/IOSystem.hpp +++ b/include/assimp/IOSystem.hpp @@ -243,9 +243,7 @@ AI_FORCE_INLINE IOSystem::IOSystem() AI_NO_EXCEPT : } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE IOSystem::~IOSystem() { - // empty -} +AI_FORCE_INLINE IOSystem::~IOSystem() = default; // ---------------------------------------------------------------------------- // For compatibility, the interface of some functions taking a std::string was diff --git a/include/assimp/LogStream.hpp b/include/assimp/LogStream.hpp index 0ac74c609..3b17b200a 100644 --- a/include/assimp/LogStream.hpp +++ b/include/assimp/LogStream.hpp @@ -99,13 +99,9 @@ public: }; // !class LogStream -inline LogStream::LogStream() AI_NO_EXCEPT { - // empty -} +inline LogStream::LogStream() AI_NO_EXCEPT = default; -inline LogStream::~LogStream() { - // empty -} +inline LogStream::~LogStream() = default; } // Namespace Assimp diff --git a/include/assimp/aabb.h b/include/assimp/aabb.h index 51443bc20..fac77993d 100644 --- a/include/assimp/aabb.h +++ b/include/assimp/aabb.h @@ -73,9 +73,7 @@ struct aiAABB { } /// @brief The class destructor. - ~aiAABB() { - // empty - } + ~aiAABB() = default; #endif // __cplusplus }; diff --git a/tools/assimp_cmd/CompareDump.cpp b/tools/assimp_cmd/CompareDump.cpp index 49f680c24..4c2df2d9e 100644 --- a/tools/assimp_cmd/CompareDump.cpp +++ b/tools/assimp_cmd/CompareDump.cpp @@ -569,8 +569,7 @@ public: {} // - ~sliced_chunk_reader() { - } + ~sliced_chunk_reader() = default; public: From 9cd723e282252a05fb99c609550f88b3057d6242 Mon Sep 17 00:00:00 2001 From: "J.G.Adams" <82924084+JG-Adams@users.noreply.github.com> Date: Fri, 26 Aug 2022 19:12:11 -0400 Subject: [PATCH 26/39] Wrong object is created here! If I'm not mistaken. Because this is originally push_back(aniMeshVertex) instead of push_back(v). And the fact that aniMeshVertex is just getting created and destroyed for nothing. It need to be replaced with this then? A Clang-tidy syntax to create the same aniMeshVertex. I found this in pull request #4527 I think it may need to be reviewed too. --- code/PostProcessing/JoinVerticesProcess.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/PostProcessing/JoinVerticesProcess.cpp b/code/PostProcessing/JoinVerticesProcess.cpp index 745ce1a5e..84e742115 100644 --- a/code/PostProcessing/JoinVerticesProcess.cpp +++ b/code/PostProcessing/JoinVerticesProcess.cpp @@ -345,8 +345,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) { uniqueVertices.push_back(v); if (hasAnimMeshes) { for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) { - Vertex aniMeshVertex(pMesh->mAnimMeshes[animMeshIndex], a); - uniqueAnimatedVertices[animMeshIndex].push_back(v); + uniqueAnimatedVertices[animMeshIndex].emplace_back(pMesh->mAnimMeshes[animMeshIndex], a); } } } else{ From 14186bcd6b994bb0b455fc04a290280da6c0e6a3 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 27 Aug 2022 14:07:45 +0200 Subject: [PATCH 27/39] Code cleanup and some new unittests for edgecases. --- code/AssetLib/MMD/MMDPmdParser.h | 1034 ++++++++++++++++-------------- code/Common/Base64.cpp | 17 +- include/assimp/Base64.hpp | 30 +- test/unit/Common/utBase64.cpp | 41 +- 4 files changed, 604 insertions(+), 518 deletions(-) diff --git a/code/AssetLib/MMD/MMDPmdParser.h b/code/AssetLib/MMD/MMDPmdParser.h index 35e4f09d1..95d4d4552 100644 --- a/code/AssetLib/MMD/MMDPmdParser.h +++ b/code/AssetLib/MMD/MMDPmdParser.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2022, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -48,550 +47,595 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "MMDCpp14.h" -namespace pmd -{ - class PmdHeader - { - public: - std::string name; - std::string name_english; - std::string comment; - std::string comment_english; +namespace pmd { - bool Read(std::ifstream* stream) - { - char buffer[256]; - stream->read(buffer, 20); - name = std::string(buffer); - stream->read(buffer, 256); - comment = std::string(buffer); - return true; - } +struct PmdHeader { + std::string name; + std::string name_english; + std::string comment; + std::string comment_english; - bool ReadExtension(std::ifstream* stream) - { - char buffer[256]; - stream->read(buffer, 20); - name_english = std::string(buffer); - stream->read(buffer, 256); - comment_english = std::string(buffer); - return true; - } - }; + PmdHeader() = default; + ~PmdHeader() = default; - class PmdVertex - { - public: - float position[3]; + bool Read(std::ifstream *stream) { + if (stream == nullptr) { + return false; + } + char buffer[256] = {}; + stream->read(buffer, 20); + name = std::string(buffer); + stream->read(buffer, 256); + comment = std::string(buffer); + return true; + } - float normal[3]; + bool ReadExtension(std::ifstream *stream) { + if (stream == nullptr) { + return false; + } - float uv[2]; + char buffer[256] = {}; + stream->read(buffer, 20); + name_english = std::string(buffer); + stream->read(buffer, 256); + comment_english = std::string(buffer); - uint16_t bone_index[2]; + return true; + } +}; - uint8_t bone_weight; +struct PmdVertex { + float position[3]; + float normal[3]; + float uv[2]; + uint16_t bone_index[2]; + uint8_t bone_weight; + bool edge_invisible; - bool edge_invisible; + PmdVertex() : + position{ 0.0f }, normal{ 0.0f }, uv{ 0.0f }, bone_index{ 0 }, bone_weight(0), edge_invisible(false) {} - bool Read(std::ifstream* stream) - { - stream->read((char*) position, sizeof(float) * 3); - stream->read((char*) normal, sizeof(float) * 3); - stream->read((char*) uv, sizeof(float) * 2); - stream->read((char*) bone_index, sizeof(uint16_t) * 2); - stream->read((char*) &bone_weight, sizeof(uint8_t)); - stream->read((char*) &edge_invisible, sizeof(uint8_t)); - return true; - } - }; + ~PmdVertex() = default; - class PmdMaterial - { - public: - float diffuse[4]; - float power; - float specular[3]; - float ambient[3]; - uint8_t toon_index; - uint8_t edge_flag; - uint32_t index_count; - std::string texture_filename; - std::string sphere_filename; + bool Read(std::ifstream *stream) { + if (stream == nullptr) { + return false; + } - bool Read(std::ifstream* stream) - { - char buffer[20]; - stream->read((char*) &diffuse, sizeof(float) * 4); - stream->read((char*) &power, sizeof(float)); - stream->read((char*) &specular, sizeof(float) * 3); - stream->read((char*) &ambient, sizeof(float) * 3); - stream->read((char*) &toon_index, sizeof(uint8_t)); - stream->read((char*) &edge_flag, sizeof(uint8_t)); - stream->read((char*) &index_count, sizeof(uint32_t)); - stream->read((char*) &buffer, sizeof(char) * 20); - char* pstar = strchr(buffer, '*'); - if (nullptr == pstar) - { - texture_filename = std::string(buffer); - sphere_filename.clear(); - } - else { - *pstar = 0; - texture_filename = std::string(buffer); - sphere_filename = std::string(pstar+1); - } - return true; - } - }; + stream->read((char *)position, sizeof(float) * 3); + stream->read((char *)normal, sizeof(float) * 3); + stream->read((char *)uv, sizeof(float) * 2); + stream->read((char *)bone_index, sizeof(uint16_t) * 2); + stream->read((char *)&bone_weight, sizeof(uint8_t)); + stream->read((char *)&edge_invisible, sizeof(uint8_t)); + return true; + } +}; - enum class BoneType : uint8_t - { - Rotation, - RotationAndMove, - IkEffector, - Unknown, - IkEffectable, - RotationEffectable, - IkTarget, - Invisible, - Twist, - RotationMovement - }; +struct PmdMaterial { + float diffuse[4]; + float power; + float specular[3]; + float ambient[3]; + uint8_t toon_index; + uint8_t edge_flag; + uint32_t index_count; + std::string texture_filename; + std::string sphere_filename; - class PmdBone - { - public: - std::string name; - std::string name_english; - uint16_t parent_bone_index; - uint16_t tail_pos_bone_index; - BoneType bone_type; - uint16_t ik_parent_bone_index; - float bone_head_pos[3]; + PmdMaterial() : + diffuse{ 0.0f }, power(0.0f), specular{ 0.0f }, ambient{ 0.0f }, toon_index(0), edge_flag(0), index_count(0), texture_filename(), sphere_filename() {} - void Read(std::istream *stream) - { - char buffer[20]; - stream->read(buffer, 20); - name = std::string(buffer); - stream->read((char*) &parent_bone_index, sizeof(uint16_t)); - stream->read((char*) &tail_pos_bone_index, sizeof(uint16_t)); - stream->read((char*) &bone_type, sizeof(uint8_t)); - stream->read((char*) &ik_parent_bone_index, sizeof(uint16_t)); - stream->read((char*) &bone_head_pos, sizeof(float) * 3); - } + ~PmdMaterial() = default; - void ReadExpantion(std::istream *stream) - { - char buffer[20]; - stream->read(buffer, 20); - name_english = std::string(buffer); - } - }; + bool Read(std::ifstream *stream) { + if (stream == nullptr) { + return false; + } + constexpr size_t BufferSize = 20; - class PmdIk - { - public: - uint16_t ik_bone_index; - uint16_t target_bone_index; - uint16_t iterations; - float angle_limit; - std::vector ik_child_bone_index; + char buffer[BufferSize] = {}; + stream->read((char *)&diffuse, sizeof(float) * 4); + stream->read((char *)&power, sizeof(float)); + stream->read((char *)&specular, sizeof(float) * 3); + stream->read((char *)&ambient, sizeof(float) * 3); + stream->read((char *)&toon_index, sizeof(uint8_t)); + stream->read((char *)&edge_flag, sizeof(uint8_t)); + stream->read((char *)&index_count, sizeof(uint32_t)); + stream->read((char *)&buffer, sizeof(char) * BufferSize); + char *pstar = strchr(buffer, '*'); + if (nullptr == pstar) { + texture_filename = std::string(buffer); + sphere_filename.clear(); + } else { + *pstar = 0; + texture_filename = std::string(buffer); + sphere_filename = std::string(pstar + 1); + } - void Read(std::istream *stream) - { - stream->read((char *) &ik_bone_index, sizeof(uint16_t)); - stream->read((char *) &target_bone_index, sizeof(uint16_t)); - uint8_t ik_chain_length; - stream->read((char*) &ik_chain_length, sizeof(uint8_t)); - stream->read((char *) &iterations, sizeof(uint16_t)); - stream->read((char *) &angle_limit, sizeof(float)); - ik_child_bone_index.resize(ik_chain_length); - for (int i = 0; i < ik_chain_length; i++) - { - stream->read((char *) &ik_child_bone_index[i], sizeof(uint16_t)); - } - } - }; + return true; + } +}; - class PmdFaceVertex - { - public: - int vertex_index; - float position[3]; +enum class BoneType : uint8_t { + Rotation, + RotationAndMove, + IkEffector, + Unknown, + IkEffectable, + RotationEffectable, + IkTarget, + Invisible, + Twist, + RotationMovement - void Read(std::istream *stream) - { - stream->read((char *) &vertex_index, sizeof(int)); - stream->read((char *) position, sizeof(float) * 3); - } - }; +}; - enum class FaceCategory : uint8_t - { - Base, - Eyebrow, - Eye, - Mouth, - Other - }; +struct PmdBone { + std::string name; + std::string name_english; + uint16_t parent_bone_index; + uint16_t tail_pos_bone_index; + BoneType bone_type; + uint16_t ik_parent_bone_index; + float bone_head_pos[3]; - class PmdFace - { - public: - std::string name; - FaceCategory type; - std::vector vertices; - std::string name_english; + PmdBone() : + name(), name_english(), parent_bone_index(0), tail_pos_bone_index(0), bone_type(BoneType::Unknown), ik_parent_bone_index(0), bone_head_pos{ 0.0f } {} - void Read(std::istream *stream) - { - char buffer[20]; - stream->read(buffer, 20); - name = std::string(buffer); - int vertex_count; - stream->read((char*) &vertex_count, sizeof(int)); - stream->read((char*) &type, sizeof(uint8_t)); - vertices.resize(vertex_count); - for (int i = 0; i < vertex_count; i++) - { - vertices[i].Read(stream); - } - } + ~PmdBone() = default; - void ReadExpantion(std::istream *stream) - { - char buffer[20]; - stream->read(buffer, 20); - name_english = std::string(buffer); - } - }; + void Read(std::istream *stream) { + if (stream == nullptr) { + return; + } + constexpr size_t BufferSize = 20; + char buffer[BufferSize] = {}; + stream->read(buffer, BufferSize); + name = std::string(buffer); + stream->read((char *)&parent_bone_index, sizeof(uint16_t)); + stream->read((char *)&tail_pos_bone_index, sizeof(uint16_t)); + stream->read((char *)&bone_type, sizeof(uint8_t)); + stream->read((char *)&ik_parent_bone_index, sizeof(uint16_t)); + stream->read((char *)&bone_head_pos, sizeof(float) * 3); + } - class PmdBoneDispName - { - public: - std::string bone_disp_name; - std::string bone_disp_name_english; + void ReadExpantion(std::istream *stream) { + if (stream == nullptr) { + return; + } + constexpr size_t BufferSize = 20; + char buffer[BufferSize] = {}; + stream->read(buffer, BufferSize); + name_english = std::string(buffer); + } +}; - void Read(std::istream *stream) - { - char buffer[50]; - stream->read(buffer, 50); - bone_disp_name = std::string(buffer); - bone_disp_name_english.clear(); - } - void ReadExpantion(std::istream *stream) - { - char buffer[50]; - stream->read(buffer, 50); - bone_disp_name_english = std::string(buffer); - } - }; +struct PmdIk { + uint16_t ik_bone_index; + uint16_t target_bone_index; + uint16_t iterations; + float angle_limit; + std::vector ik_child_bone_index; - class PmdBoneDisp - { - public: - uint16_t bone_index; - uint8_t bone_disp_index; + PmdIk() : + ik_child_bone_index(0), target_bone_index(0), iterations(0), angle_limit(0.0f) {} - void Read(std::istream *stream) - { - stream->read((char*) &bone_index, sizeof(uint16_t)); - stream->read((char*) &bone_disp_index, sizeof(uint8_t)); - } - }; + ~PmdIk() = default; - enum class RigidBodyShape : uint8_t - { - Sphere = 0, - Box = 1, - Cpusel = 2 - }; + void Read(std::istream *stream) { + if (stream == nullptr) { + return; + } - enum class RigidBodyType : uint8_t - { - BoneConnected = 0, - Physics = 1, - ConnectedPhysics = 2 - }; + stream->read((char *)&ik_bone_index, sizeof(uint16_t)); + stream->read((char *)&target_bone_index, sizeof(uint16_t)); + uint8_t ik_chain_length; + stream->read((char *)&ik_chain_length, sizeof(uint8_t)); + stream->read((char *)&iterations, sizeof(uint16_t)); + stream->read((char *)&angle_limit, sizeof(float)); + ik_child_bone_index.resize(ik_chain_length); + for (int i = 0; i < ik_chain_length; i++) { + stream->read((char *)&ik_child_bone_index[i], sizeof(uint16_t)); + } + } +}; - class PmdRigidBody - { - public: - std::string name; - uint16_t related_bone_index; - uint8_t group_index; - uint16_t mask; - RigidBodyShape shape; - float size[3]; - float position[3]; - float orientation[3]; - float weight; - float linear_damping; - float anglar_damping; - float restitution; - float friction; - RigidBodyType rigid_type; +struct PmdFaceVertex { + int vertex_index; + float position[3]; - void Read(std::istream *stream) - { - char buffer[20]; - stream->read(buffer, sizeof(char) * 20); - name = (std::string(buffer)); - stream->read((char*) &related_bone_index, sizeof(uint16_t)); - stream->read((char*) &group_index, sizeof(uint8_t)); - stream->read((char*) &mask, sizeof(uint16_t)); - stream->read((char*) &shape, sizeof(uint8_t)); - stream->read((char*) size, sizeof(float) * 3); - stream->read((char*) position, sizeof(float) * 3); - stream->read((char*) orientation, sizeof(float) * 3); - stream->read((char*) &weight, sizeof(float)); - stream->read((char*) &linear_damping, sizeof(float)); - stream->read((char*) &anglar_damping, sizeof(float)); - stream->read((char*) &restitution, sizeof(float)); - stream->read((char*) &friction, sizeof(float)); - stream->read((char*) &rigid_type, sizeof(char)); - } - }; + PmdFaceVertex() : + vertex_index(0), position{ 0.0f } {} - class PmdConstraint - { - public: - std::string name; - uint32_t rigid_body_index_a; - uint32_t rigid_body_index_b; - float position[3]; - float orientation[3]; - float linear_lower_limit[3]; - float linear_upper_limit[3]; - float angular_lower_limit[3]; - float angular_upper_limit[3]; - float linear_stiffness[3]; - float angular_stiffness[3]; + ~PmdFaceVertex() = default; - void Read(std::istream *stream) - { - char buffer[20]; - stream->read(buffer, 20); - name = std::string(buffer); - stream->read((char *) &rigid_body_index_a, sizeof(uint32_t)); - stream->read((char *) &rigid_body_index_b, sizeof(uint32_t)); - stream->read((char *) position, sizeof(float) * 3); - stream->read((char *) orientation, sizeof(float) * 3); - stream->read((char *) linear_lower_limit, sizeof(float) * 3); - stream->read((char *) linear_upper_limit, sizeof(float) * 3); - stream->read((char *) angular_lower_limit, sizeof(float) * 3); - stream->read((char *) angular_upper_limit, sizeof(float) * 3); - stream->read((char *) linear_stiffness, sizeof(float) * 3); - stream->read((char *) angular_stiffness, sizeof(float) * 3); - } - }; + void Read(std::istream *stream) { + if (stream == nullptr) { + return; + } + stream->read((char *)&vertex_index, sizeof(int)); + stream->read((char *)position, sizeof(float) * 3); + } +}; - class PmdModel - { - public: - float version; - PmdHeader header; - std::vector vertices; - std::vector indices; - std::vector materials; - std::vector bones; - std::vector iks; - std::vector faces; - std::vector faces_indices; - std::vector bone_disp_name; - std::vector bone_disp; - std::vector toon_filenames; - std::vector rigid_bodies; - std::vector constraints; +enum class FaceCategory : uint8_t { + Base, + Eyebrow, + Eye, + Mouth, + Other +}; - static std::unique_ptr LoadFromFile(const char *filename) - { - std::ifstream stream(filename, std::ios::binary); - if (stream.fail()) - { - std::cerr << "could not open \"" << filename << "\"" << std::endl; - return nullptr; - } - auto result = LoadFromStream(&stream); - stream.close(); - return result; - } +struct PmdFace { + std::string name; + FaceCategory type; + std::vector vertices; + std::string name_english; - static std::unique_ptr LoadFromStream(std::ifstream *stream) - { - auto result = mmd::make_unique(); - char buffer[100]; + PmdFace() : + name(), type(FaceCategory::Other), vertices(), name_english() {} - // magic - char magic[3]; - stream->read(magic, 3); - if (magic[0] != 'P' || magic[1] != 'm' || magic[2] != 'd') - { - std::cerr << "invalid file" << std::endl; - return nullptr; - } + ~PmdFace() = default; - // version - stream->read((char*) &(result->version), sizeof(float)); - if (result ->version != 1.0f) - { - std::cerr << "invalid version" << std::endl; - return nullptr; - } + void Read(std::istream *stream) { + if (stream == nullptr) { + return; + } + constexpr size_t BufferSize = 20; + char buffer[BufferSize]; + stream->read(buffer, BufferSize); + name = std::string(buffer); + int vertex_count; + stream->read((char *)&vertex_count, sizeof(int)); + stream->read((char *)&type, sizeof(uint8_t)); + vertices.resize(vertex_count); + for (int i = 0; i < vertex_count; i++) { + vertices[i].Read(stream); + } + } - // header - result->header.Read(stream); + void ReadExpantion(std::istream *stream) { + if (stream == nullptr) { + return; + } - // vertices - uint32_t vertex_num; - stream->read((char*) &vertex_num, sizeof(uint32_t)); - result->vertices.resize(vertex_num); - for (uint32_t i = 0; i < vertex_num; i++) - { - result->vertices[i].Read(stream); - } + char buffer[20]; + stream->read(buffer, 20); + name_english = std::string(buffer); + } +}; - // indices - uint32_t index_num; - stream->read((char*) &index_num, sizeof(uint32_t)); - result->indices.resize(index_num); - for (uint32_t i = 0; i < index_num; i++) - { - stream->read((char*) &result->indices[i], sizeof(uint16_t)); - } +struct PmdBoneDispName { + std::string bone_disp_name; + std::string bone_disp_name_english; - // materials - uint32_t material_num; - stream->read((char*) &material_num, sizeof(uint32_t)); - result->materials.resize(material_num); - for (uint32_t i = 0; i < material_num; i++) - { - result->materials[i].Read(stream); - } + PmdBoneDispName() = default; - // bones - uint16_t bone_num; - stream->read((char*) &bone_num, sizeof(uint16_t)); - result->bones.resize(bone_num); - for (uint32_t i = 0; i < bone_num; i++) - { - result->bones[i].Read(stream); - } + ~PmdBoneDispName() = default; - // iks - uint16_t ik_num; - stream->read((char*) &ik_num, sizeof(uint16_t)); - result->iks.resize(ik_num); - for (uint32_t i = 0; i < ik_num; i++) - { - result->iks[i].Read(stream); - } + void Read(std::istream *stream) { + if (stream == nullptr) { + return; + } + char buffer[50]; + stream->read(buffer, 50); + bone_disp_name = std::string(buffer); + bone_disp_name_english.clear(); + } - // faces - uint16_t face_num; - stream->read((char*) &face_num, sizeof(uint16_t)); - result->faces.resize(face_num); - for (uint32_t i = 0; i < face_num; i++) - { - result->faces[i].Read(stream); - } + void ReadExpantion(std::istream *stream) { + if (stream == nullptr) { + return; + } + char buffer[50]; + stream->read(buffer, 50); + bone_disp_name_english = std::string(buffer); + } +}; - // face frames - uint8_t face_frame_num; - stream->read((char*) &face_frame_num, sizeof(uint8_t)); - result->faces_indices.resize(face_frame_num); - for (uint32_t i = 0; i < face_frame_num; i++) - { - stream->read((char*) &result->faces_indices[i], sizeof(uint16_t)); - } +struct PmdBoneDisp { + uint16_t bone_index; + uint8_t bone_disp_index; - // bone names - uint8_t bone_disp_num; - stream->read((char*) &bone_disp_num, sizeof(uint8_t)); - result->bone_disp_name.resize(bone_disp_num); - for (uint32_t i = 0; i < bone_disp_num; i++) - { - result->bone_disp_name[i].Read(stream); - } + PmdBoneDisp() : + bone_index(0), bone_disp_index(0) {} - // bone frame - uint32_t bone_frame_num; - stream->read((char*) &bone_frame_num, sizeof(uint32_t)); - result->bone_disp.resize(bone_frame_num); - for (uint32_t i = 0; i < bone_frame_num; i++) - { - result->bone_disp[i].Read(stream); - } + ~PmdBoneDisp() = default; - // english name - bool english; - stream->read((char*) &english, sizeof(char)); - if (english) - { - result->header.ReadExtension(stream); - for (uint32_t i = 0; i < bone_num; i++) - { - result->bones[i].ReadExpantion(stream); - } - for (uint32_t i = 0; i < face_num; i++) - { - if (result->faces[i].type == pmd::FaceCategory::Base) - { - continue; - } - result->faces[i].ReadExpantion(stream); - } - for (uint32_t i = 0; i < result->bone_disp_name.size(); i++) - { - result->bone_disp_name[i].ReadExpantion(stream); - } - } + void Read(std::istream *stream) { + if (stream == nullptr) { + return; + } - // toon textures - if (stream->peek() == std::ios::traits_type::eof()) - { - result->toon_filenames.clear(); - } - else { - result->toon_filenames.resize(10); - for (uint32_t i = 0; i < 10; i++) - { - stream->read(buffer, 100); - result->toon_filenames[i] = std::string(buffer); - } - } + stream->read((char *)&bone_index, sizeof(uint16_t)); + stream->read((char *)&bone_disp_index, sizeof(uint8_t)); + } +}; - // physics - if (stream->peek() == std::ios::traits_type::eof()) - { - result->rigid_bodies.clear(); - result->constraints.clear(); - } - else { - uint32_t rigid_body_num; - stream->read((char*) &rigid_body_num, sizeof(uint32_t)); - result->rigid_bodies.resize(rigid_body_num); - for (uint32_t i = 0; i < rigid_body_num; i++) - { - result->rigid_bodies[i].Read(stream); - } - uint32_t constraint_num; - stream->read((char*) &constraint_num, sizeof(uint32_t)); - result->constraints.resize(constraint_num); - for (uint32_t i = 0; i < constraint_num; i++) - { - result->constraints[i].Read(stream); - } - } +enum class RigidBodyShape : uint8_t { + Sphere = 0, + Box = 1, + Cpusel = 2 +}; - if (stream->peek() != std::ios::traits_type::eof()) - { - std::cerr << "there is unknown data" << std::endl; - } +enum class RigidBodyType : uint8_t { + BoneConnected = 0, + Physics = 1, + ConnectedPhysics = 2 +}; + +struct PmdRigidBody { + std::string name; + uint16_t related_bone_index; + uint8_t group_index; + uint16_t mask; + RigidBodyShape shape; + float size[3]; + float position[3]; + float orientation[3]; + float weight; + float linear_damping; + float anglar_damping; + float restitution; + float friction; + RigidBodyType rigid_type; + + PmdRigidBody() : + name(), related_bone_index(0), group_index(0), mask(0), shape(RigidBodyShape::Box), size{ 0.0f }, position{ 0.0f }, weight(0.0f), linear_damping(0.0f), anglar_damping(0.0f), restitution(0.0f), friction(0.0f), rigid_type(RigidBodyType::BoneConnected) {} + + ~PmdRigidBody() = default; + + void Read(std::istream *stream) { + if (stream == nullptr) { + return; + } + + char buffer[20]; + stream->read(buffer, sizeof(char) * 20); + name = (std::string(buffer)); + stream->read((char *)&related_bone_index, sizeof(uint16_t)); + stream->read((char *)&group_index, sizeof(uint8_t)); + stream->read((char *)&mask, sizeof(uint16_t)); + stream->read((char *)&shape, sizeof(uint8_t)); + stream->read((char *)size, sizeof(float) * 3); + stream->read((char *)position, sizeof(float) * 3); + stream->read((char *)orientation, sizeof(float) * 3); + stream->read((char *)&weight, sizeof(float)); + stream->read((char *)&linear_damping, sizeof(float)); + stream->read((char *)&anglar_damping, sizeof(float)); + stream->read((char *)&restitution, sizeof(float)); + stream->read((char *)&friction, sizeof(float)); + stream->read((char *)&rigid_type, sizeof(char)); + } +}; + +struct PmdConstraint { + std::string name; + uint32_t rigid_body_index_a; + uint32_t rigid_body_index_b; + float position[3]; + float orientation[3]; + float linear_lower_limit[3]; + float linear_upper_limit[3]; + float angular_lower_limit[3]; + float angular_upper_limit[3]; + float linear_stiffness[3]; + float angular_stiffness[3]; + + PmdConstraint() : + name(), rigid_body_index_a(0), rigid_body_index_b(0), position{ 0.0f }, orientation{ 0.0f }, linear_lower_limit{ 0.0f }, linear_upper_limit{ 0.0f }, angular_lower_limit{ 0.0f }, angular_upper_limit{ 0.0f }, linear_stiffness{ 0.0f }, angular_stiffness{ 0.0f } {} + + ~PmdConstraint() = default; + + void Read(std::istream *stream) { + if (stream == nullptr) { + return; + } + + char buffer[20]; + stream->read(buffer, 20); + name = std::string(buffer); + stream->read((char *)&rigid_body_index_a, sizeof(uint32_t)); + stream->read((char *)&rigid_body_index_b, sizeof(uint32_t)); + stream->read((char *)position, sizeof(float) * 3); + stream->read((char *)orientation, sizeof(float) * 3); + stream->read((char *)linear_lower_limit, sizeof(float) * 3); + stream->read((char *)linear_upper_limit, sizeof(float) * 3); + stream->read((char *)angular_lower_limit, sizeof(float) * 3); + stream->read((char *)angular_upper_limit, sizeof(float) * 3); + stream->read((char *)linear_stiffness, sizeof(float) * 3); + stream->read((char *)angular_stiffness, sizeof(float) * 3); + } +}; + +struct PmdModel { + float version; + PmdHeader header; + std::vector vertices; + std::vector indices; + std::vector materials; + std::vector bones; + std::vector iks; + std::vector faces; + std::vector faces_indices; + std::vector bone_disp_name; + std::vector bone_disp; + std::vector toon_filenames; + std::vector rigid_bodies; + std::vector constraints; + + PmdModel() : + version(0.0f) {} + + ~PmdModel() = default; + + static std::unique_ptr LoadFromFile(const char *filename) { + if (filename == nullptr) { + return nullptr; + } + + std::ifstream stream(filename, std::ios::binary); + if (stream.fail()) { + std::cerr << "could not open \"" << filename << "\"" << std::endl; + return nullptr; + } + auto result = LoadFromStream(&stream); + stream.close(); + return result; + } + + static std::unique_ptr LoadFromStream(std::ifstream *stream) { + auto result = mmd::make_unique(); + char buffer[100]; + + // magic + char magic[3]; + stream->read(magic, 3); + if (magic[0] != 'P' || magic[1] != 'm' || magic[2] != 'd') { + std::cerr << "invalid file" << std::endl; + return nullptr; + } + + // version + stream->read((char *)&(result->version), sizeof(float)); + if (result->version != 1.0f) { + std::cerr << "invalid version" << std::endl; + return nullptr; + } + + // header + result->header.Read(stream); + + // vertices + uint32_t vertex_num; + stream->read((char *)&vertex_num, sizeof(uint32_t)); + result->vertices.resize(vertex_num); + for (uint32_t i = 0; i < vertex_num; i++) { + result->vertices[i].Read(stream); + } + + // indices + uint32_t index_num; + stream->read((char *)&index_num, sizeof(uint32_t)); + result->indices.resize(index_num); + for (uint32_t i = 0; i < index_num; i++) { + stream->read((char *)&result->indices[i], sizeof(uint16_t)); + } + + // materials + uint32_t material_num; + stream->read((char *)&material_num, sizeof(uint32_t)); + result->materials.resize(material_num); + for (uint32_t i = 0; i < material_num; i++) { + result->materials[i].Read(stream); + } + + // bones + uint16_t bone_num; + stream->read((char *)&bone_num, sizeof(uint16_t)); + result->bones.resize(bone_num); + for (uint32_t i = 0; i < bone_num; i++) { + result->bones[i].Read(stream); + } + + // iks + uint16_t ik_num; + stream->read((char *)&ik_num, sizeof(uint16_t)); + result->iks.resize(ik_num); + for (uint32_t i = 0; i < ik_num; i++) { + result->iks[i].Read(stream); + } + + // faces + uint16_t face_num; + stream->read((char *)&face_num, sizeof(uint16_t)); + result->faces.resize(face_num); + for (uint32_t i = 0; i < face_num; i++) { + result->faces[i].Read(stream); + } + + // face frames + uint8_t face_frame_num; + stream->read((char *)&face_frame_num, sizeof(uint8_t)); + result->faces_indices.resize(face_frame_num); + for (uint32_t i = 0; i < face_frame_num; i++) { + stream->read((char *)&result->faces_indices[i], sizeof(uint16_t)); + } + + // bone names + uint8_t bone_disp_num; + stream->read((char *)&bone_disp_num, sizeof(uint8_t)); + result->bone_disp_name.resize(bone_disp_num); + for (uint32_t i = 0; i < bone_disp_num; i++) { + result->bone_disp_name[i].Read(stream); + } + + // bone frame + uint32_t bone_frame_num; + stream->read((char *)&bone_frame_num, sizeof(uint32_t)); + result->bone_disp.resize(bone_frame_num); + for (uint32_t i = 0; i < bone_frame_num; i++) { + result->bone_disp[i].Read(stream); + } + + // english name + bool english; + stream->read((char *)&english, sizeof(char)); + if (english) { + result->header.ReadExtension(stream); + for (uint32_t i = 0; i < bone_num; i++) { + result->bones[i].ReadExpantion(stream); + } + for (uint32_t i = 0; i < face_num; i++) { + if (result->faces[i].type == pmd::FaceCategory::Base) { + continue; + } + result->faces[i].ReadExpantion(stream); + } + for (uint32_t i = 0; i < result->bone_disp_name.size(); i++) { + result->bone_disp_name[i].ReadExpantion(stream); + } + } + + // toon textures + if (stream->peek() == std::ios::traits_type::eof()) { + result->toon_filenames.clear(); + } else { + result->toon_filenames.resize(10); + for (uint32_t i = 0; i < 10; i++) { + stream->read(buffer, 100); + result->toon_filenames[i] = std::string(buffer); + } + } + + // physics + if (stream->peek() == std::ios::traits_type::eof()) { + result->rigid_bodies.clear(); + result->constraints.clear(); + } else { + uint32_t rigid_body_num; + stream->read((char *)&rigid_body_num, sizeof(uint32_t)); + result->rigid_bodies.resize(rigid_body_num); + for (uint32_t i = 0; i < rigid_body_num; i++) { + result->rigid_bodies[i].Read(stream); + } + uint32_t constraint_num; + stream->read((char *)&constraint_num, sizeof(uint32_t)); + result->constraints.resize(constraint_num); + for (uint32_t i = 0; i < constraint_num; i++) { + result->constraints[i].Read(stream); + } + } + + if (stream->peek() != std::ios::traits_type::eof()) { + std::cerr << "there is unknown data" << std::endl; + } + + return result; + } +}; + +} // namespace pmd - return result; - } - }; -} diff --git a/code/Common/Base64.cpp b/code/Common/Base64.cpp index 3e9c47405..e55e0ba75 100644 --- a/code/Common/Base64.cpp +++ b/code/Common/Base64.cpp @@ -46,7 +46,7 @@ namespace Assimp { namespace Base64 { -static const uint8_t tableDecodeBase64[128] = { +static constexpr uint8_t tableDecodeBase64[128] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63, @@ -57,7 +57,7 @@ static const uint8_t tableDecodeBase64[128] = { 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0 }; -static const char *tableEncodeBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; +static constexpr char *tableEncodeBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; static inline char EncodeChar(uint8_t b) { return tableEncodeBase64[size_t(b)]; @@ -71,6 +71,11 @@ inline uint8_t DecodeChar(char c) { } void Encode(const uint8_t *in, size_t inLength, std::string &out) { + if (in == nullptr || inLength==0) { + out.clear(); + return; + } + size_t outLength = ((inLength + 2) / 3) * 4; size_t j = out.size(); @@ -115,8 +120,14 @@ std::string Encode(const std::vector &in) { } size_t Decode(const char *in, size_t inLength, uint8_t *&out) { + if (in == nullptr) { + out = nullptr; + return 0; + } + if (inLength % 4 != 0) { - throw DeadlyImportError("Invalid base64 encoded data: \"", std::string(in, std::min(size_t(32), inLength)), "\", length:", inLength); + throw DeadlyImportError("Invalid base64 encoded data: \"", std::string(in, std::min(size_t(32), inLength)), + "\", length:", inLength); } if (inLength < 4) { diff --git a/include/assimp/Base64.hpp b/include/assimp/Base64.hpp index ee319aceb..403723857 100644 --- a/include/assimp/Base64.hpp +++ b/include/assimp/Base64.hpp @@ -50,16 +50,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { namespace Base64 { -/// @brief Will encode the given -/// @param in -/// @param inLength -/// @param out +/// @brief Will encode the given character buffer from UTF64 to ASCII +/// @param in The UTF-64 buffer. +/// @param inLength The size of the buffer +/// @param out The encoded ASCII string. void Encode(const uint8_t *in, size_t inLength, std::string &out); + +/// @brief Will encode the given character buffer from UTF64 to ASCII. +/// @param in A vector, which contains the buffer for encoding. +/// @param out The encoded ASCII string. void Encode(const std::vector& in, std::string &out); + +/// @brief Will encode the given character buffer from UTF64 to ASCII. +/// @param in A vector, which contains the buffer for encoding. +/// @return The encoded ASCII string. std::string Encode(const std::vector& in); +/// @brief Will decode the given character buffer from ASCII to UTF64. +/// @param in The ASCII buffer to decode. +/// @param inLength The size of the buffer. +/// @param out The decoded buffer. +/// @return The new buffer size. size_t Decode(const char *in, size_t inLength, uint8_t *&out); + +/// @brief Will decode the given character buffer from ASCII to UTF64. +/// @param in The ASCII buffer to decode as a std::string. +/// @param out The decoded buffer. +/// @return The new buffer size. size_t Decode(const std::string& in, std::vector& out); + +/// @brief Will decode the given character buffer from ASCII to UTF64. +/// @param in The ASCII string. +/// @return The decoded buffer in a vector. std::vector Decode(const std::string& in); } // namespace Base64 diff --git a/test/unit/Common/utBase64.cpp b/test/unit/Common/utBase64.cpp index 8b0a60e47..ec927b980 100644 --- a/test/unit/Common/utBase64.cpp +++ b/test/unit/Common/utBase64.cpp @@ -47,26 +47,35 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace std; using namespace Assimp; -class Base64Test : public ::testing::Test { -public: - virtual void SetUp() { - } - - virtual void TearDown() { - } -}; +class Base64Test : public ::testing::Test {}; static const std::vector assimpStringBinary = { 97, 115, 115, 105, 109, 112 }; static const std::string assimpStringEncoded = "YXNzaW1w"; -TEST_F( Base64Test, encodeTest ) { - EXPECT_EQ( "", Base64::Encode (std::vector{}) ); - EXPECT_EQ( "Vg==", Base64::Encode (std::vector{ 86 }) ); - EXPECT_EQ( assimpStringEncoded, Base64::Encode (assimpStringBinary) ); +TEST_F( Base64Test, encodeTest) { + EXPECT_EQ( "", Base64::Encode(std::vector{}) ); + EXPECT_EQ( "Vg==", Base64::Encode(std::vector{ 86 }) ); + EXPECT_EQ( assimpStringEncoded, Base64::Encode(assimpStringBinary) ); } -TEST_F( Base64Test, decodeTest ) { - EXPECT_EQ( std::vector {}, Base64::Decode ("") ); - EXPECT_EQ( std::vector { 86 }, Base64::Decode ("Vg==") ); - EXPECT_EQ( assimpStringBinary, Base64::Decode (assimpStringEncoded) ); +TEST_F( Base64Test, encodeTestWithNullptr ) { + std::string out; + Base64::Encode(nullptr, 100u, out); + EXPECT_TRUE(out.empty()); + + Base64::Encode(&assimpStringBinary[0], 0u, out); + EXPECT_TRUE(out.empty()); +} + +TEST_F( Base64Test, decodeTest) { + EXPECT_EQ( std::vector {}, Base64::Decode("") ); + EXPECT_EQ( std::vector { 86 }, Base64::Decode("Vg==") ); + EXPECT_EQ( assimpStringBinary, Base64::Decode(assimpStringEncoded) ); +} + +TEST_F(Base64Test, decodeTestWithNullptr) { + uint8_t *out = nullptr; + size_t size = Base64::Decode(nullptr, 100u, out); + EXPECT_EQ(nullptr, out); + EXPECT_EQ(0u, size); } From e4c383324a61794251b729b4dff75433ff9b6b1b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 27 Aug 2022 15:11:54 +0200 Subject: [PATCH 28/39] Use string for constexpr --- code/Common/Base64.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/Base64.cpp b/code/Common/Base64.cpp index e55e0ba75..65308f4fd 100644 --- a/code/Common/Base64.cpp +++ b/code/Common/Base64.cpp @@ -57,7 +57,7 @@ static constexpr uint8_t tableDecodeBase64[128] = { 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0 }; -static constexpr char *tableEncodeBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; +static constexpr char tableEncodeBase64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; static inline char EncodeChar(uint8_t b) { return tableEncodeBase64[size_t(b)]; From 02e6c425f9b06dbd5e6fb019555beee2caa980de Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 27 Aug 2022 15:20:53 +0200 Subject: [PATCH 29/39] Fix ordering of initalizer list --- code/AssetLib/MMD/MMDPmdParser.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/AssetLib/MMD/MMDPmdParser.h b/code/AssetLib/MMD/MMDPmdParser.h index 95d4d4552..23aaac555 100644 --- a/code/AssetLib/MMD/MMDPmdParser.h +++ b/code/AssetLib/MMD/MMDPmdParser.h @@ -219,8 +219,7 @@ struct PmdIk { float angle_limit; std::vector ik_child_bone_index; - PmdIk() : - ik_child_bone_index(0), target_bone_index(0), iterations(0), angle_limit(0.0f) {} + PmdIk() : ik_bone_index(0), target_bone_index(0), iterations(0), angle_limit(0.0f) {} ~PmdIk() = default; From 0571ee21fb97b3b509d999b0d35d10347fbae40b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 28 Aug 2022 20:58:52 +0200 Subject: [PATCH 30/39] Introduce unittest for BaseProcess. --- code/Common/AssertHandler.cpp | 20 +++--- code/Common/AssertHandler.h | 46 +++++++------ code/Common/BaseImporter.cpp | 14 ++-- code/Common/BaseProcess.cpp | 13 +++- code/Common/BaseProcess.h | 44 ++++++------ test/CMakeLists.txt | 3 +- test/unit/Common/utBaseProcess.cpp | 105 +++++++++++++++++++++++++++++ 7 files changed, 185 insertions(+), 60 deletions(-) create mode 100644 test/unit/Common/utBaseProcess.cpp diff --git a/code/Common/AssertHandler.cpp b/code/Common/AssertHandler.cpp index d0bd6ccad..469e7bec5 100644 --- a/code/Common/AssertHandler.cpp +++ b/code/Common/AssertHandler.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2022, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -50,23 +48,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -void Assimp::defaultAiAssertHandler(const char* failedExpression, const char* file, int line) -{ +void Assimp::defaultAiAssertHandler(const char* failedExpression, const char* file, int line) { std::cerr << "ai_assert failure in " << file << "(" << line << "): " << failedExpression << std::endl; std::abort(); } -namespace -{ +namespace { Assimp::AiAssertHandler s_handler = Assimp::defaultAiAssertHandler; } -void Assimp::setAiAssertHandler(AiAssertHandler handler) -{ - s_handler = handler; +void Assimp::setAiAssertHandler(AiAssertHandler handler) { + if (handler != nullptr) { + s_handler = handler; + } else { + s_handler = Assimp::defaultAiAssertHandler; + } } -void Assimp::aiAssertViolation(const char* failedExpression, const char* file, int line) -{ +void Assimp::aiAssertViolation(const char* failedExpression, const char* file, int line) { s_handler(failedExpression, file, line); } diff --git a/code/Common/AssertHandler.h b/code/Common/AssertHandler.h index 2515f0bf2..365a924b0 100644 --- a/code/Common/AssertHandler.h +++ b/code/Common/AssertHandler.h @@ -47,29 +47,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -namespace Assimp -{ - // --------------------------------------------------------------------------- - /** Signature of functions which handle assert violations. - */ - using AiAssertHandler = void (*)(const char* failedExpression, const char* file, int line); +namespace Assimp { - // --------------------------------------------------------------------------- - /** Set the assert handler. - */ - ASSIMP_API void setAiAssertHandler(AiAssertHandler handler); +// --------------------------------------------------------------------------- +/** + * @brief Signature of functions which handle assert violations. + */ +using AiAssertHandler = void (*)(const char* failedExpression, const char* file, int line); - // --------------------------------------------------------------------------- - /** The assert handler which is set by default. - * - * This issues a message to stderr and calls abort. - */ - ASSIMP_API void defaultAiAssertHandler(const char* failedExpression, const char* file, int line); +// --------------------------------------------------------------------------- +/** + * @brief Set the assert handler. + */ +ASSIMP_API void setAiAssertHandler(AiAssertHandler handler); + +// --------------------------------------------------------------------------- +/** The assert handler which is set by default. + * + * @brief This issues a message to stderr and calls abort. + */ +ASSIMP_API void defaultAiAssertHandler(const char* failedExpression, const char* file, int line); + +// --------------------------------------------------------------------------- +/** + * @brief Dispatches an assert violation to the assert handler. + */ +ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line); - // --------------------------------------------------------------------------- - /** Dispatches an assert violation to the assert handler. - */ - ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line); } // end of namespace Assimp -#endif // INCLUDED_AI_ASSERTHANDLER_H \ No newline at end of file +#endif // INCLUDED_AI_ASSERTHANDLER_H diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index 383300ef1..1d0aea6a3 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -234,19 +234,23 @@ void BaseImporter::GetExtensionList(std::set &extensions) { std::string::size_type pos = pFile.find_last_of('.'); // no file extension - can't read - if (pos == std::string::npos) + if (pos == std::string::npos) { return false; + } const char *ext_real = &pFile[pos + 1]; - if (!ASSIMP_stricmp(ext_real, ext0)) + if (!ASSIMP_stricmp(ext_real, ext0)) { return true; + } // check for other, optional, file extensions - if (ext1 && !ASSIMP_stricmp(ext_real, ext1)) + if (ext1 && !ASSIMP_stricmp(ext_real, ext1)) { return true; + } - if (ext2 && !ASSIMP_stricmp(ext_real, ext2)) - return true; + if (ext2 && !ASSIMP_stricmp(ext_real, ext2)) { + return true; + } return false; } diff --git a/code/Common/BaseProcess.cpp b/code/Common/BaseProcess.cpp index 48895b9f3..32e9ad608 100644 --- a/code/Common/BaseProcess.cpp +++ b/code/Common/BaseProcess.cpp @@ -66,17 +66,26 @@ BaseProcess::~BaseProcess() { // ------------------------------------------------------------------------------------------------ void BaseProcess::ExecuteOnScene(Importer *pImp) { ai_assert( nullptr != pImp ); - ai_assert( nullptr != pImp->Pimpl()->mScene); + if (pImp == nullptr) { + return; + } + + ai_assert(nullptr != pImp->Pimpl()->mScene); + if (pImp->Pimpl()->mScene == nullptr) { + return; + } progress = pImp->GetProgressHandler(); ai_assert(nullptr != progress); + if (progress == nullptr) { + return; + } SetupProperties(pImp); // catch exceptions thrown inside the PostProcess-Step try { Execute(pImp->Pimpl()->mScene); - } catch (const std::exception &err) { // extract error description diff --git a/code/Common/BaseProcess.h b/code/Common/BaseProcess.h index 64403567a..cd9a43b6b 100644 --- a/code/Common/BaseProcess.h +++ b/code/Common/BaseProcess.h @@ -179,19 +179,20 @@ class ASSIMP_API_WINONLY BaseProcess { friend class Importer; public: - /** Constructor to be privately used by Importer */ + /** @brief onstructor to be privately used by Importer */ BaseProcess() AI_NO_EXCEPT; - /** Destructor, private as well */ + /** @brief Destructor, private as well */ virtual ~BaseProcess(); // ------------------------------------------------------------------- - /** Returns whether the processing step is present in the given flag. + /** + * @brief Returns whether the processing step is present in the given flag. * @param pFlags The processing flags the importer was called with. A * bitwise combination of #aiPostProcessSteps. * @return true if the process is present in this flag fields, * false if not. - */ + */ virtual bool IsActive(unsigned int pFlags) const = 0; // ------------------------------------------------------------------- @@ -200,33 +201,36 @@ public: virtual bool RequireVerboseFormat() const; // ------------------------------------------------------------------- - /** Executes the post processing step on the given imported data. - * The function deletes the scene if the postprocess step fails ( - * the object pointer will be set to nullptr). - * @param pImp Importer instance (pImp->mScene must be valid) - */ + /** + * @brief Executes the post processing step on the given imported data. + * The function deletes the scene if the post-process step fails ( + * the object pointer will be set to nullptr). + * @param pImp Importer instance (pImp->mScene must be valid) + */ void ExecuteOnScene(Importer *pImp); // ------------------------------------------------------------------- - /** Called prior to ExecuteOnScene(). - * The function is a request to the process to update its configuration - * basing on the Importer's configuration property list. - */ + /** + * @brief Called prior to ExecuteOnScene(). + * The function is a request to the process to update its configuration + * basing on the Importer's configuration property list. + */ virtual void SetupProperties(const Importer *pImp); // ------------------------------------------------------------------- - /** Executes the post processing step on the given imported data. - * A process should throw an ImportErrorException* if it fails. - * This method must be implemented by deriving classes. - * @param pScene The imported data to work at. - */ + /** + * @brief Executes the post processing step on the given imported data. + * A process should throw an ImportErrorException* if it fails. + * This method must be implemented by deriving classes. + * @param pScene The imported data to work at. + */ virtual void Execute(aiScene *pScene) = 0; // ------------------------------------------------------------------- /** Assign a new SharedPostProcessInfo to the step. This object - * allows multiple postprocess steps to share data. + * allows multiple post-process steps to share data. * @param sh May be nullptr - */ + */ inline void SetSharedData(SharedPostProcessInfo *sh) { shared = sh; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cdf13d778..5c87dabbe 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -71,7 +71,6 @@ SET( COMMON unit/AssimpAPITest_aiQuaternion.cpp unit/AssimpAPITest_aiVector2D.cpp unit/AssimpAPITest_aiVector3D.cpp - unit/Common/utHash.cpp unit/MathTest.cpp unit/MathTest.h unit/RandomNumberGeneration.h @@ -98,6 +97,8 @@ SET( COMMON unit/Common/utAssertHandler.cpp unit/Common/utXmlParser.cpp unit/Common/utBase64.cpp + unit/Common/utHash.cpp + unit/Common/utBaseProcess.cpp ) SET( IMPORTERS diff --git a/test/unit/Common/utBaseProcess.cpp b/test/unit/Common/utBaseProcess.cpp new file mode 100644 index 000000000..2da5c18b0 --- /dev/null +++ b/test/unit/Common/utBaseProcess.cpp @@ -0,0 +1,105 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2022, assimp team + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ + +#include "TestIOSystem.h" +#include "UnitTestPCH.h" + +#include "Common/BaseProcess.h" +#include "Common/AssertHandler.h" + +using namespace Assimp; + +class BaseProcessTest : public ::testing::Test { +public: + static void test_handler( const char*, const char*, int ) { + HandlerWasCalled = true; + } + + void SetUp() override { + HandlerWasCalled = false; + setAiAssertHandler(test_handler); + } + + void TearDown() override { + setAiAssertHandler(nullptr); + } + + static bool handlerWasCalled() { + return HandlerWasCalled; + } + +private: + static bool HandlerWasCalled; +}; + +bool BaseProcessTest::HandlerWasCalled = false; + +class TestingBaseProcess : public BaseProcess { +public: + TestingBaseProcess() : BaseProcess() { + // empty + } + + ~TestingBaseProcess() override = default; + + bool IsActive( unsigned int ) const override { + return true; + } + + void Execute(aiScene*) override { + + } +}; +TEST_F( BaseProcessTest, constructTest ) { + bool ok = true; + try { + TestingBaseProcess process; + } catch (...) { + ok = false; + } + EXPECT_TRUE(ok); +} + +TEST_F( BaseProcessTest, executeOnSceneTest ) { + TestingBaseProcess process; + process.ExecuteOnScene(nullptr); + EXPECT_TRUE(BaseProcessTest::handlerWasCalled()); +} From e34becff62301a57341d9c6d2c83fa6f6f8e24c8 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 29 Aug 2022 11:43:32 +0200 Subject: [PATCH 31/39] Enable portable linkage to fix build --- code/Common/BaseProcess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/BaseProcess.h b/code/Common/BaseProcess.h index cd9a43b6b..b6b1e1144 100644 --- a/code/Common/BaseProcess.h +++ b/code/Common/BaseProcess.h @@ -175,7 +175,7 @@ private: * should be executed. If the function returns true, the class' Execute() * function is called subsequently. */ -class ASSIMP_API_WINONLY BaseProcess { +class ASSIMP_API BaseProcess { friend class Importer; public: From 6539b8685fa5cc79b9e140e12f84a88e984ff288 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 29 Aug 2022 17:48:57 +0200 Subject: [PATCH 32/39] Update utBaseProcess.cpp --- test/unit/Common/utBaseProcess.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/unit/Common/utBaseProcess.cpp b/test/unit/Common/utBaseProcess.cpp index 2da5c18b0..004267c2c 100644 --- a/test/unit/Common/utBaseProcess.cpp +++ b/test/unit/Common/utBaseProcess.cpp @@ -101,5 +101,10 @@ TEST_F( BaseProcessTest, constructTest ) { TEST_F( BaseProcessTest, executeOnSceneTest ) { TestingBaseProcess process; process.ExecuteOnScene(nullptr); +#ifdef DEBUG EXPECT_TRUE(BaseProcessTest::handlerWasCalled()); +#else + EXPECT_FALSE(BaseProcessTest::handlerWasCalled()); +#endif + } From fbb69df8be18c5a8c4403813d037b6eadd93ec6a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 30 Aug 2022 20:54:23 +0200 Subject: [PATCH 33/39] Update utBaseProcess.cpp --- test/unit/Common/utBaseProcess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/Common/utBaseProcess.cpp b/test/unit/Common/utBaseProcess.cpp index 004267c2c..978af7e99 100644 --- a/test/unit/Common/utBaseProcess.cpp +++ b/test/unit/Common/utBaseProcess.cpp @@ -101,7 +101,7 @@ TEST_F( BaseProcessTest, constructTest ) { TEST_F( BaseProcessTest, executeOnSceneTest ) { TestingBaseProcess process; process.ExecuteOnScene(nullptr); -#ifdef DEBUG +#ifdef ASSIMP_BUILD_DEBUG EXPECT_TRUE(BaseProcessTest::handlerWasCalled()); #else EXPECT_FALSE(BaseProcessTest::handlerWasCalled()); From a22aa75bca5da546abb320edefe2da0ae3316535 Mon Sep 17 00:00:00 2001 From: Gargaj Date: Wed, 31 Aug 2022 22:27:34 +0200 Subject: [PATCH 34/39] fix vertices being joined duplicating weights This bug causes weights to duplicate, i.e. one bone will have several (equal) weights assigned to the same vertex - which then has the potential to cause even bigger problems when combined with `LimitBoneWeightsProcess`. --- code/PostProcessing/JoinVerticesProcess.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/code/PostProcessing/JoinVerticesProcess.cpp b/code/PostProcessing/JoinVerticesProcess.cpp index 84e742115..aed865e30 100644 --- a/code/PostProcessing/JoinVerticesProcess.cpp +++ b/code/PostProcessing/JoinVerticesProcess.cpp @@ -394,6 +394,16 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) { const aiVertexWeight& ow = bone->mWeights[ b ]; // if the vertex is a unique one, translate it if ( !( replaceIndex[ ow.mVertexId ] & 0x80000000 ) ) { + bool weightAlreadyExists = false; + for (std::vector::iterator vit = newWeights.begin(); vit != newWeights.end(); ++vit) { + if (vit->mVertexId == replaceIndex[ow.mVertexId]) { + weightAlreadyExists = true; + break; + } + } + if (weightAlreadyExists) { + continue; + } aiVertexWeight nw; nw.mVertexId = replaceIndex[ ow.mVertexId ]; nw.mWeight = ow.mWeight; From 4c6652f5b06aab80514f41529cea03768df9159e Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Thu, 1 Sep 2022 11:37:53 -0400 Subject: [PATCH 35/39] Add a handful of missing fixes --- code/AssetLib/B3D/B3DImporter.cpp | 4 +--- code/AssetLib/STL/STLLoader.cpp | 4 +--- code/Common/BaseProcess.cpp | 4 +--- code/Common/SGSpatialSort.cpp | 5 +---- code/PostProcessing/PretransformVertices.cpp | 4 +--- test/unit/AbstractImportExportBase.cpp | 4 +--- test/unit/ImportExport/utExporter.cpp | 6 ++---- test/unit/SceneDiffer.cpp | 4 +--- test/unit/utBlendImportAreaLight.cpp | 2 +- test/unit/utObjTools.cpp | 4 +--- tools/assimp_cmd/Main.cpp | 4 +--- 11 files changed, 12 insertions(+), 33 deletions(-) diff --git a/code/AssetLib/B3D/B3DImporter.cpp b/code/AssetLib/B3D/B3DImporter.cpp index b572a61e4..8cfa55cc4 100644 --- a/code/AssetLib/B3D/B3DImporter.cpp +++ b/code/AssetLib/B3D/B3DImporter.cpp @@ -88,9 +88,7 @@ void DeleteAllBarePointers(std::vector &x) { } } -B3DImporter::~B3DImporter() { - // empty -} +B3DImporter::~B3DImporter() = default; // ------------------------------------------------------------------------------------------------ bool B3DImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const { diff --git a/code/AssetLib/STL/STLLoader.cpp b/code/AssetLib/STL/STLLoader.cpp index cea448de1..2379ad619 100644 --- a/code/AssetLib/STL/STLLoader.cpp +++ b/code/AssetLib/STL/STLLoader.cpp @@ -134,9 +134,7 @@ STLImporter::STLImporter() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -STLImporter::~STLImporter() { - // empty -} +STLImporter::~STLImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/Common/BaseProcess.cpp b/code/Common/BaseProcess.cpp index 32e9ad608..8ff7c98e9 100644 --- a/code/Common/BaseProcess.cpp +++ b/code/Common/BaseProcess.cpp @@ -59,9 +59,7 @@ BaseProcess::BaseProcess() AI_NO_EXCEPT // ------------------------------------------------------------------------------------------------ // Destructor, private as well -BaseProcess::~BaseProcess() { - // nothing to do here -} +BaseProcess::~BaseProcess() = default; // ------------------------------------------------------------------------------------------------ void BaseProcess::ExecuteOnScene(Importer *pImp) { diff --git a/code/Common/SGSpatialSort.cpp b/code/Common/SGSpatialSort.cpp index 5a830b4dd..0ef1853c0 100644 --- a/code/Common/SGSpatialSort.cpp +++ b/code/Common/SGSpatialSort.cpp @@ -59,10 +59,7 @@ SGSpatialSort::SGSpatialSort() } // ------------------------------------------------------------------------------------------------ // Destructor -SGSpatialSort::~SGSpatialSort() -{ - // nothing to do here, everything destructs automatically -} +SGSpatialSort::~SGSpatialSort() = default; // ------------------------------------------------------------------------------------------------ void SGSpatialSort::Add(const aiVector3D& vPosition, unsigned int index, unsigned int smoothingGroup) diff --git a/code/PostProcessing/PretransformVertices.cpp b/code/PostProcessing/PretransformVertices.cpp index ec7b8783e..9ac90d277 100644 --- a/code/PostProcessing/PretransformVertices.cpp +++ b/code/PostProcessing/PretransformVertices.cpp @@ -70,9 +70,7 @@ PretransformVertices::PretransformVertices() : // ------------------------------------------------------------------------------------------------ // Destructor, private as well -PretransformVertices::~PretransformVertices() { - // nothing to do here -} +PretransformVertices::~PretransformVertices() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/test/unit/AbstractImportExportBase.cpp b/test/unit/AbstractImportExportBase.cpp index 31402f483..077a4d1f2 100644 --- a/test/unit/AbstractImportExportBase.cpp +++ b/test/unit/AbstractImportExportBase.cpp @@ -44,6 +44,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace ::Assimp; -AbstractImportExportBase::~AbstractImportExportBase() { - // empty -} +AbstractImportExportBase::~AbstractImportExportBase() = default; diff --git a/test/unit/ImportExport/utExporter.cpp b/test/unit/ImportExport/utExporter.cpp index 9c5ca1ce6..096a5c49d 100644 --- a/test/unit/ImportExport/utExporter.cpp +++ b/test/unit/ImportExport/utExporter.cpp @@ -55,9 +55,7 @@ public: // empty } - virtual ~TestProgressHandler() { - // empty - } + virtual ~TestProgressHandler() = default; bool Update(float percentage = -1.f) override { mPercentage = percentage; @@ -104,4 +102,4 @@ TEST_F(ExporterTest, ExporterIdTest) { EXPECT_EQ(nullptr, desc) << "More exporters than claimed"; } -#endif \ No newline at end of file +#endif diff --git a/test/unit/SceneDiffer.cpp b/test/unit/SceneDiffer.cpp index 0918530b7..a7132496a 100644 --- a/test/unit/SceneDiffer.cpp +++ b/test/unit/SceneDiffer.cpp @@ -53,9 +53,7 @@ SceneDiffer::SceneDiffer() // empty } -SceneDiffer::~SceneDiffer() { - // empty -} +SceneDiffer::~SceneDiffer() = default; bool SceneDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) { if ( expected == toCompare ) { diff --git a/test/unit/utBlendImportAreaLight.cpp b/test/unit/utBlendImportAreaLight.cpp index 53788743e..4a16e662c 100644 --- a/test/unit/utBlendImportAreaLight.cpp +++ b/test/unit/utBlendImportAreaLight.cpp @@ -69,7 +69,7 @@ TEST_F(BlendImportAreaLight, testImportLight) { std::vector> lightNames; for (size_t i = 0; i < pTest->mNumLights; i++) { - lightNames.push_back(std::make_pair(pTest->mLights[i]->mName.C_Str(), i)); + lightNames.emplace_back(pTest->mLights[i]->mName.C_Str(), i); } std::sort(lightNames.begin(), lightNames.end()); diff --git a/test/unit/utObjTools.cpp b/test/unit/utObjTools.cpp index 744e22630..f2e5304ad 100644 --- a/test/unit/utObjTools.cpp +++ b/test/unit/utObjTools.cpp @@ -55,9 +55,7 @@ public: // empty } - ~TestObjFileParser() { - // empty - } + ~TestObjFileParser() = default; void testCopyNextWord(char *pBuffer, size_t length) { copyNextWord(pBuffer, length); diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index 31b92b0f0..a795a5472 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -55,9 +55,7 @@ public: // empty } - ~ConsoleProgressHandler() override { - // empty - } + ~ConsoleProgressHandler() override = default; bool Update(float percentage) override { std::cout << percentage * 100.0f << " %\n"; From e3b01e10db3ed7551f7a42a9f3ce983a22922d6c Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Thu, 1 Sep 2022 12:28:45 -0400 Subject: [PATCH 36/39] apply fixes to more headers --- code/AssetLib/ASE/ASEParser.h | 2 +- code/AssetLib/Blender/BlenderIntermediate.h | 3 +-- code/AssetLib/COB/COBScene.h | 2 +- code/AssetLib/Collada/ColladaExporter.h | 2 +- code/AssetLib/IFC/IFCUtil.h | 3 +-- code/AssetLib/IQM/IQMImporter.h | 2 +- code/AssetLib/Irr/IRRLoader.h | 3 +-- code/AssetLib/LWO/LWOFileData.h | 10 ++------- code/AssetLib/LWS/LWSLoader.h | 2 +- code/AssetLib/MMD/MMDPmxParser.h | 2 +- code/AssetLib/X3D/X3DExporter.hpp | 2 +- code/AssetLib/X3D/X3DImporter.hpp | 2 +- code/AssetLib/X3D/X3DImporter_Macro.hpp | 2 +- code/AssetLib/glTF/glTFAsset.h | 10 ++++----- code/AssetLib/glTF2/glTF2Asset.h | 24 ++++++++++----------- code/Common/BaseProcess.h | 4 ++-- include/assimp/IOStream.hpp | 4 +--- include/assimp/Logger.hpp | 4 +--- include/assimp/Subdivision.h | 5 +---- test/unit/UTLogStream.h | 2 +- 20 files changed, 37 insertions(+), 53 deletions(-) diff --git a/code/AssetLib/ASE/ASEParser.h b/code/AssetLib/ASE/ASEParser.h index 5c24fffd1..8cda32f24 100644 --- a/code/AssetLib/ASE/ASEParser.h +++ b/code/AssetLib/ASE/ASEParser.h @@ -116,7 +116,7 @@ struct Material : public D3DS::Material { return *this; } - ~Material() {} + ~Material() = default; //! Contains all sub materials of this material std::vector avSubMaterials; diff --git a/code/AssetLib/Blender/BlenderIntermediate.h b/code/AssetLib/Blender/BlenderIntermediate.h index 0651f7117..546b79f09 100644 --- a/code/AssetLib/Blender/BlenderIntermediate.h +++ b/code/AssetLib/Blender/BlenderIntermediate.h @@ -65,8 +65,7 @@ namespace Blender { struct TempArray { typedef TCLASS< T*,std::allocator > mywrap; - TempArray() { - } + TempArray() = default; ~TempArray () { for(T* elem : arr) { diff --git a/code/AssetLib/COB/COBScene.h b/code/AssetLib/COB/COBScene.h index 57620ca51..cc49de276 100644 --- a/code/AssetLib/COB/COBScene.h +++ b/code/AssetLib/COB/COBScene.h @@ -107,7 +107,7 @@ struct Node : public ChunkInfo TYPE_MESH,TYPE_GROUP,TYPE_LIGHT,TYPE_CAMERA,TYPE_BONE }; - virtual ~Node() {} + virtual ~Node() = default; Node(Type type) : type(type), unit_scale(1.f){} Type type; diff --git a/code/AssetLib/Collada/ColladaExporter.h b/code/AssetLib/Collada/ColladaExporter.h index 56415fba7..7288dce54 100644 --- a/code/AssetLib/Collada/ColladaExporter.h +++ b/code/AssetLib/Collada/ColladaExporter.h @@ -233,7 +233,7 @@ public: Surface ambient, diffuse, specular, emissive, reflective, transparent, normal; Property shininess, transparency, index_refraction; - Material() {} + Material() = default; }; std::map textures; diff --git a/code/AssetLib/IFC/IFCUtil.h b/code/AssetLib/IFC/IFCUtil.h index b5f72a56d..f9063ce22 100644 --- a/code/AssetLib/IFC/IFCUtil.h +++ b/code/AssetLib/IFC/IFCUtil.h @@ -344,8 +344,7 @@ protected: public: typedef std::pair ParamRange; - virtual ~Curve() {} - + virtual ~Curve() = default; // check if a curve is closed virtual bool IsClosed() const = 0; diff --git a/code/AssetLib/IQM/IQMImporter.h b/code/AssetLib/IQM/IQMImporter.h index fbeaff8c3..cc549186f 100644 --- a/code/AssetLib/IQM/IQMImporter.h +++ b/code/AssetLib/IQM/IQMImporter.h @@ -56,7 +56,7 @@ class IQMImporter : public BaseImporter { public: /// \brief Default constructor IQMImporter(); - ~IQMImporter() override {} + ~IQMImporter() override = default; /// \brief Returns whether the class can handle the format of the given file. /// \remark See BaseImporter::CanRead() for details. diff --git a/code/AssetLib/Irr/IRRLoader.h b/code/AssetLib/Irr/IRRLoader.h index d56c4ca2d..7fa239395 100644 --- a/code/AssetLib/Irr/IRRLoader.h +++ b/code/AssetLib/Irr/IRRLoader.h @@ -206,8 +206,7 @@ private: */ struct SkyboxVertex { - SkyboxVertex() - {} + SkyboxVertex() = default; //! Construction from single vertex components SkyboxVertex(ai_real px, ai_real py, ai_real pz, diff --git a/code/AssetLib/LWO/LWOFileData.h b/code/AssetLib/LWO/LWOFileData.h index 59d10eca1..656dd4529 100644 --- a/code/AssetLib/LWO/LWOFileData.h +++ b/code/AssetLib/LWO/LWOFileData.h @@ -338,13 +338,7 @@ struct Face : public aiFace { uint32_t type; //! Assignment operator - Face &operator=(const LWO::Face &f) { - aiFace::operator=(f); - surfaceIndex = f.surfaceIndex; - smoothGroup = f.smoothGroup; - type = f.type; - return *this; - } + Face &operator=(const LWO::Face &f) = default; }; // --------------------------------------------------------------------------- @@ -354,7 +348,7 @@ struct VMapEntry { explicit VMapEntry(unsigned int _dims) : dims(_dims) {} - virtual ~VMapEntry() {} + virtual ~VMapEntry() = default; //! allocates memory for the vertex map virtual void Allocate(unsigned int num) { diff --git a/code/AssetLib/LWS/LWSLoader.h b/code/AssetLib/LWS/LWSLoader.h index 225186f5c..3df9fe9d9 100644 --- a/code/AssetLib/LWS/LWSLoader.h +++ b/code/AssetLib/LWS/LWSLoader.h @@ -69,7 +69,7 @@ namespace LWS { */ class Element { public: - Element() {} + Element() = default; // first: name, second: rest std::string tokens[2]; diff --git a/code/AssetLib/MMD/MMDPmxParser.h b/code/AssetLib/MMD/MMDPmxParser.h index c9df37c68..f2e387975 100644 --- a/code/AssetLib/MMD/MMDPmxParser.h +++ b/code/AssetLib/MMD/MMDPmxParser.h @@ -88,7 +88,7 @@ namespace pmx { public: virtual void Read(std::istream *stream, PmxSetting *setting) = 0; - virtual ~PmxVertexSkinning() {} + virtual ~PmxVertexSkinning() = default; }; class PmxVertexSkinningBDEF1 : public PmxVertexSkinning diff --git a/code/AssetLib/X3D/X3DExporter.hpp b/code/AssetLib/X3D/X3DExporter.hpp index fefaba9f3..7a87821b4 100644 --- a/code/AssetLib/X3D/X3DExporter.hpp +++ b/code/AssetLib/X3D/X3DExporter.hpp @@ -241,7 +241,7 @@ public: /// \fn ~X3DExporter() /// Default destructor. - ~X3DExporter() {} + ~X3DExporter() = default; }; // class X3DExporter diff --git a/code/AssetLib/X3D/X3DImporter.hpp b/code/AssetLib/X3D/X3DImporter.hpp index d9aed70d8..8852b71ec 100644 --- a/code/AssetLib/X3D/X3DImporter.hpp +++ b/code/AssetLib/X3D/X3DImporter.hpp @@ -270,7 +270,7 @@ public: void Clear(); private: - X3DNodeElementBase *MACRO_USE_CHECKANDAPPLY(XmlNode &node, std::string pDEF, std::string pUSE, X3DElemType pType, X3DNodeElementBase *pNE); + X3DNodeElementBase *MACRO_USE_CHECKANDAPPLY(XmlNode &node, const std::string &pDEF, const std::string &pUSE, X3DElemType pType, X3DNodeElementBase *pNE); bool isNodeEmpty(XmlNode &node); void checkNodeMustBeEmpty(XmlNode &node); void skipUnsupportedNode(const std::string &pParentNodeName, XmlNode &node); diff --git a/code/AssetLib/X3D/X3DImporter_Macro.hpp b/code/AssetLib/X3D/X3DImporter_Macro.hpp index a84a739a3..26b949cfa 100644 --- a/code/AssetLib/X3D/X3DImporter_Macro.hpp +++ b/code/AssetLib/X3D/X3DImporter_Macro.hpp @@ -59,7 +59,7 @@ namespace Assimp { /// \param [in] pUSE - string holding "USE" value. /// \param [in] pType - type of element to find. /// \param [out] pNE - pointer to found node element. -inline X3DNodeElementBase *X3DImporter::MACRO_USE_CHECKANDAPPLY(XmlNode &node, std::string pDEF, std::string pUSE, X3DElemType pType, X3DNodeElementBase *pNE) { +inline X3DNodeElementBase *X3DImporter::MACRO_USE_CHECKANDAPPLY(XmlNode &node, const std::string &pDEF, const std::string &pUSE, X3DElemType pType, X3DNodeElementBase *pNE) { checkNodeMustBeEmpty(node); if (!pDEF.empty()) Assimp::Throw_DEF_And_USE(node.name()); diff --git a/code/AssetLib/glTF/glTFAsset.h b/code/AssetLib/glTF/glTFAsset.h index 1b4faa9f6..a599cd5fa 100644 --- a/code/AssetLib/glTF/glTFAsset.h +++ b/code/AssetLib/glTF/glTFAsset.h @@ -314,7 +314,7 @@ struct Object { virtual bool IsSpecial() const { return false; } Object() = default; - virtual ~Object() {} + virtual ~Object() = default; //! Maps special IDs to another ID, where needed. Subclasses may override it (statically) static const char *TranslateId(Asset & /*r*/, const char *id) { return id; } @@ -666,7 +666,7 @@ struct Mesh : public Object { std::vector primitives; std::list Extension; ///< List of extensions used in mesh. - Mesh() {} + Mesh() = default; /// Destructor. ~Mesh() { @@ -706,12 +706,12 @@ struct Node : public Object { Ref parent; //!< This is not part of the glTF specification. Used as a helper. - Node() {} + Node() = default; void Read(Value &obj, Asset &r); }; struct Program : public Object { - Program() {} + Program() = default; void Read(Value &obj, Asset &r); }; @@ -830,7 +830,7 @@ struct Animation : public Object { //! Base class for LazyDict that acts as an interface class LazyDictBase { public: - virtual ~LazyDictBase() {} + virtual ~LazyDictBase() = default; virtual void AttachToDocument(Document &doc) = 0; virtual void DetachFromDocument() = 0; diff --git a/code/AssetLib/glTF2/glTF2Asset.h b/code/AssetLib/glTF2/glTF2Asset.h index 44ab6c9c8..3becc4d9b 100644 --- a/code/AssetLib/glTF2/glTF2Asset.h +++ b/code/AssetLib/glTF2/glTF2Asset.h @@ -391,7 +391,7 @@ struct Object { //! Objects marked as special are not exported (used to emulate the binary body buffer) virtual bool IsSpecial() const { return false; } - virtual ~Object() {} + virtual ~Object() = default; //! Maps special IDs to another ID, where needed. Subclasses may override it (statically) static const char *TranslateId(Asset & /*r*/, const char *id) { return id; } @@ -613,7 +613,7 @@ struct Accessor : public Object { return Indexer(*this); } - Accessor() {} + Accessor() = default; void Read(Value &obj, Asset &r); //sparse @@ -681,7 +681,7 @@ struct Light : public Object { float innerConeAngle; float outerConeAngle; - Light() {} + Light() = default; void Read(Value &obj, Asset &r); }; @@ -877,7 +877,7 @@ struct Mesh : public Object { std::vector weights; std::vector targetNames; - Mesh() {} + Mesh() = default; /// Get mesh data from JSON-object and place them to root asset. /// \param [in] pJSON_Object - reference to pJSON-object from which data are read. @@ -903,12 +903,12 @@ struct Node : public Object { Ref parent; //!< This is not part of the glTF specification. Used as a helper. - Node() {} + Node() = default; void Read(Value &obj, Asset &r); }; struct Program : public Object { - Program() {} + Program() = default; void Read(Value &obj, Asset &r); }; @@ -927,12 +927,12 @@ struct Scene : public Object { std::string name; std::vector> nodes; - Scene() {} + Scene() = default; void Read(Value &obj, Asset &r); }; struct Shader : public Object { - Shader() {} + Shader() = default; void Read(Value &obj, Asset &r); }; @@ -942,7 +942,7 @@ struct Skin : public Object { std::vector> jointNames; //!< Joint names of the joints (nodes with a jointName property) in this skin. std::string name; //!< The user-defined name of this object. - Skin() {} + Skin() = default; void Read(Value &obj, Asset &r); }; @@ -957,7 +957,7 @@ struct Texture : public Object { //TextureTarget target; //!< The target that the WebGL texture should be bound to. (default: TextureTarget_TEXTURE_2D) //TextureType type; //!< Texel datatype. (default: TextureType_UNSIGNED_BYTE) - Texture() {} + Texture() = default; void Read(Value &obj, Asset &r); }; @@ -990,14 +990,14 @@ struct Animation : public Object { std::vector samplers; //!< All the key-frame data for this animation. std::vector channels; //!< Data to connect nodes to key-frames. - Animation() {} + Animation() = default; void Read(Value &obj, Asset &r); }; //! Base class for LazyDict that acts as an interface class LazyDictBase { public: - virtual ~LazyDictBase() {} + virtual ~LazyDictBase() = default; virtual void AttachToDocument(Document &doc) = 0; virtual void DetachFromDocument() = 0; diff --git a/code/Common/BaseProcess.h b/code/Common/BaseProcess.h index b6b1e1144..d2af4faa6 100644 --- a/code/Common/BaseProcess.h +++ b/code/Common/BaseProcess.h @@ -63,7 +63,7 @@ class Importer; class SharedPostProcessInfo { public: struct Base { - virtual ~Base() {} + virtual ~Base() = default; }; //! Represents data that is allocated on the heap, thus needs to be deleted @@ -84,7 +84,7 @@ public: explicit TStaticData(T in) : data(in) {} - ~TStaticData() {} + ~TStaticData() = default; T data; }; diff --git a/include/assimp/IOStream.hpp b/include/assimp/IOStream.hpp index 5e19f5176..3b9b3c3f8 100644 --- a/include/assimp/IOStream.hpp +++ b/include/assimp/IOStream.hpp @@ -134,9 +134,7 @@ IOStream::IOStream() AI_NO_EXCEPT { // ---------------------------------------------------------------------------------- AI_FORCE_INLINE -IOStream::~IOStream() { - // empty -} +IOStream::~IOStream() = default; // ---------------------------------------------------------------------------------- } //!namespace Assimp diff --git a/include/assimp/Logger.hpp b/include/assimp/Logger.hpp index 54fd5d03d..e8df64dd8 100644 --- a/include/assimp/Logger.hpp +++ b/include/assimp/Logger.hpp @@ -263,9 +263,7 @@ inline Logger::Logger() AI_NO_EXCEPT : } // ---------------------------------------------------------------------------------- -inline Logger::~Logger() { - // empty -} +inline Logger::~Logger() = default; // ---------------------------------------------------------------------------------- inline Logger::Logger(LogSeverity severity) : diff --git a/include/assimp/Subdivision.h b/include/assimp/Subdivision.h index 9dfb38901..114120368 100644 --- a/include/assimp/Subdivision.h +++ b/include/assimp/Subdivision.h @@ -122,10 +122,7 @@ public: }; -inline -Subdivider::~Subdivider() { - // empty -} +inline Subdivider::~Subdivider() = default; } // end namespace Assimp diff --git a/test/unit/UTLogStream.h b/test/unit/UTLogStream.h index 70cb3f801..6e5d75762 100644 --- a/test/unit/UTLogStream.h +++ b/test/unit/UTLogStream.h @@ -56,7 +56,7 @@ public: virtual void write(const char* message) { if ( nullptr != message ) { - m_messages.push_back( std::string( message ) ); + m_messages.emplace_back(message); } } From 411171fa459e521ff47974ac9ea7a32d222cecbd Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 2 Sep 2022 11:20:02 -0400 Subject: [PATCH 37/39] Apply some more modernize-use-emplace --- code/AssetLib/B3D/B3DImporter.cpp | 2 +- code/AssetLib/COB/COBLoader.cpp | 4 +- code/AssetLib/FBX/FBXConverter.cpp | 4 +- code/AssetLib/IFC/IFCOpenings.cpp | 26 ++++++------- code/AssetLib/IQM/IQMImporter.h | 2 +- code/AssetLib/LWO/LWOBLoader.cpp | 2 +- code/AssetLib/LWO/LWOLoader.cpp | 8 ++-- code/AssetLib/MD5/MD5Parser.cpp | 16 ++++---- code/AssetLib/MMD/MMDImporter.cpp | 39 +++++++------------ code/AssetLib/Q3D/Q3DLoader.cpp | 2 +- code/PostProcessing/DeboneProcess.cpp | 2 +- code/PostProcessing/ProcessHelper.cpp | 2 +- code/PostProcessing/SortByPTypeProcess.cpp | 2 +- .../SplitByBoneCountProcess.cpp | 2 +- code/PostProcessing/TextureTransform.cpp | 2 +- test/unit/utLimitBoneWeights.cpp | 2 +- tools/assimp_cmd/CompareDump.cpp | 8 ++-- 17 files changed, 56 insertions(+), 69 deletions(-) diff --git a/code/AssetLib/B3D/B3DImporter.cpp b/code/AssetLib/B3D/B3DImporter.cpp index 8cfa55cc4..68aa7d4d4 100644 --- a/code/AssetLib/B3D/B3DImporter.cpp +++ b/code/AssetLib/B3D/B3DImporter.cpp @@ -671,7 +671,7 @@ void B3DImporter::ReadBB3D(aiScene *scene) { int bone = v.bones[k]; float weight = v.weights[k]; - vweights[bone].push_back(aiVertexWeight(vertIdx + faceIndex, weight)); + vweights[bone].emplace_back(vertIdx + faceIndex, weight); } } ++face; diff --git a/code/AssetLib/COB/COBLoader.cpp b/code/AssetLib/COB/COBLoader.cpp index 3e4c63b63..a540ffaf1 100644 --- a/code/AssetLib/COB/COBLoader.cpp +++ b/code/AssetLib/COB/COBLoader.cpp @@ -518,7 +518,7 @@ void COBImporter::ReadMat1_Ascii(Scene &out, LineSplitter &splitter, const Chunk return; } - out.materials.push_back(Material()); + out.materials.emplace_back(); Material &mat = out.materials.back(); mat = nfo; @@ -1004,7 +1004,7 @@ void COBImporter::ReadMat1_Binary(COB::Scene &out, StreamReaderLE &reader, const const chunk_guard cn(nfo, reader); - out.materials.push_back(Material()); + out.materials.emplace_back(); Material &mat = out.materials.back(); mat = nfo; diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index d8dbb6244..ffe961a4e 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -3319,7 +3319,7 @@ FBXConverter::KeyFrameListList FBXConverter::GetKeyframeList(const std::vector& a, ClipperLib::Polygon clip; for(const IfcVector2& pip : a) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(clip)) { @@ -410,7 +410,7 @@ void MergeWindowContours (const std::vector& a, clip.clear(); for(const IfcVector2& pip : b) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(clip)) { @@ -433,7 +433,7 @@ void MakeDisjunctWindowContours (const std::vector& a, ClipperLib::Polygon clip; for(const IfcVector2& pip : a) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(clip)) { @@ -444,7 +444,7 @@ void MakeDisjunctWindowContours (const std::vector& a, clip.clear(); for(const IfcVector2& pip : b) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(clip)) { @@ -466,7 +466,7 @@ void CleanupWindowContour(ProjectedWindowContour& window) ClipperLib::ExPolygons clipped; for(const IfcVector2& pip : contour) { - subject.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + subject.emplace_back(to_int64(pip.x), to_int64(pip.y)); } clipper.AddPolygon(subject,ClipperLib::ptSubject); @@ -524,7 +524,7 @@ void CleanupOuterContour(const std::vector& contour_flat, TempMesh& ClipperLib::Polygon clip; clip.reserve(contour_flat.size()); for(const IfcVector2& pip : contour_flat) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (!ClipperLib::Orientation(clip)) { @@ -544,7 +544,7 @@ void CleanupOuterContour(const std::vector& contour_flat, TempMesh& continue; } } - subject.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + subject.emplace_back(to_int64(pip.x), to_int64(pip.y)); if (--countdown == 0) { if (!ClipperLib::Orientation(subject)) { std::reverse(subject.begin(), subject.end()); @@ -1378,12 +1378,12 @@ bool GenerateOpenings(std::vector& openings, if(!temp_contour.empty()) { if (generate_connection_geometry) { - contours_to_openings.push_back(std::vector( - joined_openings.begin(), - joined_openings.end())); + contours_to_openings.emplace_back( + joined_openings.begin(), + joined_openings.end()); } - contours.push_back(ProjectedWindowContour(temp_contour, bb, is_rectangle)); + contours.emplace_back(temp_contour, bb, is_rectangle); } } @@ -1791,7 +1791,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings, pip.x = (pip.x - vmin.x) / vmax.x; pip.y = (pip.y - vmin.y) / vmax.y; - hole.push_back(ClipperLib::IntPoint(to_int64(pip.x),to_int64(pip.y))); + hole.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if(!ClipperLib::Orientation(hole)) { @@ -1833,7 +1833,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings, pip.x = (pip.x - vmin.x) / vmax.x; pip.y = (pip.y - vmin.y) / vmax.y; - poly.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + poly.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(poly)) { diff --git a/code/AssetLib/IQM/IQMImporter.h b/code/AssetLib/IQM/IQMImporter.h index cc549186f..ea4729988 100644 --- a/code/AssetLib/IQM/IQMImporter.h +++ b/code/AssetLib/IQM/IQMImporter.h @@ -58,7 +58,7 @@ public: IQMImporter(); ~IQMImporter() override = default; - /// \brief Returns whether the class can handle the format of the given file. + /// \brief Returns whether the class can handle the format of the given file. /// \remark See BaseImporter::CanRead() for details. bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const override; diff --git a/code/AssetLib/LWO/LWOBLoader.cpp b/code/AssetLib/LWO/LWOBLoader.cpp index 1fbd9b9df..a61e49a7f 100644 --- a/code/AssetLib/LWO/LWOBLoader.cpp +++ b/code/AssetLib/LWO/LWOBLoader.cpp @@ -218,7 +218,7 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it, // ------------------------------------------------------------------------------------------------ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned int size) { - list.push_back(LWO::Texture()); + list.emplace_back(); LWO::Texture* tex = &list.back(); std::string type; diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp index be7d54700..df0ba2238 100644 --- a/code/AssetLib/LWO/LWOLoader.cpp +++ b/code/AssetLib/LWO/LWOLoader.cpp @@ -1095,7 +1095,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) { void LWOImporter::LoadLWO2Clip(unsigned int length) { AI_LWO_VALIDATE_CHUNK_LENGTH(length, CLIP, 10); - mClips.push_back(LWO::Clip()); + mClips.emplace_back(); LWO::Clip &clip = mClips.back(); // first - get the index of the clip @@ -1165,7 +1165,7 @@ void LWOImporter::LoadLWO2Clip(unsigned int length) { void LWOImporter::LoadLWO3Clip(unsigned int length) { AI_LWO_VALIDATE_CHUNK_LENGTH(length, CLIP, 12); - mClips.push_back(LWO::Clip()); + mClips.emplace_back(); LWO::Clip &clip = mClips.back(); // first - get the index of the clip @@ -1238,7 +1238,7 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length) { LE_NCONST uint8_t *const end = mFileBuffer + length; AI_LWO_VALIDATE_CHUNK_LENGTH(length, ENVL, 4); - mEnvelopes.push_back(LWO::Envelope()); + mEnvelopes.emplace_back(); LWO::Envelope &envelope = mEnvelopes.back(); // Get the index of the envelope @@ -1346,7 +1346,7 @@ void LWOImporter::LoadLWO3Envelope(unsigned int length) { LE_NCONST uint8_t *const end = mFileBuffer + length; AI_LWO_VALIDATE_CHUNK_LENGTH(length, ENVL, 4); - mEnvelopes.push_back(LWO::Envelope()); + mEnvelopes.emplace_back(); LWO::Envelope &envelope = mEnvelopes.back(); // Get the index of the envelope diff --git a/code/AssetLib/MD5/MD5Parser.cpp b/code/AssetLib/MD5/MD5Parser.cpp index 7ed23cb82..606660080 100644 --- a/code/AssetLib/MD5/MD5Parser.cpp +++ b/code/AssetLib/MD5/MD5Parser.cpp @@ -76,7 +76,7 @@ MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) { // and read all sections until we're finished bool running = true; while (running) { - mSections.push_back(Section()); + mSections.emplace_back(); Section &sec = mSections.back(); if (!ParseSection(sec)) { break; @@ -158,7 +158,7 @@ bool MD5Parser::ParseSection(Section &out) { break; } - out.mElements.push_back(Element()); + out.mElements.emplace_back(); Element &elem = out.mElements.back(); elem.iLineNumber = lineNumber; @@ -253,7 +253,7 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) { } else if ((*iter).mName == "joints") { // "origin" -1 ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000000 0.707107 ) for (const auto &elem : (*iter).mElements) { - mJoints.push_back(BoneDesc()); + mJoints.emplace_back(); BoneDesc &desc = mJoints.back(); const char *sz = elem.szStart; @@ -267,7 +267,7 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) { AI_MD5_READ_TRIPLE(desc.mRotationQuat); // normalized quaternion, so w is not there } } else if ((*iter).mName == "mesh") { - mMeshes.push_back(MeshDesc()); + mMeshes.emplace_back(); MeshDesc &desc = mMeshes.back(); for (const auto &elem : (*iter).mElements) { @@ -364,7 +364,7 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) { if ((*iter).mName == "hierarchy") { // "sheath" 0 63 6 for (const auto &elem : (*iter).mElements) { - mAnimatedBones.push_back(AnimBoneDesc()); + mAnimatedBones.emplace_back(); AnimBoneDesc &desc = mAnimatedBones.back(); const char *sz = elem.szStart; @@ -389,7 +389,7 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) { for (const auto &elem : (*iter).mElements) { const char *sz = elem.szStart; - mBaseFrames.push_back(BaseFrameDesc()); + mBaseFrames.emplace_back(); BaseFrameDesc &desc = mBaseFrames.back(); AI_MD5_READ_TRIPLE(desc.vPositionXYZ); @@ -401,7 +401,7 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) { continue; } - mFrames.push_back(FrameDesc()); + mFrames.emplace_back(); FrameDesc &desc = mFrames.back(); desc.iIndex = strtoul10((*iter).mGlobalValue.c_str()); @@ -459,7 +459,7 @@ MD5CameraParser::MD5CameraParser(SectionList &mSections) { for (const auto &elem : (*iter).mElements) { const char *sz = elem.szStart; - frames.push_back(CameraAnimFrameDesc()); + frames.emplace_back(); CameraAnimFrameDesc &cur = frames.back(); AI_MD5_READ_TRIPLE(cur.vPositionXYZ); AI_MD5_READ_TRIPLE(cur.vRotationQuat); diff --git a/code/AssetLib/MMD/MMDImporter.cpp b/code/AssetLib/MMD/MMDImporter.cpp index 7a9030b64..97b04f4eb 100644 --- a/code/AssetLib/MMD/MMDImporter.cpp +++ b/code/AssetLib/MMD/MMDImporter.cpp @@ -269,43 +269,30 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel, dynamic_cast(v->skinning.get()); switch (v->skinning_type) { case pmx::PmxVertexSkinningType::BDEF1: - bone_vertex_map[vsBDEF1_ptr->bone_index].push_back( - aiVertexWeight(index, 1.0)); + bone_vertex_map[vsBDEF1_ptr->bone_index].emplace_back(index, 1.0); break; case pmx::PmxVertexSkinningType::BDEF2: - bone_vertex_map[vsBDEF2_ptr->bone_index1].push_back( - aiVertexWeight(index, vsBDEF2_ptr->bone_weight)); - bone_vertex_map[vsBDEF2_ptr->bone_index2].push_back( - aiVertexWeight(index, 1.0f - vsBDEF2_ptr->bone_weight)); + bone_vertex_map[vsBDEF2_ptr->bone_index1].emplace_back(index, vsBDEF2_ptr->bone_weight); + bone_vertex_map[vsBDEF2_ptr->bone_index2].emplace_back(index, 1.0f - vsBDEF2_ptr->bone_weight); break; case pmx::PmxVertexSkinningType::BDEF4: - bone_vertex_map[vsBDEF4_ptr->bone_index1].push_back( - aiVertexWeight(index, vsBDEF4_ptr->bone_weight1)); - bone_vertex_map[vsBDEF4_ptr->bone_index2].push_back( - aiVertexWeight(index, vsBDEF4_ptr->bone_weight2)); - bone_vertex_map[vsBDEF4_ptr->bone_index3].push_back( - aiVertexWeight(index, vsBDEF4_ptr->bone_weight3)); - bone_vertex_map[vsBDEF4_ptr->bone_index4].push_back( - aiVertexWeight(index, vsBDEF4_ptr->bone_weight4)); + bone_vertex_map[vsBDEF4_ptr->bone_index1].emplace_back(index, vsBDEF4_ptr->bone_weight1); + bone_vertex_map[vsBDEF4_ptr->bone_index2].emplace_back(index, vsBDEF4_ptr->bone_weight2); + bone_vertex_map[vsBDEF4_ptr->bone_index3].emplace_back(index, vsBDEF4_ptr->bone_weight3); + bone_vertex_map[vsBDEF4_ptr->bone_index4].emplace_back(index, vsBDEF4_ptr->bone_weight4); break; case pmx::PmxVertexSkinningType::SDEF: // TODO: how to use sdef_c, sdef_r0, // sdef_r1? - bone_vertex_map[vsSDEF_ptr->bone_index1].push_back( - aiVertexWeight(index, vsSDEF_ptr->bone_weight)); - bone_vertex_map[vsSDEF_ptr->bone_index2].push_back( - aiVertexWeight(index, 1.0f - vsSDEF_ptr->bone_weight)); + bone_vertex_map[vsSDEF_ptr->bone_index1].emplace_back(index, vsSDEF_ptr->bone_weight); + bone_vertex_map[vsSDEF_ptr->bone_index2].emplace_back(index, 1.0f - vsSDEF_ptr->bone_weight); break; case pmx::PmxVertexSkinningType::QDEF: const auto vsQDEF_ptr = dynamic_cast(v->skinning.get()); - bone_vertex_map[vsQDEF_ptr->bone_index1].push_back( - aiVertexWeight(index, vsQDEF_ptr->bone_weight1)); - bone_vertex_map[vsQDEF_ptr->bone_index2].push_back( - aiVertexWeight(index, vsQDEF_ptr->bone_weight2)); - bone_vertex_map[vsQDEF_ptr->bone_index3].push_back( - aiVertexWeight(index, vsQDEF_ptr->bone_weight3)); - bone_vertex_map[vsQDEF_ptr->bone_index4].push_back( - aiVertexWeight(index, vsQDEF_ptr->bone_weight4)); + bone_vertex_map[vsQDEF_ptr->bone_index1].emplace_back(index, vsQDEF_ptr->bone_weight1); + bone_vertex_map[vsQDEF_ptr->bone_index2].emplace_back(index, vsQDEF_ptr->bone_weight2); + bone_vertex_map[vsQDEF_ptr->bone_index3].emplace_back(index, vsQDEF_ptr->bone_weight3); + bone_vertex_map[vsQDEF_ptr->bone_index4].emplace_back(index, vsQDEF_ptr->bone_weight4); break; } } diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp index 5ea4f00e1..a91788c78 100644 --- a/code/AssetLib/Q3D/Q3DLoader.cpp +++ b/code/AssetLib/Q3D/Q3DLoader.cpp @@ -418,7 +418,7 @@ outer: (*fit).mat = 0; } if (fidx[(*fit).mat].empty()) ++pScene->mNumMeshes; - fidx[(*fit).mat].push_back(FaceIdx(p, q)); + fidx[(*fit).mat].emplace_back(p, q); } } pScene->mNumMaterials = pScene->mNumMeshes; diff --git a/code/PostProcessing/DeboneProcess.cpp b/code/PostProcessing/DeboneProcess.cpp index 2412eb9d8..bbf3264a5 100644 --- a/code/PostProcessing/DeboneProcess.cpp +++ b/code/PostProcessing/DeboneProcess.cpp @@ -153,7 +153,7 @@ void DeboneProcess::Execute( aiScene* pScene) } else { // Mesh is kept unchanged - store it's new place in the mesh array - mSubMeshIndices[a].push_back(std::pair(static_cast(meshes.size()),(aiNode*)0)); + mSubMeshIndices[a].emplace_back(static_cast(meshes.size()), (aiNode *)0); meshes.push_back(srcMesh); } } diff --git a/code/PostProcessing/ProcessHelper.cpp b/code/PostProcessing/ProcessHelper.cpp index d819012d9..15f01676c 100644 --- a/code/PostProcessing/ProcessHelper.cpp +++ b/code/PostProcessing/ProcessHelper.cpp @@ -208,7 +208,7 @@ VertexWeightTable *ComputeVertexBoneWeightTable(const aiMesh *pMesh) { aiBone *bone = pMesh->mBones[i]; for (unsigned int a = 0; a < bone->mNumWeights; ++a) { const aiVertexWeight &weight = bone->mWeights[a]; - avPerVertexWeights[weight.mVertexId].push_back(std::pair(i, weight.mWeight)); + avPerVertexWeights[weight.mVertexId].emplace_back(i, weight.mWeight); } } return avPerVertexWeights; diff --git a/code/PostProcessing/SortByPTypeProcess.cpp b/code/PostProcessing/SortByPTypeProcess.cpp index 0c5d78350..6312fa173 100644 --- a/code/PostProcessing/SortByPTypeProcess.cpp +++ b/code/PostProcessing/SortByPTypeProcess.cpp @@ -309,7 +309,7 @@ void SortByPTypeProcess::Execute(aiScene *pScene) { VertexWeightTable &tbl = avw[idx]; for (VertexWeightTable::const_iterator it = tbl.begin(), end = tbl.end(); it != end; ++it) { - tempBones[(*it).first].push_back(aiVertexWeight(outIdx, (*it).second)); + tempBones[(*it).first].emplace_back(outIdx, (*it).second); } } diff --git a/code/PostProcessing/SplitByBoneCountProcess.cpp b/code/PostProcessing/SplitByBoneCountProcess.cpp index 5e052b76a..a501d3bd6 100644 --- a/code/PostProcessing/SplitByBoneCountProcess.cpp +++ b/code/PostProcessing/SplitByBoneCountProcess.cpp @@ -173,7 +173,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormWeights[b].mWeight > 0.0f) { int vertexId = bone->mWeights[b].mVertexId; - vertexBones[vertexId].push_back( BoneWeight( a, bone->mWeights[b].mWeight)); + vertexBones[vertexId].emplace_back(a, bone->mWeights[b].mWeight); if (vertexBones[vertexId].size() > mMaxBoneCount) { throw DeadlyImportError("SplitByBoneCountProcess: Single face requires more bones than specified max bone count!"); diff --git a/code/PostProcessing/TextureTransform.cpp b/code/PostProcessing/TextureTransform.cpp index 2699863d1..efbf4d2c6 100644 --- a/code/PostProcessing/TextureTransform.cpp +++ b/code/PostProcessing/TextureTransform.cpp @@ -434,7 +434,7 @@ void TextureTransformStep::Execute( aiScene* pScene) for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) { if (ref[n]) continue; - trafo.push_back(STransformVecInfo()); + trafo.emplace_back(); trafo.back().uvIndex = n; } diff --git a/test/unit/utLimitBoneWeights.cpp b/test/unit/utLimitBoneWeights.cpp index 0c24b56c4..bf3ea93f5 100644 --- a/test/unit/utLimitBoneWeights.cpp +++ b/test/unit/utLimitBoneWeights.cpp @@ -114,7 +114,7 @@ TEST_F(LimitBoneWeightsTest, testProcess) { aiBone &pcBone = **(mMesh->mBones + i); for (unsigned int q = 0; q < pcBone.mNumWeights; ++q) { aiVertexWeight weight = pcBone.mWeights[q]; - asWeights[weight.mVertexId].push_back(LimitBoneWeightsProcess::Weight(i, weight.mWeight)); + asWeights[weight.mVertexId].emplace_back(i, weight.mWeight); } } diff --git a/tools/assimp_cmd/CompareDump.cpp b/tools/assimp_cmd/CompareDump.cpp index 4c2df2d9e..f5766a47d 100644 --- a/tools/assimp_cmd/CompareDump.cpp +++ b/tools/assimp_cmd/CompareDump.cpp @@ -125,10 +125,10 @@ public: ai_assert(expect); fseek(actual,0,SEEK_END); - lengths.push(std::make_pair(static_cast(ftell(actual)),0)); + lengths.emplace(static_cast(ftell(actual)),0); fseek(actual,0,SEEK_SET); - history.push_back(HistoryEntry("---",PerChunkCounter())); + history.emplace_back("---",PerChunkCounter()); } public: @@ -144,7 +144,7 @@ public: } else history.back().second[s] = 0; - history.push_back(HistoryEntry(s,PerChunkCounter())); + history.emplace_back(s,PerChunkCounter()); debug_trace.push_back("PUSH " + s); } @@ -158,7 +158,7 @@ public: /* push current chunk length and start offset on top of stack */ void push_length(uint32_t nl, uint32_t start) { - lengths.push(std::make_pair(nl,start)); + lengths.emplace(nl,start); ++cnt_chunks; } From d15b4ad7ef5c0bd199bdcc0fd4a2a43e3421705b Mon Sep 17 00:00:00 2001 From: Gargaj Date: Wed, 24 Aug 2022 21:24:09 +0200 Subject: [PATCH 38/39] add missing light data to assbin import/export --- code/AssetLib/Assbin/AssbinFileWriter.cpp | 4 ++++ code/AssetLib/Assbin/AssbinLoader.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/code/AssetLib/Assbin/AssbinFileWriter.cpp b/code/AssetLib/Assbin/AssbinFileWriter.cpp index d1388cde6..97be634de 100644 --- a/code/AssetLib/Assbin/AssbinFileWriter.cpp +++ b/code/AssetLib/Assbin/AssbinFileWriter.cpp @@ -642,6 +642,10 @@ protected: Write(&chunk, l->mName); Write(&chunk, l->mType); + Write(&chunk, l->mPosition); + Write(&chunk, l->mDirection); + Write(&chunk, l->mUp); + if (l->mType != aiLightSource_DIRECTIONAL) { Write(&chunk, l->mAttenuationConstant); Write(&chunk, l->mAttenuationLinear); diff --git a/code/AssetLib/Assbin/AssbinLoader.cpp b/code/AssetLib/Assbin/AssbinLoader.cpp index 060ce4377..f7b35636c 100644 --- a/code/AssetLib/Assbin/AssbinLoader.cpp +++ b/code/AssetLib/Assbin/AssbinLoader.cpp @@ -556,6 +556,10 @@ void AssbinImporter::ReadBinaryLight(IOStream *stream, aiLight *l) { l->mName = Read(stream); l->mType = (aiLightSourceType)Read(stream); + l->mPosition = Read(stream); + l->mDirection = Read(stream); + l->mUp = Read(stream); + if (l->mType != aiLightSource_DIRECTIONAL) { l->mAttenuationConstant = Read(stream); l->mAttenuationLinear = Read(stream); From 4b0e38e44ff12d8a1e91812f60f4606cb939d85e Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 5 Sep 2022 11:00:57 -0500 Subject: [PATCH 39/39] Fix aiBone.mOffsetMatrix documentation Fixed the comment on the `mOffsetMatrix` property to be correct. See https://assimp-docs.readthedocs.io/en/latest/API/API-Documentation.html#_CPPv46aiBone See also https://stackoverflow.com/a/73603994 --- include/assimp/mesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h index ffac27bb0..49d43f9f9 100644 --- a/include/assimp/mesh.h +++ b/include/assimp/mesh.h @@ -281,7 +281,7 @@ struct aiBone { //! The influence weights of this bone, by vertex index. C_STRUCT aiVertexWeight *mWeights; - /** Matrix that transforms from bone space to mesh space in bind pose. + /** Matrix that transforms from mesh space to bone space in bind pose. * * This matrix describes the position of the mesh * in the local space of this bone when the skeleton was bound.