Просмотр исходного кода

update:
- remove dead code.
- check for a possible division by zero.

Signed-off-by: Kim Kulling <[email protected]>

Kim Kulling 11 лет назад
Родитель
Сommit
46ca36cb6f
3 измененных файлов с 9 добавлено и 6 удалено
  1. 1 2
      code/FindInstancesProcess.cpp
  2. 1 1
      code/GenVertexNormalsProcess.cpp
  3. 7 3
      code/LimitBoneWeightsProcess.cpp

+ 1 - 2
code/FindInstancesProcess.cpp

@@ -174,7 +174,6 @@ void FindInstancesProcess::Execute( aiScene* pScene)
 
 
 					// use a constant epsilon for colors and UV coordinates
 					// use a constant epsilon for colors and UV coordinates
 					static const float uvEpsilon = 10e-4f;
 					static const float uvEpsilon = 10e-4f;
-
 					{
 					{
 						unsigned int i, end = orig->GetNumUVChannels();
 						unsigned int i, end = orig->GetNumUVChannels();
 						for(i = 0; i < end; ++i) {
 						for(i = 0; i < end; ++i) {
@@ -260,7 +259,7 @@ void FindInstancesProcess::Execute( aiScene* pScene)
 					pScene->mMeshes[real++] = pScene->mMeshes[i];
 					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());
 			UpdateMeshIndices(pScene->mRootNode,remapping.get());
 
 
 			// write to log
 			// write to log

+ 1 - 1
code/GenVertexNormalsProcess.cpp

@@ -93,7 +93,7 @@ void GenVertexNormalsProcess::Execute( aiScene* pScene)
 	bool bHas = false;
 	bool bHas = false;
 	for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
 	for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
 	{
 	{
-		if(GenMeshVertexNormals( pScene->mMeshes[a],a))
+        if(GenMeshVertexNormals( pScene->mMeshes[a],a))
 			bHas = true;
 			bHas = true;
 	}
 	}
 
 

+ 7 - 3
code/LimitBoneWeightsProcess.cpp

@@ -133,8 +133,12 @@ void LimitBoneWeightsProcess::ProcessMesh( aiMesh* pMesh)
 		float sum = 0.0f;
 		float sum = 0.0f;
 		for( std::vector<Weight>::const_iterator it = vit->begin(); it != vit->end(); ++it)
 		for( std::vector<Weight>::const_iterator it = vit->begin(); it != vit->end(); ++it)
 			sum += it->mWeight;
 			sum += it->mWeight;
-		for( std::vector<Weight>::iterator it = vit->begin(); it != vit->end(); ++it)
-			it->mWeight /= sum;
+		const float invSum = 1.0f/sum;
+        if( 0.0f != sum ) {
+            for( std::vector<Weight>::iterator it = vit->begin(); it != vit->end(); ++it ) {
+                it->mWeight *= invSum;
+            }
+        }
 	}
 	}
 
 
 	if (bChanged)	{
 	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
 			// 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);
 			ai_assert( bw.size() <= bone->mNumWeights);
-			bone->mNumWeights = (unsigned int) bw.size();
+			bone->mNumWeights = static_cast<unsigned int>( bw.size() );
 			::memcpy( bone->mWeights, &bw[0], bw.size() * sizeof( aiVertexWeight));
 			::memcpy( bone->mWeights, &bw[0], bw.size() * sizeof( aiVertexWeight));
 		}
 		}