From efa6ead1a5a2eb5a9efbc308cecfe99fc6be6e46 Mon Sep 17 00:00:00 2001 From: iamAdrianIusca Date: Thu, 23 Apr 2020 22:27:55 +0300 Subject: [PATCH] fix the whitespaces --- .../LimitBoneWeightsProcess.cpp | 175 ++++++++---------- 1 file changed, 80 insertions(+), 95 deletions(-) diff --git a/code/PostProcessing/LimitBoneWeightsProcess.cpp b/code/PostProcessing/LimitBoneWeightsProcess.cpp index 05b3873fa..4c4c6b5f7 100644 --- a/code/PostProcessing/LimitBoneWeightsProcess.cpp +++ b/code/PostProcessing/LimitBoneWeightsProcess.cpp @@ -55,138 +55,123 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -LimitBoneWeightsProcess::LimitBoneWeightsProcess() -{ - mMaxWeights = AI_LMW_MAX_WEIGHTS; +LimitBoneWeightsProcess::LimitBoneWeightsProcess() { + mMaxWeights = AI_LMW_MAX_WEIGHTS; } // ------------------------------------------------------------------------------------------------ // Destructor, private as well -LimitBoneWeightsProcess::~LimitBoneWeightsProcess() -{ - // nothing to do here +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 -{ - return (pFlags & aiProcess_LimitBoneWeights) != 0; +bool LimitBoneWeightsProcess::IsActive(unsigned int pFlags) const { + return (pFlags & aiProcess_LimitBoneWeights) != 0; } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void LimitBoneWeightsProcess::Execute( aiScene* pScene) -{ +void LimitBoneWeightsProcess::Execute(aiScene *pScene) { ASSIMP_LOG_DEBUG("LimitBoneWeightsProcess begin"); for (unsigned int m = 0; m < pScene->mNumMeshes; ++m) { ProcessMesh(pScene->mMeshes[m]); } - ASSIMP_LOG_DEBUG("LimitBoneWeightsProcess end"); + ASSIMP_LOG_DEBUG("LimitBoneWeightsProcess end"); } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -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); +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); } // ------------------------------------------------------------------------------------------------ // Unites identical vertices in the given mesh -void LimitBoneWeightsProcess::ProcessMesh(aiMesh* pMesh) -{ - if (!pMesh->HasBones()) - return; +void LimitBoneWeightsProcess::ProcessMesh(aiMesh *pMesh) { + if (!pMesh->HasBones()) + return; - // collect all bone weights per vertex - typedef SmallVector VertexWeightArray; - typedef std::vector WeightsPerVertex; - WeightsPerVertex vertexWeights(pMesh->mNumVertices); - size_t maxVertexWeights = 0; + // collect all bone weights per vertex + typedef SmallVector VertexWeightArray; + typedef std::vector WeightsPerVertex; + WeightsPerVertex vertexWeights(pMesh->mNumVertices); + size_t maxVertexWeights = 0; - for (unsigned int b = 0; b < pMesh->mNumBones; ++b) - { - const aiBone* bone = pMesh->mBones[b]; - for (unsigned int w = 0; w < bone->mNumWeights; ++w) - { - const aiVertexWeight& vw = bone->mWeights[w]; - vertexWeights[vw.mVertexId].push_back(Weight(b, vw.mWeight)); - maxVertexWeights = std::max(maxVertexWeights, vertexWeights[vw.mVertexId].size()); - } - } + for (unsigned int b = 0; b < pMesh->mNumBones; ++b) { + const aiBone *bone = pMesh->mBones[b]; + for (unsigned int w = 0; w < bone->mNumWeights; ++w) { + const aiVertexWeight &vw = bone->mWeights[w]; + vertexWeights[vw.mVertexId].push_back(Weight(b, vw.mWeight)); + maxVertexWeights = std::max(maxVertexWeights, vertexWeights[vw.mVertexId].size()); + } + } - if (maxVertexWeights <= mMaxWeights) - return; + if (maxVertexWeights <= mMaxWeights) + return; - unsigned int removed = 0, old_bones = pMesh->mNumBones; + unsigned int removed = 0, old_bones = pMesh->mNumBones; - // now cut the weight count if it exceeds the maximum - for (WeightsPerVertex::iterator vit = vertexWeights.begin(); vit != vertexWeights.end(); ++vit) - { - if (vit->size() <= mMaxWeights) - continue; + // now cut the weight count if it exceeds the maximum + for (WeightsPerVertex::iterator vit = vertexWeights.begin(); vit != vertexWeights.end(); ++vit) { + if (vit->size() <= mMaxWeights) + continue; - // more than the defined maximum -> first sort by weight in descending order. That's - // why we defined the < operator in such a weird way. - std::sort(vit->begin(), vit->end()); + // more than the defined maximum -> first sort by weight in descending order. That's + // why we defined the < operator in such a weird way. + std::sort(vit->begin(), vit->end()); - // now kill everything beyond the maximum count - unsigned int m = static_cast(vit->size()); - vit->resize(mMaxWeights); - removed += static_cast(m - vit->size()); + // now kill everything beyond the maximum count + unsigned int m = static_cast(vit->size()); + vit->resize(mMaxWeights); + removed += static_cast(m - vit->size()); - // and renormalize the weights - float sum = 0.0f; - for(const Weight* it = vit->begin(); it != vit->end(); ++it) { - sum += it->mWeight; - } - if (0.0f != sum) { - const float invSum = 1.0f / sum; - for(Weight* it = vit->begin(); it != vit->end(); ++it) { - it->mWeight *= invSum; - } - } - } + // and renormalize the weights + float sum = 0.0f; + for (const Weight *it = vit->begin(); it != vit->end(); ++it) { + sum += it->mWeight; + } + if (0.0f != sum) { + const float invSum = 1.0f / sum; + for (Weight *it = vit->begin(); it != vit->end(); ++it) { + it->mWeight *= invSum; + } + } + } - // clear weight count for all bone - for (unsigned int a = 0; a < pMesh->mNumBones; ++a) - { - pMesh->mBones[a]->mNumWeights = 0; - } + // clear weight count for all bone + for (unsigned int a = 0; a < pMesh->mNumBones; ++a) { + pMesh->mBones[a]->mNumWeights = 0; + } - // rebuild the vertex weight array for all bones - for (unsigned int a = 0; a < vertexWeights.size(); ++a) - { - const VertexWeightArray& vw = vertexWeights[a]; - for (const Weight* it = vw.begin(); it != vw.end(); ++it) - { - aiBone* bone = pMesh->mBones[it->mBone]; - bone->mWeights[bone->mNumWeights++] = aiVertexWeight(a, it->mWeight); - } - } + // rebuild the vertex weight array for all bones + for (unsigned int a = 0; a < vertexWeights.size(); ++a) { + const VertexWeightArray &vw = vertexWeights[a]; + for (const Weight *it = vw.begin(); it != vw.end(); ++it) { + aiBone *bone = pMesh->mBones[it->mBone]; + bone->mWeights[bone->mNumWeights++] = aiVertexWeight(a, it->mWeight); + } + } - // remove empty bones - unsigned int writeBone = 0; + // remove empty bones + unsigned int writeBone = 0; - for (unsigned int readBone = 0; readBone< pMesh->mNumBones; ++readBone) - { - aiBone* bone = pMesh->mBones[readBone]; - if (bone->mNumWeights > 0) - { - pMesh->mBones[writeBone++] = bone; - } - else - { - delete bone; - } - } - pMesh->mNumBones = writeBone; + for (unsigned int readBone = 0; readBone < pMesh->mNumBones; ++readBone) { + aiBone *bone = pMesh->mBones[readBone]; + if (bone->mNumWeights > 0) { + pMesh->mBones[writeBone++] = bone; + } else { + delete bone; + } + } + pMesh->mNumBones = writeBone; - if (!DefaultLogger::isNullLogger()) { - ASSIMP_LOG_INFO_F("Removed ", removed, " weights. Input bones: ", old_bones, ". Output bones: ", pMesh->mNumBones); - } + if (!DefaultLogger::isNullLogger()) { + ASSIMP_LOG_INFO_F("Removed ", removed, " weights. Input bones: ", old_bones, ". Output bones: ", + pMesh->mNumBones); + } }