diff --git a/code/AssetLib/Obj/ObjFileData.h b/code/AssetLib/Obj/ObjFileData.h index 5982be44d..693ff9ee6 100644 --- a/code/AssetLib/Obj/ObjFileData.h +++ b/code/AssetLib/Obj/ObjFileData.h @@ -74,15 +74,13 @@ struct Face { Material *m_pMaterial; //! \brief Default constructor - Face(aiPrimitiveType pt = aiPrimitiveType_POLYGON) : + explicit Face(aiPrimitiveType pt = aiPrimitiveType_POLYGON) : m_PrimitiveType(pt), m_vertices(), m_normals(), m_texturCoords(), m_pMaterial(0L) { // empty } //! \brief Destructor - ~Face() { - // empty - } + ~Face() = default; }; // ------------------------------------------------------------------------------------------------ @@ -296,19 +294,16 @@ struct Model { it != m_Objects.end(); ++it) { delete *it; } - m_Objects.clear(); // Clear all stored mesh instances for (std::vector::iterator it = m_Meshes.begin(); it != m_Meshes.end(); ++it) { delete *it; } - m_Meshes.clear(); for (GroupMapIt it = m_Groups.begin(); it != m_Groups.end(); ++it) { delete it->second; } - m_Groups.clear(); for (std::map::iterator it = m_MaterialMap.begin(); it != m_MaterialMap.end(); ++it) { delete it->second; diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index 47ff05f2f..4243f0b78 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -60,6 +60,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include +#include using namespace Assimp; diff --git a/code/Common/Importer.h b/code/Common/Importer.h index eaf42e9c5..c1b4ab6e1 100644 --- a/code/Common/Importer.h +++ b/code/Common/Importer.h @@ -129,14 +129,8 @@ ImporterPimpl::ImporterPimpl() AI_NO_EXCEPT , mIsDefaultHandler( false ) , mProgressHandler( nullptr ) , mIsDefaultProgressHandler( false ) -, mImporter() , mPostProcessingSteps() , mScene( nullptr ) -, mErrorString() -, mIntProperties() -, mFloatProperties() -, mStringProperties() -, mMatrixProperties() , bExtraVerbose( false ) , mPPShared( nullptr ) { // empty diff --git a/code/Common/SceneCombiner.cpp b/code/Common/SceneCombiner.cpp index bfc4899a1..b47f049e7 100644 --- a/code/Common/SceneCombiner.cpp +++ b/code/Common/SceneCombiner.cpp @@ -66,10 +66,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { +// clang-format off #if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wclass-memaccess" #endif +// clang-format on // ------------------------------------------------------------------------------------------------ // Add a prefix to a string @@ -495,7 +497,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector= 8 && __GNUC_MINOR__ >= 0) -#pragma GCC diagnostic pop +# pragma GCC diagnostic pop #endif +// clang-format on } // Namespace Assimp diff --git a/code/Common/SkeletonMeshBuilder.cpp b/code/Common/SkeletonMeshBuilder.cpp index 7387744bf..97b811e16 100644 --- a/code/Common/SkeletonMeshBuilder.cpp +++ b/code/Common/SkeletonMeshBuilder.cpp @@ -253,6 +253,8 @@ aiMaterial *SkeletonMeshBuilder::CreateMaterial() { // Name aiString matName(std::string("SkeletonMaterial")); matHelper->AddProperty(&matName, AI_MATKEY_NAME); + aiString matName("SkeletonMaterial"); + matHelper->AddProperty( &matName, AI_MATKEY_NAME); // Prevent backface culling const int no_cull = 1; diff --git a/code/Common/SpatialSort.cpp b/code/Common/SpatialSort.cpp index 88f06b618..42eddbc8a 100644 --- a/code/Common/SpatialSort.cpp +++ b/code/Common/SpatialSort.cpp @@ -101,7 +101,7 @@ void SpatialSort::Append(const aiVector3D *pPositions, unsigned int pNumPosition // store position by index and distance ai_real distance = *vec * mPlaneNormal; - mPositions.push_back(Entry(static_cast(a + initial), *vec, distance)); + mPositions.emplace_back(Entry(static_cast(a + initial), *vec, distance)); } if (pFinalize) { @@ -121,7 +121,7 @@ void SpatialSort::FindPositions(const aiVector3D &pPosition, poResults.clear(); // quick check for positions outside the range - if (mPositions.size() == 0) + if( mPositions.empty()) return; if (maxDist < mPositions.front().mDistance) return; diff --git a/code/Common/StandardShapes.cpp b/code/Common/StandardShapes.cpp index b30fa2e25..b94998f1c 100644 --- a/code/Common/StandardShapes.cpp +++ b/code/Common/StandardShapes.cpp @@ -423,17 +423,18 @@ 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(ai_real(0.0), halfHeight, ai_real(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(ai_real(0.0), -halfHeight, ai_real(0.0)); } } + s = s2; t = t2; angle = next; @@ -466,14 +467,15 @@ void StandardShapes::MakeCircle(ai_real radius, unsigned int tess, ai_real s = 1.0; // std::cos(angle == 0); ai_real t = 0.0; // std::sin(angle == 0); +<<<<<<< HEAD for (ai_real angle = 0.0; angle < angle_max;) { - positions.push_back(aiVector3D(s * radius, 0.0, t * radius)); + positions.emplace_back(aiVector3D(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(aiVector3D(s * radius, 0.0, t * radius)); - positions.push_back(aiVector3D(0.0, 0.0, 0.0)); + positions.emplace_back(aiVector3D(0.0, 0.0, 0.0)); } } diff --git a/code/Common/TargetAnimation.cpp b/code/Common/TargetAnimation.cpp index 05fd334c4..e9a98f1d9 100644 --- a/code/Common/TargetAnimation.cpp +++ b/code/Common/TargetAnimation.cpp @@ -220,7 +220,7 @@ void TargetAnimationHelper::Process(std::vector *distanceTrack) { // diff is now the vector in which our camera is pointing } - if (real.size()) { + if (!real.empty()) { *distanceTrack = real; } } diff --git a/code/PostProcessing/ComputeUVMappingProcess.cpp b/code/PostProcessing/ComputeUVMappingProcess.cpp index 1ebf798bd..01965715e 100644 --- a/code/PostProcessing/ComputeUVMappingProcess.cpp +++ b/code/PostProcessing/ComputeUVMappingProcess.cpp @@ -51,10 +51,10 @@ using namespace Assimp; namespace { - const static aiVector3D base_axis_y(0.0,1.0,0.0); - const static aiVector3D base_axis_x(1.0,0.0,0.0); - const static aiVector3D base_axis_z(0.0,0.0,1.0); - const static ai_real angle_epsilon = ai_real( 0.95 ); + const aiVector3D base_axis_y(0.0,1.0,0.0); + const aiVector3D base_axis_x(1.0,0.0,0.0); + const aiVector3D base_axis_z(0.0,0.0,1.0); + const ai_real angle_epsilon = ai_real( 0.95 ); } // ------------------------------------------------------------------------------------------------ diff --git a/code/PostProcessing/DeboneProcess.cpp b/code/PostProcessing/DeboneProcess.cpp index 4d9cb6ab6..96c96fe08 100644 --- a/code/PostProcessing/DeboneProcess.cpp +++ b/code/PostProcessing/DeboneProcess.cpp @@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // internal headers of the post-processing framework #include "ProcessHelper.h" #include "DeboneProcess.h" -#include +#include using namespace Assimp; @@ -83,7 +83,7 @@ bool DeboneProcess::IsActive( unsigned int pFlags) const void DeboneProcess::SetupProperties(const Importer* pImp) { // get the current value of the property - mAllOrNone = pImp->GetPropertyInteger(AI_CONFIG_PP_DB_ALL_OR_NONE,0)?true:false; + mAllOrNone = pImp->GetPropertyInteger(AI_CONFIG_PP_DB_ALL_OR_NONE, 0) != 0; mThreshold = pImp->GetPropertyFloat(AI_CONFIG_PP_DB_THRESHOLD,AI_DEBONE_THRESHOLD); } @@ -104,7 +104,7 @@ void DeboneProcess::Execute( aiScene* pScene) int numSplits = 0; - if(!!mNumBonesCanDoWithout && (!mAllOrNone||mNumBonesCanDoWithout==mNumBones)) { + if(mNumBonesCanDoWithout != 0 && (!mAllOrNone || mNumBonesCanDoWithout == mNumBones)) { for(unsigned int a = 0; a < pScene->mNumMeshes; a++) { if(splitList[a]) { numSplits++; @@ -156,7 +156,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/FindInvalidDataProcess.cpp b/code/PostProcessing/FindInvalidDataProcess.cpp index dc2b3c548..a329d88f9 100644 --- a/code/PostProcessing/FindInvalidDataProcess.cpp +++ b/code/PostProcessing/FindInvalidDataProcess.cpp @@ -174,7 +174,7 @@ inline const char *ValidateArrayContents(const aiVector3D *arr, unsi unsigned int cnt = 0; for (unsigned int i = 0; i < size; ++i) { - if (dirtyMask.size() && dirtyMask[i]) { + if (!dirtyMask.empty() && dirtyMask[i]) { continue; } ++cnt; diff --git a/code/PostProcessing/GenVertexNormalsProcess.cpp b/code/PostProcessing/GenVertexNormalsProcess.cpp index 72031153b..4153a0444 100644 --- a/code/PostProcessing/GenVertexNormalsProcess.cpp +++ b/code/PostProcessing/GenVertexNormalsProcess.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/code/PostProcessing/JoinVerticesProcess.cpp b/code/PostProcessing/JoinVerticesProcess.cpp index 5f8139536..7baa59790 100644 --- a/code/PostProcessing/JoinVerticesProcess.cpp +++ b/code/PostProcessing/JoinVerticesProcess.cpp @@ -423,7 +423,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) ASSIMP_LOG_ERROR( "X-Export: aiBone shall contain weights, but pointer to them is nullptr." ); } - if (newWeights.size() > 0) { + if (!newWeights.empty()) { // kill the old and replace them with the translated weights delete [] bone->mWeights; bone->mNumWeights = (unsigned int)newWeights.size(); diff --git a/code/PostProcessing/LimitBoneWeightsProcess.cpp b/code/PostProcessing/LimitBoneWeightsProcess.cpp index b4f0b48d8..18d732e78 100644 --- a/code/PostProcessing/LimitBoneWeightsProcess.cpp +++ b/code/PostProcessing/LimitBoneWeightsProcess.cpp @@ -55,22 +55,19 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -LimitBoneWeightsProcess::LimitBoneWeightsProcess() -{ +LimitBoneWeightsProcess::LimitBoneWeightsProcess() { mMaxWeights = AI_LMW_MAX_WEIGHTS; } // ------------------------------------------------------------------------------------------------ // Destructor, private as well -LimitBoneWeightsProcess::~LimitBoneWeightsProcess() -{ +LimitBoneWeightsProcess::~LimitBoneWeightsProcess() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool LimitBoneWeightsProcess::IsActive( unsigned int pFlags) const -{ +bool LimitBoneWeightsProcess::IsActive(unsigned int pFlags) const { return (pFlags & aiProcess_LimitBoneWeights) != 0; } @@ -89,10 +86,9 @@ void LimitBoneWeightsProcess::Execute( aiScene* pScene) // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void LimitBoneWeightsProcess::SetupProperties(const Importer* pImp) -{ +void LimitBoneWeightsProcess::SetupProperties(const Importer *pImp) { // get the current value of the property - this->mMaxWeights = pImp->GetPropertyInteger(AI_CONFIG_PP_LBW_MAX_WEIGHTS,AI_LMW_MAX_WEIGHTS); + this->mMaxWeights = pImp->GetPropertyInteger(AI_CONFIG_PP_LBW_MAX_WEIGHTS, AI_LMW_MAX_WEIGHTS); } // ------------------------------------------------------------------------------------------------ diff --git a/code/PostProcessing/OptimizeMeshes.cpp b/code/PostProcessing/OptimizeMeshes.cpp index 983d8001f..acd0565f7 100644 --- a/code/PostProcessing/OptimizeMeshes.cpp +++ b/code/PostProcessing/OptimizeMeshes.cpp @@ -140,7 +140,7 @@ void OptimizeMeshesProcess::Execute( aiScene* pScene) // and process all nodes in the scenegraph recursively ProcessNode(pScene->mRootNode); - if (!output.size()) { + if (output.empty()) { throw DeadlyImportError("OptimizeMeshes: No meshes remaining; there's definitely something wrong"); } diff --git a/code/PostProcessing/ProcessHelper.cpp b/code/PostProcessing/ProcessHelper.cpp index e3a8aab8a..b1cfc9e7b 100644 --- a/code/PostProcessing/ProcessHelper.cpp +++ b/code/PostProcessing/ProcessHelper.cpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -63,7 +62,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/SortByPTypeProcess.cpp b/code/PostProcessing/SortByPTypeProcess.cpp index c4f9c7e4d..4a78fa90c 100644 --- a/code/PostProcessing/SortByPTypeProcess.cpp +++ b/code/PostProcessing/SortByPTypeProcess.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -269,7 +267,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(aiVertexWeight(outIdx, (*it).second)); } } diff --git a/code/PostProcessing/SplitLargeMeshes.cpp b/code/PostProcessing/SplitLargeMeshes.cpp index d74a335ad..2c289e654 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); } } diff --git a/code/PostProcessing/TriangulateProcess.cpp b/code/PostProcessing/TriangulateProcess.cpp index 8035b34f4..a314f7f9d 100644 --- a/code/PostProcessing/TriangulateProcess.cpp +++ b/code/PostProcessing/TriangulateProcess.cpp @@ -200,7 +200,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) aiFace& face = pMesh->mFaces[a]; unsigned int* idx = face.mIndices; - int num = (int)face.mNumIndices, ear = 0, tmp, prev = num-1, next = 0, max = num; + int num = (int)face.mNumIndices, ear, tmp, prev = num - 1, next = 0, max = num; // Apply vertex colors to represent the face winding? #ifdef AI_BUILD_TRIANGULATE_COLOR_FACE_WINDING @@ -476,7 +476,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) for(aiFace* f = last_face; f != curOut; ++f) { unsigned int* i = f->mIndices; - fprintf(fout," (%i %i %i)",i[0],i[1],i[2]); + fprintf(fout," (%u %u %u)",i[0],i[1],i[2]); } fprintf(fout,"\n*********************************************************************\n"); diff --git a/include/assimp/SceneCombiner.h b/include/assimp/SceneCombiner.h index ff347d4fa..80f79056f 100644 --- a/include/assimp/SceneCombiner.h +++ b/include/assimp/SceneCombiner.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms,