From aca6aaf35d6c17d91fd8e6e8c4cc4e9d82164f7d Mon Sep 17 00:00:00 2001 From: iamAdrianIusca Date: Sun, 1 Mar 2020 11:12:37 +0200 Subject: [PATCH] small changes - removed static definition - use emplace_back instead of push_back - changed the c++ deprecated headers - removed some redundant std containers initialization in the destructor - removed redundant .clear call for the std containers in the destructor - added some const reference for some std container parameters - other small changes in different places --- code/Common/BaseImporter.cpp | 7 +- code/Common/Importer.h | 6 -- code/Common/SceneCombiner.cpp | 16 ++-- code/Common/SkeletonMeshBuilder.cpp | 74 +++++++++---------- code/Common/SpatialSort.cpp | 4 +- code/Common/SplitByBoneCountProcess.cpp | 4 +- code/Common/StandardShapes.cpp | 22 +++--- code/Common/TargetAnimation.cpp | 2 +- code/Obj/ObjFileData.h | 26 ++----- code/Obj/ObjFileImporter.cpp | 2 +- code/Obj/ObjFileParser.cpp | 7 +- .../ComputeUVMappingProcess.cpp | 8 +- code/PostProcessing/DeboneProcess.cpp | 8 +- .../PostProcessing/FindInvalidDataProcess.cpp | 2 +- .../GenVertexNormalsProcess.cpp | 4 +- code/PostProcessing/JoinVerticesProcess.cpp | 2 +- .../LimitBoneWeightsProcess.cpp | 4 +- code/PostProcessing/OptimizeMeshes.cpp | 2 +- code/PostProcessing/ProcessHelper.cpp | 2 +- code/PostProcessing/SortByPTypeProcess.cpp | 2 +- code/PostProcessing/SplitLargeMeshes.cpp | 4 +- code/PostProcessing/TriangulateProcess.cpp | 2 +- include/assimp/SceneCombiner.h | 4 +- 23 files changed, 99 insertions(+), 115 deletions(-) diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index 8d7b029ba..f47532b43 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -60,6 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include using namespace Assimp; @@ -484,11 +485,11 @@ void BaseImporter::TextFileToBuffer(IOStream* stream, namespace Assimp { // Represents an import request struct LoadRequest { - LoadRequest(const std::string& _file, unsigned int _flags,const BatchLoader::PropertyMap* _map, unsigned int _id) - : file(_file) + LoadRequest(std::string _file, unsigned int _flags,const BatchLoader::PropertyMap* _map, unsigned int _id) + : file(std::move(_file)) , flags(_flags) , refCnt(1) - , scene(NULL) + , scene(nullptr) , loaded(false) , id(_id) { if ( _map ) { diff --git a/code/Common/Importer.h b/code/Common/Importer.h index c31f67caa..07571de5d 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 29b6082a8..423cdaa35 100644 --- a/code/Common/SceneCombiner.cpp +++ b/code/Common/SceneCombiner.cpp @@ -503,7 +503,7 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vector& asBones, std::vector::const_iterator it, - std::vector::const_iterator end) + const std::vector::const_iterator& end) { unsigned int iOffset = 0; for (; it != end;++it) { @@ -670,24 +670,24 @@ void SceneCombiner::BuildUniqueBoneList(std::list& asBones, aiBone* p = (*it)->mBones[l]; uint32_t itml = SuperFastHash(p->mName.data,(unsigned int)p->mName.length); - std::list::iterator it2 = asBones.begin(); - std::list::iterator end2 = asBones.end(); + auto it2 = asBones.begin(); + auto end2 = asBones.end(); 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; @@ -697,7 +697,7 @@ void SceneCombiner::BuildUniqueBoneList(std::list& asBones, // ------------------------------------------------------------------------------------------------ // Merge a list of bones void SceneCombiner::MergeBones(aiMesh* out,std::vector::const_iterator it, - std::vector::const_iterator end) + const std::vector::const_iterator& end) { if ( nullptr == out || out->mNumBones == 0 ) { return; diff --git a/code/Common/SkeletonMeshBuilder.cpp b/code/Common/SkeletonMeshBuilder.cpp index 724359f99..a4a163fc6 100644 --- a/code/Common/SkeletonMeshBuilder.cpp +++ b/code/Common/SkeletonMeshBuilder.cpp @@ -124,10 +124,10 @@ 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 @@ -136,40 +136,40 @@ void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode) 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); @@ -259,7 +259,7 @@ aiMaterial* SkeletonMeshBuilder::CreateMaterial() aiMaterial* matHelper = new aiMaterial; // Name - aiString matName( std::string( "SkeletonMaterial")); + aiString matName("SkeletonMaterial"); matHelper->AddProperty( &matName, AI_MATKEY_NAME); // Prevent backface culling diff --git a/code/Common/SpatialSort.cpp b/code/Common/SpatialSort.cpp index 604b086b7..5d5725681 100644 --- a/code/Common/SpatialSort.cpp +++ b/code/Common/SpatialSort.cpp @@ -110,7 +110,7 @@ void SpatialSort::Append( const aiVector3D* pPositions, unsigned int pNumPositio // store position by index and distance ai_real distance = *vec * mPlaneNormal; - mPositions.push_back( Entry( static_cast(a+initial), *vec, distance)); + mPositions.emplace_back( static_cast(a+initial), *vec, distance); } if (pFinalize) { @@ -131,7 +131,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/SplitByBoneCountProcess.cpp b/code/Common/SplitByBoneCountProcess.cpp index b472cb359..6de4be062 100644 --- a/code/Common/SplitByBoneCountProcess.cpp +++ b/code/Common/SplitByBoneCountProcess.cpp @@ -74,7 +74,7 @@ SplitByBoneCountProcess::~SplitByBoneCountProcess() // Returns whether the processing step is present in the given flag. bool SplitByBoneCountProcess::IsActive( unsigned int pFlags) const { - return !!(pFlags & aiProcess_SplitByBoneCount); + return (pFlags & aiProcess_SplitByBoneCount) != 0; } // ------------------------------------------------------------------------------------------------ @@ -165,7 +165,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormBones[a]; for( unsigned int b = 0; b < bone->mNumWeights; ++b) - vertexBones[ bone->mWeights[b].mVertexId ].push_back( BoneWeight( a, bone->mWeights[b].mWeight)); + vertexBones[ bone->mWeights[b].mVertexId ].emplace_back( a, bone->mWeights[b].mWeight); } unsigned int numFacesHandled = 0; diff --git a/code/Common/StandardShapes.cpp b/code/Common/StandardShapes.cpp index d474c6129..e51fe8676 100644 --- a/code/Common/StandardShapes.cpp +++ b/code/Common/StandardShapes.cpp @@ -445,20 +445,19 @@ 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; t = t2; angle = next; @@ -494,13 +493,14 @@ void StandardShapes::MakeCircle(ai_real radius, unsigned int tess, 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.push_back(aiVector3D(0.0,0.0,0.0)); + positions.emplace_back(s * radius,0.0,t * radius); + positions.emplace_back(0.0,0.0,0.0); } } diff --git a/code/Common/TargetAnimation.cpp b/code/Common/TargetAnimation.cpp index 3c61d2176..0c8950908 100644 --- a/code/Common/TargetAnimation.cpp +++ b/code/Common/TargetAnimation.cpp @@ -242,7 +242,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/Obj/ObjFileData.h b/code/Obj/ObjFileData.h index 298d1e1b7..be7130e44 100644 --- a/code/Obj/ObjFileData.h +++ b/code/Obj/ObjFileData.h @@ -75,19 +75,14 @@ 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 ) { + , m_pMaterial( nullptr ) { // empty } //! \brief Destructor - ~Face() { - // empty - } + ~Face() = default; }; // ------------------------------------------------------------------------------------------------ @@ -285,14 +280,12 @@ struct Model { //! \brief The default class constructor Model() : - m_ModelName(""), - m_pCurrent(NULL), - m_pCurrentMaterial(NULL), - m_pDefaultMaterial(NULL), - m_pGroupFaceIDs(NULL), - m_strActiveGroup(""), + m_pCurrent(nullptr), + m_pCurrentMaterial(nullptr), + m_pDefaultMaterial(nullptr), + m_pGroupFaceIDs(nullptr), m_TextureCoordDim(0), - m_pCurrentMesh(NULL) + m_pCurrentMesh(nullptr) { // empty } @@ -304,19 +297,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/Obj/ObjFileImporter.cpp b/code/Obj/ObjFileImporter.cpp index d73cc5b32..c1aa0d5bf 100644 --- a/code/Obj/ObjFileImporter.cpp +++ b/code/Obj/ObjFileImporter.cpp @@ -112,7 +112,7 @@ void ObjFileImporter::InternReadFile( const std::string &file, aiScene* pScene, // Read file into memory static const std::string mode = "rb"; std::unique_ptr fileStream( pIOHandler->Open( file, mode)); - if( !fileStream.get() ) { + if(!fileStream) { throw DeadlyImportError( "Failed to open file " + file + "." ); } diff --git a/code/Obj/ObjFileParser.cpp b/code/Obj/ObjFileParser.cpp index 7ba2216ae..6fae8794d 100644 --- a/code/Obj/ObjFileParser.cpp +++ b/code/Obj/ObjFileParser.cpp @@ -66,8 +66,7 @@ ObjFileParser::ObjFileParser() , m_pModel( nullptr ) , m_uiLine( 0 ) , m_pIO( nullptr ) -, m_progress( nullptr ) -, m_originalObjFileName() { +, m_progress( nullptr ) { // empty } @@ -567,7 +566,7 @@ void ObjFileParser::getMaterialDesc() { if (!skip) { // Search for material - std::map::iterator it = m_pModel->m_MaterialMap.find(strName); + auto it = m_pModel->m_MaterialMap.find(strName); if (it == m_pModel->m_MaterialMap.end()) { // Not found, so we don't know anything about the material except for its name. // This may be the case if the material library is missing. We don't want to lose all @@ -674,7 +673,7 @@ void ObjFileParser::getNewMaterial() { while( m_DataIt != m_DataItEnd && IsSpaceOrNewLine( *m_DataIt ) ) { ++m_DataIt; } - std::map::iterator it = m_pModel->m_MaterialMap.find( strMat ); + auto it = m_pModel->m_MaterialMap.find( strMat ); if ( it == m_pModel->m_MaterialMap.end() ) { // Show a warning, if material was not found ASSIMP_LOG_WARN("OBJ: Unsupported material requested: " + strMat); 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 9d6313f71..e3bf88d00 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 c557d7f70..bddf93f9f 100644 --- a/code/PostProcessing/FindInvalidDataProcess.cpp +++ b/code/PostProcessing/FindInvalidDataProcess.cpp @@ -183,7 +183,7 @@ const char* ValidateArrayContents(const aiVector3D* arr, unsigned in 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 1df333410..e31ca0bb9 100644 --- a/code/PostProcessing/GenVertexNormalsProcess.cpp +++ b/code/PostProcessing/GenVertexNormalsProcess.cpp @@ -158,9 +158,9 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int // Set up a SpatialSort to quickly find all vertices close to a given position // check whether we can reuse the SpatialSort of a previous step. - SpatialSort* vertexFinder = NULL; + SpatialSort* vertexFinder = nullptr; SpatialSort _vertexFinder; - ai_real posEpsilon = ai_real( 1e-5 ); + ai_real posEpsilon; if (shared) { std::vector >* avf; shared->GetProperty(AI_SPP_SPATIAL_SORT,avf); diff --git a/code/PostProcessing/JoinVerticesProcess.cpp b/code/PostProcessing/JoinVerticesProcess.cpp index 070c9636f..6da602e03 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 NULL." ); } - 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 1f1abfabb..012897391 100644 --- a/code/PostProcessing/LimitBoneWeightsProcess.cpp +++ b/code/PostProcessing/LimitBoneWeightsProcess.cpp @@ -111,7 +111,7 @@ void LimitBoneWeightsProcess::ProcessMesh( aiMesh* pMesh) for( unsigned int b = 0; b < bone->mNumWeights; b++) { const aiVertexWeight& w = bone->mWeights[b]; - vertexWeights[w.mVertexId].push_back( Weight( a, w.mWeight)); + vertexWeights[w.mVertexId].emplace_back( a, w.mWeight); } } @@ -156,7 +156,7 @@ void LimitBoneWeightsProcess::ProcessMesh( aiMesh* pMesh) { const std::vector& vw = vertexWeights[a]; for( std::vector::const_iterator it = vw.begin(); it != vw.end(); ++it) - boneWeights[it->mBone].push_back( aiVertexWeight( a, it->mWeight)); + boneWeights[it->mBone].emplace_back( a, it->mWeight); } // and finally copy the vertex weight list over to the mesh's bones 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 123986438..6abaa3a6d 100644 --- a/code/PostProcessing/ProcessHelper.cpp +++ b/code/PostProcessing/ProcessHelper.cpp @@ -66,7 +66,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 { diff --git a/code/PostProcessing/SortByPTypeProcess.cpp b/code/PostProcessing/SortByPTypeProcess.cpp index c1b08c5a7..3831dafea 100644 --- a/code/PostProcessing/SortByPTypeProcess.cpp +++ b/code/PostProcessing/SortByPTypeProcess.cpp @@ -293,7 +293,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { 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/SplitLargeMeshes.cpp b/code/PostProcessing/SplitLargeMeshes.cpp index 70960f4a8..119ac96b5 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 64cc63bbd..76376b628 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 diff --git a/include/assimp/SceneCombiner.h b/include/assimp/SceneCombiner.h index 40aad0890..02269cade 100644 --- a/include/assimp/SceneCombiner.h +++ b/include/assimp/SceneCombiner.h @@ -274,7 +274,7 @@ public: * @param end Points to the mesh after the last mesh to be processed */ static void MergeBones(aiMesh* out,std::vector::const_iterator it, - std::vector::const_iterator end); + const std::vector::const_iterator& end); // ------------------------------------------------------------------- /** Merges two or more materials @@ -300,7 +300,7 @@ public: */ static void BuildUniqueBoneList(std::list& asBones, std::vector::const_iterator it, - std::vector::const_iterator end); + const std::vector::const_iterator& end); // ------------------------------------------------------------------- /** Add a name prefix to all nodes in a scene.