From 46ca36cb6fc06e7efb5d8c5e0c0622ae1ca34bda Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 19 Jul 2014 14:45:21 +0200 Subject: [PATCH] update: - remove dead code. - check for a possible division by zero. Signed-off-by: Kim Kulling --- code/FindInstancesProcess.cpp | 3 +-- code/GenVertexNormalsProcess.cpp | 2 +- code/LimitBoneWeightsProcess.cpp | 10 +++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/code/FindInstancesProcess.cpp b/code/FindInstancesProcess.cpp index faf0541af..278f01115 100644 --- a/code/FindInstancesProcess.cpp +++ b/code/FindInstancesProcess.cpp @@ -174,7 +174,6 @@ void FindInstancesProcess::Execute( aiScene* pScene) // use a constant epsilon for colors and UV coordinates static const float uvEpsilon = 10e-4f; - { unsigned int i, end = orig->GetNumUVChannels(); for(i = 0; i < end; ++i) { @@ -260,7 +259,7 @@ void FindInstancesProcess::Execute( aiScene* pScene) pScene->mMeshes[real++] = pScene->mMeshes[i]; } - // And update the nodegraph with our nice lookup table + // And update the node graph with our nice lookup table UpdateMeshIndices(pScene->mRootNode,remapping.get()); // write to log diff --git a/code/GenVertexNormalsProcess.cpp b/code/GenVertexNormalsProcess.cpp index b278afb87..77ef20ac5 100644 --- a/code/GenVertexNormalsProcess.cpp +++ b/code/GenVertexNormalsProcess.cpp @@ -93,7 +93,7 @@ void GenVertexNormalsProcess::Execute( aiScene* pScene) bool bHas = false; for( unsigned int a = 0; a < pScene->mNumMeshes; a++) { - if(GenMeshVertexNormals( pScene->mMeshes[a],a)) + if(GenMeshVertexNormals( pScene->mMeshes[a],a)) bHas = true; } diff --git a/code/LimitBoneWeightsProcess.cpp b/code/LimitBoneWeightsProcess.cpp index 91ac122ac..32a1b47c0 100644 --- a/code/LimitBoneWeightsProcess.cpp +++ b/code/LimitBoneWeightsProcess.cpp @@ -133,8 +133,12 @@ void LimitBoneWeightsProcess::ProcessMesh( aiMesh* pMesh) float sum = 0.0f; for( std::vector::const_iterator it = vit->begin(); it != vit->end(); ++it) sum += it->mWeight; - for( std::vector::iterator it = vit->begin(); it != vit->end(); ++it) - it->mWeight /= sum; + const float invSum = 1.0f/sum; + if( 0.0f != sum ) { + for( std::vector::iterator it = vit->begin(); it != vit->end(); ++it ) { + it->mWeight *= invSum; + } + } } if (bChanged) { @@ -177,7 +181,7 @@ void LimitBoneWeightsProcess::ProcessMesh( aiMesh* pMesh) // copy the weight list. should always be less weights than before, so we don't need a new allocation ai_assert( bw.size() <= bone->mNumWeights); - bone->mNumWeights = (unsigned int) bw.size(); + bone->mNumWeights = static_cast( bw.size() ); ::memcpy( bone->mWeights, &bw[0], bw.size() * sizeof( aiVertexWeight)); }