diff --git a/code/PostProcessing/DeboneProcess.cpp b/code/PostProcessing/DeboneProcess.cpp index 22a4397bf..2a8499dc5 100644 --- a/code/PostProcessing/DeboneProcess.cpp +++ b/code/PostProcessing/DeboneProcess.cpp @@ -43,42 +43,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /// @file DeboneProcess.cpp /** Implementation of the DeboneProcess post processing step */ - - // internal headers of the post-processing framework #include "ProcessHelper.h" #include "DeboneProcess.h" #include - using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -DeboneProcess::DeboneProcess() -{ - mNumBones = 0; - mNumBonesCanDoWithout = 0; - - mThreshold = AI_DEBONE_THRESHOLD; - mAllOrNone = false; -} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -DeboneProcess::~DeboneProcess() = default; +DeboneProcess::DeboneProcess() : mNumBones(0), mNumBonesCanDoWithout(0), mThreshold(AI_DEBONE_THRESHOLD), mAllOrNone(false) {} // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool DeboneProcess::IsActive( unsigned int pFlags) const -{ +bool DeboneProcess::IsActive( unsigned int pFlags) const { return (pFlags & aiProcess_Debone) != 0; } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void DeboneProcess::SetupProperties(const Importer* pImp) -{ +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; mThreshold = pImp->GetPropertyFloat(AI_CONFIG_PP_DB_THRESHOLD,AI_DEBONE_THRESHOLD); @@ -86,8 +70,7 @@ void DeboneProcess::SetupProperties(const Importer* pImp) // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void DeboneProcess::Execute( aiScene* pScene) -{ +void DeboneProcess::Execute( aiScene* pScene) { ASSIMP_LOG_DEBUG("DeboneProcess begin"); if(!pScene->mNumMeshes) { @@ -117,10 +100,8 @@ void DeboneProcess::Execute( aiScene* pScene) // build a new array of meshes for the scene std::vector meshes; - for(unsigned int a=0;amNumMeshes;a++) - { + for (unsigned int a=0;amNumMeshes; ++a) { aiMesh* srcMesh = pScene->mMeshes[a]; - std::vector > newMeshes; if(splitList[a]) { @@ -150,8 +131,7 @@ void DeboneProcess::Execute( aiScene* pScene) // and destroy the source mesh. It should be completely contained inside the new submeshes delete srcMesh; - } - else { + } else { // Mesh is kept unchanged - store it's new place in the mesh array mSubMeshIndices[a].emplace_back(static_cast(meshes.size()), (aiNode *)nullptr); meshes.push_back(srcMesh); @@ -173,8 +153,7 @@ void DeboneProcess::Execute( aiScene* pScene) // ------------------------------------------------------------------------------------------------ // Counts bones total/removable in a given mesh. -bool DeboneProcess::ConsiderMesh(const aiMesh* pMesh) -{ +bool DeboneProcess::ConsiderMesh(const aiMesh* pMesh) { if(!pMesh->HasBones()) { return false; } @@ -193,25 +172,23 @@ bool DeboneProcess::ConsiderMesh(const aiMesh* pMesh) for(unsigned int i=0;imNumBones;i++) { for(unsigned int j=0;jmBones[i]->mNumWeights;j++) { float w = pMesh->mBones[i]->mWeights[j].mWeight; - - if(w==0.0f) { + if (w == 0.0f) { continue; } unsigned int vid = pMesh->mBones[i]->mWeights[j].mVertexId; - if(w>=mThreshold) { - - if(vertexBones[vid]!=cUnowned) { - if(vertexBones[vid]==i) //double entry - { + if (w >= mThreshold) { + if (vertexBones[vid] != cUnowned) { + //double entry + if(vertexBones[vid]==i) { ASSIMP_LOG_WARN("Encountered double entry in bone weights"); - } - else //TODO: track attraction in order to break tie - { + } else { + //TODO: track attraction in order to break tie vertexBones[vid] = cCoowned; } - } - else vertexBones[vid] = i; + } else { + vertexBones[vid] = i; + } } if(!isBoneNecessary[i]) { @@ -227,13 +204,16 @@ bool DeboneProcess::ConsiderMesh(const aiMesh* pMesh) if(isInterstitialRequired) { for(unsigned int i=0;imNumFaces;i++) { unsigned int v = vertexBones[pMesh->mFaces[i].mIndices[0]]; - - for(unsigned int j=1;jmFaces[i].mNumIndices;j++) { + for (unsigned int j=1;jmFaces[i].mNumIndices;j++) { unsigned int w = vertexBones[pMesh->mFaces[i].mIndices[j]]; - if(v!=w) { - if(vmNumBones) isBoneNecessary[v] = true; - if(wmNumBones) isBoneNecessary[w] = true; + if (v != w) { + if(vmNumBones) { + isBoneNecessary[v] = true; + } + if (wmNumBones) { + isBoneNecessary[w] = true; + } } } } @@ -252,8 +232,7 @@ bool DeboneProcess::ConsiderMesh(const aiMesh* pMesh) // ------------------------------------------------------------------------------------------------ // Splits the given mesh by bone count. -void DeboneProcess::SplitMesh( const aiMesh* pMesh, std::vector< std::pair< aiMesh*,const aiBone* > >& poNewMeshes) const -{ +void DeboneProcess::SplitMesh( const aiMesh* pMesh, std::vector< std::pair< aiMesh*,const aiBone* > >& poNewMeshes) const { // same deal here as ConsiderMesh basically std::vector isBoneNecessary(pMesh->mNumBones,false); @@ -371,8 +350,7 @@ void DeboneProcess::SplitMesh( const aiMesh* pMesh, std::vector< std::pair< aiMe // ------------------------------------------------------------------------------------------------ // Recursively updates the node's mesh list to account for the changed mesh list -void DeboneProcess::UpdateNode(aiNode* pNode) const -{ +void DeboneProcess::UpdateNode(aiNode* pNode) const { // rebuild the node's mesh index list std::vector newMeshList; @@ -430,8 +408,7 @@ void DeboneProcess::UpdateNode(aiNode* pNode) const // ------------------------------------------------------------------------------------------------ // Apply the node transformation to a mesh -void DeboneProcess::ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat)const -{ +void DeboneProcess::ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat)const { // Check whether we need to transform the coordinates at all if (!mat.IsIdentity()) { diff --git a/code/PostProcessing/DeboneProcess.h b/code/PostProcessing/DeboneProcess.h index cb072b7eb..080bc30d1 100644 --- a/code/PostProcessing/DeboneProcess.h +++ b/code/PostProcessing/DeboneProcess.h @@ -70,7 +70,7 @@ namespace Assimp { class DeboneProcess : public BaseProcess { public: DeboneProcess(); - ~DeboneProcess(); + ~DeboneProcess() override = default; // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag. diff --git a/code/PostProcessing/DropFaceNormalsProcess.cpp b/code/PostProcessing/DropFaceNormalsProcess.cpp index f85daa588..223482374 100644 --- a/code/PostProcessing/DropFaceNormalsProcess.cpp +++ b/code/PostProcessing/DropFaceNormalsProcess.cpp @@ -54,14 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; -// ------------------------------------------------------------------------------------------------ -// Constructor to be privately used by Importer -DropFaceNormalsProcess::DropFaceNormalsProcess() = default; - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -DropFaceNormalsProcess::~DropFaceNormalsProcess() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool DropFaceNormalsProcess::IsActive( unsigned int pFlags) const { diff --git a/code/PostProcessing/DropFaceNormalsProcess.h b/code/PostProcessing/DropFaceNormalsProcess.h index 50abdc727..719c98dc7 100644 --- a/code/PostProcessing/DropFaceNormalsProcess.h +++ b/code/PostProcessing/DropFaceNormalsProcess.h @@ -55,8 +55,8 @@ namespace Assimp { */ class ASSIMP_API_WINONLY DropFaceNormalsProcess : public BaseProcess { public: - DropFaceNormalsProcess(); - ~DropFaceNormalsProcess(); + DropFaceNormalsProcess() = default; + ~DropFaceNormalsProcess() override = 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 dc7e54ac1..d5d2ef872 100644 --- a/code/PostProcessing/EmbedTexturesProcess.cpp +++ b/code/PostProcessing/EmbedTexturesProcess.cpp @@ -49,10 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; -EmbedTexturesProcess::EmbedTexturesProcess() = default; - -EmbedTexturesProcess::~EmbedTexturesProcess() = default; - bool EmbedTexturesProcess::IsActive(unsigned int pFlags) const { return (pFlags & aiProcess_EmbedTextures) != 0; } diff --git a/code/PostProcessing/EmbedTexturesProcess.h b/code/PostProcessing/EmbedTexturesProcess.h index c3e63612c..e09fa0896 100644 --- a/code/PostProcessing/EmbedTexturesProcess.h +++ b/code/PostProcessing/EmbedTexturesProcess.h @@ -62,10 +62,10 @@ namespace Assimp { class ASSIMP_API EmbedTexturesProcess : public BaseProcess { public: /// The default class constructor. - EmbedTexturesProcess(); + EmbedTexturesProcess() = default; /// The class destructor. - virtual ~EmbedTexturesProcess(); + ~EmbedTexturesProcess() override = default; /// Overwritten, @see BaseProcess virtual bool IsActive(unsigned int pFlags) const; diff --git a/code/PostProcessing/FindDegenerates.h b/code/PostProcessing/FindDegenerates.h index 55a9dd981..d1eb81615 100644 --- a/code/PostProcessing/FindDegenerates.h +++ b/code/PostProcessing/FindDegenerates.h @@ -59,7 +59,7 @@ namespace Assimp { class ASSIMP_API FindDegeneratesProcess : public BaseProcess { public: FindDegeneratesProcess(); - ~FindDegeneratesProcess() = default; + ~FindDegeneratesProcess() override = default; // ------------------------------------------------------------------- // Check whether step is active diff --git a/code/PostProcessing/FindInstancesProcess.h b/code/PostProcessing/FindInstancesProcess.h index d1daeb1f4..b6c61527a 100644 --- a/code/PostProcessing/FindInstancesProcess.h +++ b/code/PostProcessing/FindInstancesProcess.h @@ -110,7 +110,7 @@ inline bool CompareArrays(const aiColor4D* first, const aiColor4D* second, class FindInstancesProcess : public BaseProcess { public: FindInstancesProcess(); - ~FindInstancesProcess() = default; + ~FindInstancesProcess() override = default; // ------------------------------------------------------------------- // Check whether step is active in given flags combination diff --git a/code/PostProcessing/FindInvalidDataProcess.h b/code/PostProcessing/FindInvalidDataProcess.h index c5c7067a6..14746864f 100644 --- a/code/PostProcessing/FindInvalidDataProcess.h +++ b/code/PostProcessing/FindInvalidDataProcess.h @@ -64,35 +64,37 @@ namespace Assimp { * which have zero normal vectors. */ class ASSIMP_API FindInvalidDataProcess : public BaseProcess { public: + // ------------------------------------------------------------------- + /// The default class constructor / destructor. FindInvalidDataProcess(); - ~FindInvalidDataProcess() = default; + ~FindInvalidDataProcess() override = default; // ------------------------------------------------------------------- - // + /// Returns active state. bool IsActive(unsigned int pFlags) const; // ------------------------------------------------------------------- - // Setup import settings + /// Setup import settings void SetupProperties(const Importer *pImp); // ------------------------------------------------------------------- - // Run the step + /// Run the step void Execute(aiScene *pScene); // ------------------------------------------------------------------- - /** Executes the post-processing step on the given mesh - * @param pMesh The mesh to process. - * @return 0 - nothing, 1 - removed sth, 2 - please delete me */ + /// Executes the post-processing step on the given mesh + /// @param pMesh The mesh to process. + /// @return 0 - nothing, 1 - removed sth, 2 - please delete me */ int ProcessMesh(aiMesh *pMesh); // ------------------------------------------------------------------- - /** Executes the post-processing step on the given animation - * @param anim The animation to process. */ + /// Executes the post-processing step on the given animation + /// @param anim The animation to process. */ void ProcessAnimation(aiAnimation *anim); // ------------------------------------------------------------------- - /** Executes the post-processing step on the given anim channel - * @param anim The animation channel to process.*/ + /// Executes the post-processing step on the given anim channel + /// @param anim The animation channel to process.*/ void ProcessAnimationChannel(aiNodeAnim *anim); private: diff --git a/code/PostProcessing/FixNormalsStep.h b/code/PostProcessing/FixNormalsStep.h index ec546c987..e5f5c8a1f 100644 --- a/code/PostProcessing/FixNormalsStep.h +++ b/code/PostProcessing/FixNormalsStep.h @@ -58,8 +58,10 @@ namespace Assimp { */ class FixInfacingNormalsProcess : public BaseProcess { public: + // ------------------------------------------------------------------- + /// The default class constructor / destructor. FixInfacingNormalsProcess() = default; - ~FixInfacingNormalsProcess() = default; + ~FixInfacingNormalsProcess() override = default; // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/GenBoundingBoxesProcess.h b/code/PostProcessing/GenBoundingBoxesProcess.h index a880a0638..0cf8514f4 100644 --- a/code/PostProcessing/GenBoundingBoxesProcess.h +++ b/code/PostProcessing/GenBoundingBoxesProcess.h @@ -60,13 +60,17 @@ namespace Assimp { */ class ASSIMP_API GenBoundingBoxesProcess : public BaseProcess { public: - /// The class constructor. + // ------------------------------------------------------------------- + /// The default class constructor / destructor. GenBoundingBoxesProcess() = default; - /// The class destructor. - ~GenBoundingBoxesProcess() = default; - /// Will return true, if aiProcess_GenBoundingBoxes is defined. + ~GenBoundingBoxesProcess() override = default; + + // ------------------------------------------------------------------- + /// @brief Will return true, if aiProcess_GenBoundingBoxes is defined. bool IsActive(unsigned int pFlags) const override; - /// The execution callback. + + // ------------------------------------------------------------------- + /// @brief The execution callback. void Execute(aiScene* pScene) override; }; diff --git a/code/PostProcessing/GenFaceNormalsProcess.h b/code/PostProcessing/GenFaceNormalsProcess.h index 68e3fee0b..b1babca28 100644 --- a/code/PostProcessing/GenFaceNormalsProcess.h +++ b/code/PostProcessing/GenFaceNormalsProcess.h @@ -55,8 +55,10 @@ namespace Assimp { */ class ASSIMP_API_WINONLY GenFaceNormalsProcess : public BaseProcess { public: + // ------------------------------------------------------------------- + /// The default class constructor / destructor. GenFaceNormalsProcess() = default; - ~GenFaceNormalsProcess() = default; + ~GenFaceNormalsProcess() override = default; // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/GenVertexNormalsProcess.h b/code/PostProcessing/GenVertexNormalsProcess.h index 3a15bf4a8..3999fc3e9 100644 --- a/code/PostProcessing/GenVertexNormalsProcess.h +++ b/code/PostProcessing/GenVertexNormalsProcess.h @@ -60,8 +60,10 @@ namespace Assimp { */ class ASSIMP_API GenVertexNormalsProcess : public BaseProcess { public: + // ------------------------------------------------------------------- + /// The default class constructor / destructor. GenVertexNormalsProcess(); - ~GenVertexNormalsProcess() = default; + ~GenVertexNormalsProcess() override = default; // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag. diff --git a/code/PostProcessing/ImproveCacheLocality.cpp b/code/PostProcessing/ImproveCacheLocality.cpp index 197856171..9336d6b17 100644 --- a/code/PostProcessing/ImproveCacheLocality.cpp +++ b/code/PostProcessing/ImproveCacheLocality.cpp @@ -68,10 +68,6 @@ ImproveCacheLocalityProcess::ImproveCacheLocalityProcess() // empty } -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -ImproveCacheLocalityProcess::~ImproveCacheLocalityProcess() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool ImproveCacheLocalityProcess::IsActive( unsigned int pFlags) const { diff --git a/code/PostProcessing/ImproveCacheLocality.h b/code/PostProcessing/ImproveCacheLocality.h index b2074a17c..34a3883da 100644 --- a/code/PostProcessing/ImproveCacheLocality.h +++ b/code/PostProcessing/ImproveCacheLocality.h @@ -51,8 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. struct aiMesh; -namespace Assimp -{ +namespace Assimp { // --------------------------------------------------------------------------- /** The ImproveCacheLocalityProcess reorders all faces for improved vertex @@ -61,14 +60,12 @@ namespace Assimp * * @note This step expects triagulated input data. */ -class ImproveCacheLocalityProcess : public BaseProcess -{ +class ImproveCacheLocalityProcess : public BaseProcess { public: - + // ------------------------------------------------------------------- + /// The default class constructor / destructor. ImproveCacheLocalityProcess(); - ~ImproveCacheLocalityProcess(); - -public: + ~ImproveCacheLocalityProcess() override = default; // ------------------------------------------------------------------- // Check whether the pp step is active diff --git a/code/PostProcessing/JoinVerticesProcess.h b/code/PostProcessing/JoinVerticesProcess.h index b05d74ef5..de8cea691 100644 --- a/code/PostProcessing/JoinVerticesProcess.h +++ b/code/PostProcessing/JoinVerticesProcess.h @@ -51,8 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. struct aiMesh; -namespace Assimp -{ +namespace Assimp { // --------------------------------------------------------------------------- /** The JoinVerticesProcess unites identical vertices in all imported meshes. @@ -65,12 +64,9 @@ namespace Assimp class ASSIMP_API JoinVerticesProcess : public BaseProcess { public: // ------------------------------------------------------------------- - /// @brief The default class constructor. - JoinVerticesProcess() = default; - - // ------------------------------------------------------------------- - /// @brief The default class destructor. - ~JoinVerticesProcess() = default; + /// The default class constructor / destructor. + JoinVerticesProcess() = default; + ~JoinVerticesProcess() override = 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 51fb43dfc..7047ec0f1 100644 --- a/code/PostProcessing/LimitBoneWeightsProcess.cpp +++ b/code/PostProcessing/LimitBoneWeightsProcess.cpp @@ -53,11 +53,9 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -LimitBoneWeightsProcess::LimitBoneWeightsProcess() : mMaxWeights(AI_LMW_MAX_WEIGHTS) {} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -LimitBoneWeightsProcess::~LimitBoneWeightsProcess() = default; +LimitBoneWeightsProcess::LimitBoneWeightsProcess() : mMaxWeights(AI_LMW_MAX_WEIGHTS) { + // empty +} // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/LimitBoneWeightsProcess.h b/code/PostProcessing/LimitBoneWeightsProcess.h index 22d286b68..855c8628a 100644 --- a/code/PostProcessing/LimitBoneWeightsProcess.h +++ b/code/PostProcessing/LimitBoneWeightsProcess.h @@ -74,8 +74,10 @@ namespace Assimp { */ class ASSIMP_API LimitBoneWeightsProcess : public BaseProcess { public: + // ------------------------------------------------------------------- + /// The default class constructor / destructor. LimitBoneWeightsProcess(); - ~LimitBoneWeightsProcess(); + ~LimitBoneWeightsProcess() override = default; // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag. diff --git a/code/PostProcessing/MakeVerboseFormat.cpp b/code/PostProcessing/MakeVerboseFormat.cpp index 0f5276cf3..1cc2fdc02 100644 --- a/code/PostProcessing/MakeVerboseFormat.cpp +++ b/code/PostProcessing/MakeVerboseFormat.cpp @@ -49,10 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; -// ------------------------------------------------------------------------------------------------ -MakeVerboseFormatProcess::MakeVerboseFormatProcess() = default; -// ------------------------------------------------------------------------------------------------ -MakeVerboseFormatProcess::~MakeVerboseFormatProcess() = default; // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. void MakeVerboseFormatProcess::Execute(aiScene *pScene) { diff --git a/code/PostProcessing/MakeVerboseFormat.h b/code/PostProcessing/MakeVerboseFormat.h index 6b81da622..b7ac10019 100644 --- a/code/PostProcessing/MakeVerboseFormat.h +++ b/code/PostProcessing/MakeVerboseFormat.h @@ -66,15 +66,12 @@ namespace Assimp { * The step has been added because it was required by the viewer, however * it has been moved to the main library since others might find it * useful, too. */ -class ASSIMP_API_WINONLY MakeVerboseFormatProcess : public BaseProcess -{ -public: - - - MakeVerboseFormatProcess(); - ~MakeVerboseFormatProcess(); - +class ASSIMP_API_WINONLY MakeVerboseFormatProcess : public BaseProcess { public: + // ------------------------------------------------------------------- + /// The default class constructor / destructor. + MakeVerboseFormatProcess() = default; + ~MakeVerboseFormatProcess() override = default; // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/OptimizeGraph.cpp b/code/PostProcessing/OptimizeGraph.cpp index 26b06e9b6..bcd654634 100644 --- a/code/PostProcessing/OptimizeGraph.cpp +++ b/code/PostProcessing/OptimizeGraph.cpp @@ -78,10 +78,6 @@ OptimizeGraphProcess::OptimizeGraphProcess() : // empty } -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -OptimizeGraphProcess::~OptimizeGraphProcess() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool OptimizeGraphProcess::IsActive(unsigned int pFlags) const { diff --git a/code/PostProcessing/OptimizeGraph.h b/code/PostProcessing/OptimizeGraph.h index f5caa139c..23e59e67d 100644 --- a/code/PostProcessing/OptimizeGraph.h +++ b/code/PostProcessing/OptimizeGraph.h @@ -71,8 +71,10 @@ namespace Assimp { */ class OptimizeGraphProcess : public BaseProcess { public: + // ------------------------------------------------------------------- + /// The default class constructor / destructor. OptimizeGraphProcess(); - ~OptimizeGraphProcess(); + ~OptimizeGraphProcess() override = default; // ------------------------------------------------------------------- bool IsActive( unsigned int pFlags) const override; diff --git a/code/PostProcessing/OptimizeMeshes.cpp b/code/PostProcessing/OptimizeMeshes.cpp index a8c01e2d7..0fd597808 100644 --- a/code/PostProcessing/OptimizeMeshes.cpp +++ b/code/PostProcessing/OptimizeMeshes.cpp @@ -69,10 +69,6 @@ OptimizeMeshesProcess::OptimizeMeshesProcess() // empty } -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -OptimizeMeshesProcess::~OptimizeMeshesProcess() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool OptimizeMeshesProcess::IsActive( unsigned int pFlags) const diff --git a/code/PostProcessing/OptimizeMeshes.h b/code/PostProcessing/OptimizeMeshes.h index b80f98d5d..1109a30e7 100644 --- a/code/PostProcessing/OptimizeMeshes.h +++ b/code/PostProcessing/OptimizeMeshes.h @@ -68,11 +68,10 @@ namespace Assimp { */ class OptimizeMeshesProcess : public BaseProcess { public: - /// @brief The class constructor. + // ------------------------------------------------------------------- + /// The default class constructor / destructor. OptimizeMeshesProcess(); - - /// @brief The class destructor. - ~OptimizeMeshesProcess(); + ~OptimizeMeshesProcess() override = default; /** @brief Internal utility to store additional mesh info */ diff --git a/code/PostProcessing/PretransformVertices.cpp b/code/PostProcessing/PretransformVertices.cpp index 9ac90d277..b6bb6155e 100644 --- a/code/PostProcessing/PretransformVertices.cpp +++ b/code/PostProcessing/PretransformVertices.cpp @@ -68,10 +68,6 @@ PretransformVertices::PretransformVertices() : // empty } -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -PretransformVertices::~PretransformVertices() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool PretransformVertices::IsActive(unsigned int pFlags) const { diff --git a/code/PostProcessing/PretransformVertices.h b/code/PostProcessing/PretransformVertices.h index 14e5139ec..7c2b5e99e 100644 --- a/code/PostProcessing/PretransformVertices.h +++ b/code/PostProcessing/PretransformVertices.h @@ -68,8 +68,10 @@ namespace Assimp { */ class ASSIMP_API PretransformVertices : public BaseProcess { public: + // ------------------------------------------------------------------- + /// The default class constructor / destructor. PretransformVertices(); - ~PretransformVertices(); + ~PretransformVertices() override = default; // ------------------------------------------------------------------- // Check whether step is active diff --git a/code/PostProcessing/RemoveRedundantMaterials.cpp b/code/PostProcessing/RemoveRedundantMaterials.cpp index 3c3cd59e0..dbc3c8822 100644 --- a/code/PostProcessing/RemoveRedundantMaterials.cpp +++ b/code/PostProcessing/RemoveRedundantMaterials.cpp @@ -62,10 +62,6 @@ RemoveRedundantMatsProcess::RemoveRedundantMatsProcess() // nothing to do here } -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -RemoveRedundantMatsProcess::~RemoveRedundantMatsProcess() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool RemoveRedundantMatsProcess::IsActive( unsigned int pFlags) const diff --git a/code/PostProcessing/RemoveRedundantMaterials.h b/code/PostProcessing/RemoveRedundantMaterials.h index e8c1478fd..0fbf33c1b 100644 --- a/code/PostProcessing/RemoveRedundantMaterials.h +++ b/code/PostProcessing/RemoveRedundantMaterials.h @@ -59,11 +59,10 @@ namespace Assimp { */ class ASSIMP_API RemoveRedundantMatsProcess : public BaseProcess { public: - /// The default class constructor. + // ------------------------------------------------------------------- + /// The default class constructor / destructor. RemoveRedundantMatsProcess(); - - /// The class destructor. - ~RemoveRedundantMatsProcess(); + ~RemoveRedundantMatsProcess() override = default; // ------------------------------------------------------------------- // Check whether step is active diff --git a/code/PostProcessing/RemoveVCProcess.cpp b/code/PostProcessing/RemoveVCProcess.cpp index 8bbe791f6..35047dc0a 100644 --- a/code/PostProcessing/RemoveVCProcess.cpp +++ b/code/PostProcessing/RemoveVCProcess.cpp @@ -56,10 +56,6 @@ using namespace Assimp; RemoveVCProcess::RemoveVCProcess() : configDeleteFlags(), mScene() {} -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -RemoveVCProcess::~RemoveVCProcess() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool RemoveVCProcess::IsActive(unsigned int pFlags) const { diff --git a/code/PostProcessing/RemoveVCProcess.h b/code/PostProcessing/RemoveVCProcess.h index cf1086882..dfd9b59ff 100644 --- a/code/PostProcessing/RemoveVCProcess.h +++ b/code/PostProcessing/RemoveVCProcess.h @@ -58,11 +58,10 @@ namespace Assimp { */ class ASSIMP_API RemoveVCProcess : public BaseProcess { public: - /// The default class constructor. + // ------------------------------------------------------------------- + /// The default class constructor / destructor. RemoveVCProcess(); - - /// The class destructor. - ~RemoveVCProcess(); + ~RemoveVCProcess() override = 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 34f68539a..665f28a7e 100644 --- a/code/PostProcessing/ScaleProcess.cpp +++ b/code/PostProcessing/ScaleProcess.cpp @@ -47,25 +47,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { -ScaleProcess::ScaleProcess() -: BaseProcess() -, mScale( AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT ) { +// ------------------------------------------------------------------------------------------------ +ScaleProcess::ScaleProcess() : BaseProcess(), mScale( AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT ) { + // empty } -ScaleProcess::~ScaleProcess() = default; - +// ------------------------------------------------------------------------------------------------ void ScaleProcess::setScale( ai_real scale ) { mScale = scale; } +// ------------------------------------------------------------------------------------------------ ai_real ScaleProcess::getScale() const { return mScale; } +// ------------------------------------------------------------------------------------------------ bool ScaleProcess::IsActive( unsigned int pFlags ) const { return ( pFlags & aiProcess_GlobalScale ) != 0; } +// ------------------------------------------------------------------------------------------------ void ScaleProcess::SetupProperties( const Importer* pImp ) { // User scaling mScale = pImp->GetPropertyFloat( AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY, 1.0f ); @@ -78,6 +80,7 @@ void ScaleProcess::SetupProperties( const Importer* pImp ) { mScale *= importerScale; } +// ------------------------------------------------------------------------------------------------ void ScaleProcess::Execute( aiScene* pScene ) { if(mScale == 1.0f) { return; // nothing to scale @@ -96,37 +99,30 @@ void ScaleProcess::Execute( aiScene* pScene ) { } // Process animations and update position transform to new unit system - for( unsigned int animationID = 0; animationID < pScene->mNumAnimations; animationID++ ) - { + for( unsigned int animationID = 0; animationID < pScene->mNumAnimations; animationID++ ) { aiAnimation* animation = pScene->mAnimations[animationID]; - for( unsigned int animationChannel = 0; animationChannel < animation->mNumChannels; animationChannel++) - { + for( unsigned int animationChannel = 0; animationChannel < animation->mNumChannels; animationChannel++) { aiNodeAnim* anim = animation->mChannels[animationChannel]; - for( unsigned int posKey = 0; posKey < anim->mNumPositionKeys; posKey++) - { + for( unsigned int posKey = 0; posKey < anim->mNumPositionKeys; posKey++) { aiVectorKey& vectorKey = anim->mPositionKeys[posKey]; vectorKey.mValue *= mScale; } } } - for( unsigned int meshID = 0; meshID < pScene->mNumMeshes; meshID++) - { + for( unsigned int meshID = 0; meshID < pScene->mNumMeshes; meshID++) { aiMesh *mesh = pScene->mMeshes[meshID]; // Reconstruct mesh vertices to the new unit system - for( unsigned int vertexID = 0; vertexID < mesh->mNumVertices; vertexID++) - { + for( unsigned int vertexID = 0; vertexID < mesh->mNumVertices; vertexID++) { aiVector3D& vertex = mesh->mVertices[vertexID]; vertex *= mScale; } - // bone placement / scaling - for( unsigned int boneID = 0; boneID < mesh->mNumBones; boneID++) - { + for( unsigned int boneID = 0; boneID < mesh->mNumBones; boneID++) { // Reconstruct matrix by transform rather than by scale // This prevent scale values being changed which can // be meaningful in some cases @@ -152,12 +148,10 @@ void ScaleProcess::Execute( aiScene* pScene ) { // animation mesh processing // convert by position rather than scale. - for( unsigned int animMeshID = 0; animMeshID < mesh->mNumAnimMeshes; animMeshID++) - { + for( unsigned int animMeshID = 0; animMeshID < mesh->mNumAnimMeshes; animMeshID++) { aiAnimMesh * animMesh = mesh->mAnimMeshes[animMeshID]; - for( unsigned int vertexID = 0; vertexID < animMesh->mNumVertices; vertexID++) - { + for( unsigned int vertexID = 0; vertexID < animMesh->mNumVertices; vertexID++) { aiVector3D& vertex = animMesh->mVertices[vertexID]; vertex *= mScale; } @@ -167,16 +161,17 @@ void ScaleProcess::Execute( aiScene* pScene ) { traverseNodes( pScene->mRootNode ); } +// ------------------------------------------------------------------------------------------------ void ScaleProcess::traverseNodes( aiNode *node, unsigned int nested_node_id ) { applyScaling( node ); - for( size_t i = 0; i < node->mNumChildren; i++) - { + for( size_t i = 0; i < node->mNumChildren; i++) { // recurse into the tree until we are done! traverseNodes( node->mChildren[i], nested_node_id+1 ); } } +// ------------------------------------------------------------------------------------------------ void ScaleProcess::applyScaling( aiNode *currentNode ) { if ( nullptr != currentNode ) { // Reconstruct matrix by transform rather than by scale diff --git a/code/PostProcessing/ScaleProcess.h b/code/PostProcessing/ScaleProcess.h index b6eb75de7..4d706bfc3 100644 --- a/code/PostProcessing/ScaleProcess.h +++ b/code/PostProcessing/ScaleProcess.h @@ -62,11 +62,10 @@ namespace Assimp { */ class ASSIMP_API ScaleProcess : public BaseProcess { public: - /// The default class constructor. + // ------------------------------------------------------------------- + /// The default class constructor / destructor. ScaleProcess(); - - /// The class destructor. - virtual ~ScaleProcess(); + ~ScaleProcess() override = default; /// Will set the scale manually. void setScale( ai_real scale ); diff --git a/code/PostProcessing/SortByPTypeProcess.cpp b/code/PostProcessing/SortByPTypeProcess.cpp index 6312fa173..1be75fc48 100644 --- a/code/PostProcessing/SortByPTypeProcess.cpp +++ b/code/PostProcessing/SortByPTypeProcess.cpp @@ -59,10 +59,6 @@ SortByPTypeProcess::SortByPTypeProcess() : // empty } -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -SortByPTypeProcess::~SortByPTypeProcess() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool SortByPTypeProcess::IsActive(unsigned int pFlags) const { diff --git a/code/PostProcessing/SortByPTypeProcess.h b/code/PostProcessing/SortByPTypeProcess.h index e30342a86..c004e0549 100644 --- a/code/PostProcessing/SortByPTypeProcess.h +++ b/code/PostProcessing/SortByPTypeProcess.h @@ -60,8 +60,10 @@ namespace Assimp { */ class ASSIMP_API SortByPTypeProcess : public BaseProcess { public: + // ------------------------------------------------------------------- + /// The default class constructor / destructor. SortByPTypeProcess(); - ~SortByPTypeProcess(); + ~SortByPTypeProcess() override = default; // ------------------------------------------------------------------- bool IsActive( unsigned int pFlags) const; diff --git a/code/PostProcessing/SplitByBoneCountProcess.cpp b/code/PostProcessing/SplitByBoneCountProcess.cpp index a501d3bd6..5324160d4 100644 --- a/code/PostProcessing/SplitByBoneCountProcess.cpp +++ b/code/PostProcessing/SplitByBoneCountProcess.cpp @@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ - /// @file SplitByBoneCountProcess.cpp /// Implementation of the SplitByBoneCount postprocessing step @@ -59,47 +58,36 @@ using namespace Assimp::Formatter; // ------------------------------------------------------------------------------------------------ // Constructor -SplitByBoneCountProcess::SplitByBoneCountProcess() -{ - // set default, might be overridden by importer config - mMaxBoneCount = AI_SBBC_DEFAULT_MAX_BONES; +SplitByBoneCountProcess::SplitByBoneCountProcess() : mMaxBoneCount(AI_SBBC_DEFAULT_MAX_BONES) { + // empty } -// ------------------------------------------------------------------------------------------------ -// Destructor -SplitByBoneCountProcess::~SplitByBoneCountProcess() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag. -bool SplitByBoneCountProcess::IsActive( unsigned int pFlags) const -{ +bool SplitByBoneCountProcess::IsActive( unsigned int pFlags) const { return !!(pFlags & aiProcess_SplitByBoneCount); } // ------------------------------------------------------------------------------------------------ // Updates internal properties -void SplitByBoneCountProcess::SetupProperties(const Importer* pImp) -{ +void SplitByBoneCountProcess::SetupProperties(const Importer* pImp) { mMaxBoneCount = pImp->GetPropertyInteger(AI_CONFIG_PP_SBBC_MAX_BONES,AI_SBBC_DEFAULT_MAX_BONES); } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void SplitByBoneCountProcess::Execute( aiScene* pScene) -{ +void SplitByBoneCountProcess::Execute( aiScene* pScene) { ASSIMP_LOG_DEBUG("SplitByBoneCountProcess begin"); // early out bool isNecessary = false; for( unsigned int a = 0; a < pScene->mNumMeshes; ++a) - if( pScene->mMeshes[a]->mNumBones > mMaxBoneCount ) - { + if( pScene->mMeshes[a]->mNumBones > mMaxBoneCount ) { isNecessary = true; break; } - if( !isNecessary ) - { + if( !isNecessary ) { ASSIMP_LOG_DEBUG("SplitByBoneCountProcess early-out: no meshes with more than ", mMaxBoneCount, " bones." ); return; } @@ -111,28 +99,23 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene) // build a new array of meshes for the scene std::vector meshes; - for( unsigned int a = 0; a < pScene->mNumMeshes; ++a) - { + for( unsigned int a = 0; a < pScene->mNumMeshes; ++a) { aiMesh* srcMesh = pScene->mMeshes[a]; std::vector newMeshes; SplitMesh( pScene->mMeshes[a], newMeshes); // mesh was split - if( !newMeshes.empty() ) - { + if( !newMeshes.empty() ) { // store new meshes and indices of the new meshes - for( unsigned int b = 0; b < newMeshes.size(); ++b) - { + for( unsigned int b = 0; b < newMeshes.size(); ++b) { mSubMeshIndices[a].push_back( static_cast(meshes.size())); meshes.push_back( newMeshes[b]); } // and destroy the source mesh. It should be completely contained inside the new submeshes delete srcMesh; - } - else - { + } else { // Mesh is kept unchanged - store it's new place in the mesh array mSubMeshIndices[a].push_back( static_cast(meshes.size())); meshes.push_back( srcMesh); @@ -153,11 +136,9 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene) // ------------------------------------------------------------------------------------------------ // Splits the given mesh by bone count. -void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector& poNewMeshes) const -{ +void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector& poNewMeshes) const { // skip if not necessary - if( pMesh->mNumBones <= mMaxBoneCount ) - { + if( pMesh->mNumBones <= mMaxBoneCount ) { return; } @@ -165,27 +146,22 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector BoneWeight; std::vector< std::vector > vertexBones( pMesh->mNumVertices); - for( unsigned int a = 0; a < pMesh->mNumBones; ++a) - { + for( unsigned int a = 0; a < pMesh->mNumBones; ++a) { const aiBone* bone = pMesh->mBones[a]; - for( unsigned int b = 0; b < bone->mNumWeights; ++b) - { - if (bone->mWeights[b].mWeight > 0.0f) - { - int vertexId = bone->mWeights[b].mVertexId; - 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!"); + for( unsigned int b = 0; b < bone->mNumWeights; ++b) { + if (bone->mWeights[b].mWeight > 0.0f) { + int vertexId = bone->mWeights[b].mVertexId; + 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!"); + } } - } } } unsigned int numFacesHandled = 0; std::vector isFaceHandled( pMesh->mNumFaces, false); - while( numFacesHandled < pMesh->mNumFaces ) - { + while( numFacesHandled < pMesh->mNumFaces ) { // which bones are used in the current submesh unsigned int numBones = 0; std::vector isBoneUsed( pMesh->mNumBones, false); @@ -196,11 +172,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumFaces; ++a) - { + for( unsigned int a = 0; a < pMesh->mNumFaces; ++a) { // skip if the face is already stored in a submesh - if( isFaceHandled[a] ) - { + if( isFaceHandled[a] ) { continue; } // a small local set of new bones for the current face. State of all used bones for that face @@ -209,33 +183,27 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormFaces[a]; // check every vertex if its bones would still fit into the current submesh - for( unsigned int b = 0; b < face.mNumIndices; ++b ) - { - const std::vector& vb = vertexBones[face.mIndices[b]]; - for( unsigned int c = 0; c < vb.size(); ++c) - { - unsigned int boneIndex = vb[c].first; - if( !isBoneUsed[boneIndex] ) - { - newBonesAtCurrentFace.insert(boneIndex); + for( unsigned int b = 0; b < face.mNumIndices; ++b ) { + const std::vector& vb = vertexBones[face.mIndices[b]]; + for( unsigned int c = 0; c < vb.size(); ++c) { + unsigned int boneIndex = vb[c].first; + if( !isBoneUsed[boneIndex] ) { + newBonesAtCurrentFace.insert(boneIndex); + } } - } } // leave out the face if the new bones required for this face don't fit the bone count limit anymore - if( numBones + newBonesAtCurrentFace.size() > mMaxBoneCount ) - { + if( numBones + newBonesAtCurrentFace.size() > mMaxBoneCount ) { continue; } // mark all new bones as necessary - for (std::set::iterator it = newBonesAtCurrentFace.begin(); it != newBonesAtCurrentFace.end(); ++it) - { - if (!isBoneUsed[*it]) - { - isBoneUsed[*it] = true; - numBones++; - } + for (std::set::iterator it = newBonesAtCurrentFace.begin(); it != newBonesAtCurrentFace.end(); ++it) { + if (!isBoneUsed[*it]) { + isBoneUsed[*it] = true; + numBones++; + } } // store the face index and the vertex count @@ -261,27 +229,21 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumVertices = numSubMeshVertices; newMesh->mNumFaces = static_cast(subMeshFaces.size()); newMesh->mVertices = new aiVector3D[newMesh->mNumVertices]; - if( pMesh->HasNormals() ) - { + if( pMesh->HasNormals() ) { newMesh->mNormals = new aiVector3D[newMesh->mNumVertices]; } - if( pMesh->HasTangentsAndBitangents() ) - { + if( pMesh->HasTangentsAndBitangents() ) { newMesh->mTangents = new aiVector3D[newMesh->mNumVertices]; newMesh->mBitangents = new aiVector3D[newMesh->mNumVertices]; } - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a ) - { - if( pMesh->HasTextureCoords( a) ) - { + for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a ) { + if( pMesh->HasTextureCoords( a) ) { newMesh->mTextureCoords[a] = new aiVector3D[newMesh->mNumVertices]; } newMesh->mNumUVComponents[a] = pMesh->mNumUVComponents[a]; } - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a ) - { - if( pMesh->HasVertexColors( a) ) - { + for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a ) { + if( pMesh->HasVertexColors( a) ) { newMesh->mColors[a] = new aiColor4D[newMesh->mNumVertices]; } } @@ -290,41 +252,33 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormFaces = new aiFace[subMeshFaces.size()]; unsigned int nvi = 0; // next vertex index std::vector previousVertexIndices( numSubMeshVertices, std::numeric_limits::max()); // per new vertex: its index in the source mesh - for( unsigned int a = 0; a < subMeshFaces.size(); ++a ) - { + for( unsigned int a = 0; a < subMeshFaces.size(); ++a ) { const aiFace& srcFace = pMesh->mFaces[subMeshFaces[a]]; aiFace& dstFace = newMesh->mFaces[a]; dstFace.mNumIndices = srcFace.mNumIndices; dstFace.mIndices = new unsigned int[dstFace.mNumIndices]; // accumulate linearly all the vertices of the source face - for( unsigned int b = 0; b < dstFace.mNumIndices; ++b ) - { + for( unsigned int b = 0; b < dstFace.mNumIndices; ++b ) { unsigned int srcIndex = srcFace.mIndices[b]; dstFace.mIndices[b] = nvi; previousVertexIndices[nvi] = srcIndex; newMesh->mVertices[nvi] = pMesh->mVertices[srcIndex]; - if( pMesh->HasNormals() ) - { + if( pMesh->HasNormals() ) { newMesh->mNormals[nvi] = pMesh->mNormals[srcIndex]; } - if( pMesh->HasTangentsAndBitangents() ) - { + if( pMesh->HasTangentsAndBitangents() ) { newMesh->mTangents[nvi] = pMesh->mTangents[srcIndex]; newMesh->mBitangents[nvi] = pMesh->mBitangents[srcIndex]; } - for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c ) - { - if( pMesh->HasTextureCoords( c) ) - { + for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c ) { + if( pMesh->HasTextureCoords( c) ) { newMesh->mTextureCoords[c][nvi] = pMesh->mTextureCoords[c][srcIndex]; } } - for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c ) - { - if( pMesh->HasVertexColors( c) ) - { + for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c ) { + if( pMesh->HasVertexColors( c) ) { newMesh->mColors[c][nvi] = pMesh->mColors[c][srcIndex]; } } @@ -340,10 +294,8 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormBones = new aiBone*[numBones]; std::vector mappedBoneIndex( pMesh->mNumBones, std::numeric_limits::max()); - for( unsigned int a = 0; a < pMesh->mNumBones; ++a ) - { - if( !isBoneUsed[a] ) - { + for( unsigned int a = 0; a < pMesh->mNumBones; ++a ) { + if( !isBoneUsed[a] ) { continue; } @@ -360,24 +312,20 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumBones == numBones ); // iterate over all new vertices and count which bones affected its old vertex in the source mesh - for( unsigned int a = 0; a < numSubMeshVertices; ++a ) - { + for( unsigned int a = 0; a < numSubMeshVertices; ++a ) { unsigned int oldIndex = previousVertexIndices[a]; const std::vector& bonesOnThisVertex = vertexBones[oldIndex]; - for( unsigned int b = 0; b < bonesOnThisVertex.size(); ++b ) - { + for( unsigned int b = 0; b < bonesOnThisVertex.size(); ++b ) { unsigned int newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ]; - if( newBoneIndex != std::numeric_limits::max() ) - { + if( newBoneIndex != std::numeric_limits::max() ) { newMesh->mBones[newBoneIndex]->mNumWeights++; } } } // allocate all bone weight arrays accordingly - for( unsigned int a = 0; a < newMesh->mNumBones; ++a ) - { + for( unsigned int a = 0; a < newMesh->mNumBones; ++a ) { aiBone* bone = newMesh->mBones[a]; ai_assert( bone->mNumWeights > 0 ); bone->mWeights = new aiVertexWeight[bone->mNumWeights]; @@ -385,16 +333,14 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector& bonesOnThisVertex = vertexBones[previousIndex]; // all of the bones affecting it should be present in the new submesh, or else // the face it comprises shouldn't be present - for( unsigned int b = 0; b < bonesOnThisVertex.size(); ++b) - { + for( unsigned int b = 0; b < bonesOnThisVertex.size(); ++b) { unsigned int newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ]; ai_assert( newBoneIndex != std::numeric_limits::max() ); aiVertexWeight* dstWeight = newMesh->mBones[newBoneIndex]->mWeights + newMesh->mBones[newBoneIndex]->mNumWeights; @@ -450,14 +396,11 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumMeshes > 0 ) - { + if( pNode->mNumMeshes == 0 ) { std::vector newMeshList; - for( unsigned int a = 0; a < pNode->mNumMeshes; ++a) - { + for( unsigned int a = 0; a < pNode->mNumMeshes; ++a) { unsigned int srcIndex = pNode->mMeshes[a]; const std::vector& replaceMeshes = mSubMeshIndices[srcIndex]; newMeshList.insert( newMeshList.end(), replaceMeshes.begin(), replaceMeshes.end()); @@ -470,8 +413,7 @@ void SplitByBoneCountProcess::UpdateNode( aiNode* pNode) const } // do that also recursively for all children - for( unsigned int a = 0; a < pNode->mNumChildren; ++a ) - { + for( unsigned int a = 0; a < pNode->mNumChildren; ++a ) { UpdateNode( pNode->mChildren[a]); } } diff --git a/code/PostProcessing/SplitByBoneCountProcess.h b/code/PostProcessing/SplitByBoneCountProcess.h index 938b00c7f..e2377a995 100644 --- a/code/PostProcessing/SplitByBoneCountProcess.h +++ b/code/PostProcessing/SplitByBoneCountProcess.h @@ -51,9 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -namespace Assimp -{ - +namespace Assimp { /** Postprocessing filter to split meshes with many bones into submeshes * so that each submesh has a certain max bone count. @@ -61,33 +59,28 @@ namespace Assimp * Applied BEFORE the JoinVertices-Step occurs. * Returns NON-UNIQUE vertices, splits by bone count. */ -class SplitByBoneCountProcess : public BaseProcess -{ +class SplitByBoneCountProcess : public BaseProcess { public: - + // ------------------------------------------------------------------- + /// The default class constructor / destructor. SplitByBoneCountProcess(); - ~SplitByBoneCountProcess(); + ~SplitByBoneCountProcess() override = default; -public: - /** 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. - */ + /// @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. bool IsActive( unsigned int pFlags) const; - /** 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); protected: - /** Executes the post processing step on the given imported data. - * At the moment a process is not supposed to fail. - * @param pScene The imported data to work at. - */ + /// Executes the post processing step on the given imported data. + /// At the moment a process is not supposed to fail. + /// @param pScene The imported data to work at. void Execute( aiScene* pScene); /// Splits the given mesh by bone count. diff --git a/code/PostProcessing/SplitLargeMeshes.cpp b/code/PostProcessing/SplitLargeMeshes.cpp index 151ac4991..73e0cc5d8 100644 --- a/code/PostProcessing/SplitLargeMeshes.cpp +++ b/code/PostProcessing/SplitLargeMeshes.cpp @@ -55,9 +55,6 @@ SplitLargeMeshesProcess_Triangle::SplitLargeMeshesProcess_Triangle() { LIMIT = AI_SLM_DEFAULT_MAX_TRIANGLES; } -// ------------------------------------------------------------------------------------------------ -SplitLargeMeshesProcess_Triangle::~SplitLargeMeshesProcess_Triangle() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool SplitLargeMeshesProcess_Triangle::IsActive( unsigned int pFlags) const { @@ -329,9 +326,6 @@ SplitLargeMeshesProcess_Vertex::SplitLargeMeshesProcess_Vertex() { LIMIT = AI_SLM_DEFAULT_MAX_VERTICES; } -// ------------------------------------------------------------------------------------------------ -SplitLargeMeshesProcess_Vertex::~SplitLargeMeshesProcess_Vertex() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool SplitLargeMeshesProcess_Vertex::IsActive( unsigned int pFlags) const { diff --git a/code/PostProcessing/SplitLargeMeshes.h b/code/PostProcessing/SplitLargeMeshes.h index e5a8d4c1b..605f0477d 100644 --- a/code/PostProcessing/SplitLargeMeshes.h +++ b/code/PostProcessing/SplitLargeMeshes.h @@ -83,16 +83,15 @@ class SplitLargeMeshesProcess_Vertex; * Applied BEFORE the JoinVertices-Step occurs. * Returns NON-UNIQUE vertices, splits by triangle number. */ -class ASSIMP_API SplitLargeMeshesProcess_Triangle : public BaseProcess -{ +class ASSIMP_API SplitLargeMeshesProcess_Triangle : public BaseProcess { friend class SplitLargeMeshesProcess_Vertex; public: - + // ------------------------------------------------------------------- + /// The default class constructor / destructor. SplitLargeMeshesProcess_Triangle(); - ~SplitLargeMeshesProcess_Triangle(); + ~SplitLargeMeshesProcess_Triangle() override = default; -public: // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag. * @param pFlags The processing flags the importer was called with. A @@ -102,14 +101,12 @@ public: */ bool IsActive( unsigned int pFlags) const; - // ------------------------------------------------------------------- /** 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); - + void SetupProperties(const Importer* pImp) override; //! Set the split limit - needed for unit testing inline void SetLimit(unsigned int l) @@ -119,8 +116,6 @@ public: inline unsigned int GetLimit() const {return LIMIT;} -public: - // ------------------------------------------------------------------- /** Executes the post processing step on the given imported data. * At the moment a process is not supposed to fail. @@ -144,21 +139,17 @@ public: unsigned int LIMIT; }; - // --------------------------------------------------------------------------- /** Post-processing filter to split large meshes into sub-meshes * * Applied AFTER the JoinVertices-Step occurs. * Returns UNIQUE vertices, splits by vertex number. */ -class ASSIMP_API SplitLargeMeshesProcess_Vertex : public BaseProcess -{ +class ASSIMP_API SplitLargeMeshesProcess_Vertex : public BaseProcess { public: - SplitLargeMeshesProcess_Vertex(); - ~SplitLargeMeshesProcess_Vertex(); + ~SplitLargeMeshesProcess_Vertex() override = default; -public: // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag field. * @param pFlags The processing flags the importer was called with. A bitwise diff --git a/code/PostProcessing/TextureTransform.cpp b/code/PostProcessing/TextureTransform.cpp index efbf4d2c6..2ed17f390 100644 --- a/code/PostProcessing/TextureTransform.cpp +++ b/code/PostProcessing/TextureTransform.cpp @@ -56,33 +56,24 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -TextureTransformStep::TextureTransformStep() : - configFlags() -{ +TextureTransformStep::TextureTransformStep() : configFlags() { // nothing to do here } -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -TextureTransformStep::~TextureTransformStep() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool TextureTransformStep::IsActive( unsigned int pFlags) const -{ +bool TextureTransformStep::IsActive( unsigned int pFlags) const { return (pFlags & aiProcess_TransformUVCoords) != 0; } // ------------------------------------------------------------------------------------------------ // Setup properties -void TextureTransformStep::SetupProperties(const Importer* pImp) -{ +void TextureTransformStep::SetupProperties(const Importer* pImp) { configFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_TUV_EVALUATE,AI_UVTRAFO_ALL); } // ------------------------------------------------------------------------------------------------ -void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info) -{ +void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info) { /* This function tries to simplify the input UV transformation. * That's very important as it allows us to reduce the number * of output UV channels. The order in which the transformations @@ -90,7 +81,7 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info) */ int rounded; - char szTemp[512]; + char szTemp[512] = {}; /* Optimize the rotation angle. That's slightly difficult as * we have an inprecise floating-point number (when comparing @@ -98,12 +89,10 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info) * an epsilon of 5 degrees). If there is a rotation value, we can't * perform any further optimizations. */ - if (info.mRotation) - { + if (info.mRotation) { float out = info.mRotation; rounded = static_cast((info.mRotation / static_cast(AI_MATH_TWO_PI))); - if (rounded) - { + if (rounded) { out -= rounded * static_cast(AI_MATH_PI); ASSIMP_LOG_INFO("Texture coordinate rotation ", info.mRotation, " can be simplified to ", out); } @@ -187,8 +176,7 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info) } // ------------------------------------------------------------------------------------------------ -void UpdateUVIndex(const std::list& l, unsigned int n) -{ +void UpdateUVIndex(const std::list& l, unsigned int n) { // Don't set if == 0 && wasn't set before for (std::list::const_iterator it = l.begin();it != l.end(); ++it) { const TTUpdateInfo& info = *it; @@ -203,8 +191,7 @@ void UpdateUVIndex(const std::list& l, unsigned int n) } // ------------------------------------------------------------------------------------------------ -inline const char* MappingModeToChar(aiTextureMapMode map) -{ +inline static const char* MappingModeToChar(aiTextureMapMode map) { if (aiTextureMapMode_Wrap == map) return "-w"; @@ -215,8 +202,7 @@ inline const char* MappingModeToChar(aiTextureMapMode map) } // ------------------------------------------------------------------------------------------------ -void TextureTransformStep::Execute( aiScene* pScene) -{ +void TextureTransformStep::Execute( aiScene* pScene) { ASSIMP_LOG_DEBUG("TransformUVCoordsProcess begin"); diff --git a/code/PostProcessing/TextureTransform.h b/code/PostProcessing/TextureTransform.h index c1cccf8ef..873789f3e 100644 --- a/code/PostProcessing/TextureTransform.h +++ b/code/PostProcessing/TextureTransform.h @@ -193,14 +193,12 @@ struct STransformVecInfo : public aiUVTransform { /** Helper step to compute final UV coordinate sets if there are scalings * or rotations in the original data read from the file. */ -class TextureTransformStep : public BaseProcess -{ +class TextureTransformStep : public BaseProcess { public: - + // ------------------------------------------------------------------- + /// The default class constructor / destructor. TextureTransformStep(); - ~TextureTransformStep(); - -public: + ~TextureTransformStep() override = default; // ------------------------------------------------------------------- bool IsActive( unsigned int pFlags) const; @@ -213,8 +211,6 @@ public: protected: - - // ------------------------------------------------------------------- /** Preprocess a specific UV transformation setup * @@ -223,10 +219,9 @@ protected: void PreProcessUVTransform(STransformVecInfo& info); private: - unsigned int configFlags; }; - -} + +} // namespace Assimp #endif //! AI_TEXTURE_TRANSFORM_H_INCLUDED diff --git a/code/PostProcessing/TriangulateProcess.cpp b/code/PostProcessing/TriangulateProcess.cpp index 8ba6456b7..52cfa66bf 100644 --- a/code/PostProcessing/TriangulateProcess.cpp +++ b/code/PostProcessing/TriangulateProcess.cpp @@ -156,15 +156,6 @@ namespace { } - -// ------------------------------------------------------------------------------------------------ -// Constructor to be privately used by Importer -TriangulateProcess::TriangulateProcess() = default; - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -TriangulateProcess::~TriangulateProcess() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool TriangulateProcess::IsActive( unsigned int pFlags) const diff --git a/code/PostProcessing/TriangulateProcess.h b/code/PostProcessing/TriangulateProcess.h index ed5f4a587..fefeac61c 100644 --- a/code/PostProcessing/TriangulateProcess.h +++ b/code/PostProcessing/TriangulateProcess.h @@ -61,8 +61,10 @@ namespace Assimp { */ class ASSIMP_API TriangulateProcess : public BaseProcess { public: - TriangulateProcess(); - ~TriangulateProcess(); + // ------------------------------------------------------------------- + /// The default class constructor / destructor. + TriangulateProcess() = default; + ~TriangulateProcess() override = 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 d234e220b..cae35b895 100644 --- a/code/PostProcessing/ValidateDataStructure.cpp +++ b/code/PostProcessing/ValidateDataStructure.cpp @@ -60,12 +60,7 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -ValidateDSProcess::ValidateDSProcess() : - mScene() {} - -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -ValidateDSProcess::~ValidateDSProcess() = default; +ValidateDSProcess::ValidateDSProcess() : mScene(nullptr) {} // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. diff --git a/code/PostProcessing/ValidateDataStructure.h b/code/PostProcessing/ValidateDataStructure.h index 077a47b70..87c88669f 100644 --- a/code/PostProcessing/ValidateDataStructure.h +++ b/code/PostProcessing/ValidateDataStructure.h @@ -72,11 +72,11 @@ namespace Assimp { class ValidateDSProcess : public BaseProcess { public: - + // ------------------------------------------------------------------- + /// The default class constructor / destructor. ValidateDSProcess(); - ~ValidateDSProcess(); + ~ValidateDSProcess() override = default; -public: // ------------------------------------------------------------------- bool IsActive( unsigned int pFlags) const;