Bladeren bron

Fixed a bug in the SortByPType-step causing some models with bones to crash
Fixed a bug in PretransformVertices - vertex colors caused an infinite loop sometimes.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@241 67173fc5-114c-0410-ac8e-9d2fd5bffc1f

aramis_acg 17 jaren geleden
bovenliggende
commit
68ef00ef09
4 gewijzigde bestanden met toevoegingen van 15 en 7 verwijderingen
  1. 1 1
      code/PretransformVertices.cpp
  2. 2 2
      code/SortByPTypeProcess.cpp
  3. 4 1
      include/aiAnim.h
  4. 8 3
      include/aiMesh.h

+ 1 - 1
code/PretransformVertices.cpp

@@ -360,7 +360,7 @@ void PretransformVertices::Execute( aiScene* pScene)
 				}
 				iFaces = 0;
 				while ((*j) & (0x1000000 << iFaces))
-					pcMesh->mColors[iFaces] = new aiColor4D[iVertices];
+					pcMesh->mColors[iFaces++] = new aiColor4D[iVertices];
 
 				// fill the mesh ...
 				unsigned int aiTemp[2] = {0,0};

+ 2 - 2
code/SortByPTypeProcess.cpp

@@ -298,7 +298,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(idx, (*it).second) );
+							tempBones[ (*it).first ].push_back( aiVertexWeight(outIdx, (*it).second) );
 						}
 					}
 
@@ -355,7 +355,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene)
 					bone->mNumWeights = (unsigned int)in.size();
 					bone->mWeights = new aiVertexWeight[bone->mNumWeights];
 
-					::memcpy(bone->mWeights,&in[0],bone->mNumWeights*sizeof(void*));
+					::memcpy(bone->mWeights,&in[0],bone->mNumWeights*sizeof(aiVertexWeight));
 
 					++real;
 				}

+ 4 - 1
include/aiAnim.h

@@ -274,11 +274,14 @@ struct aiAnimation
 
 	~aiAnimation()
 	{
-		if (mNumChannels)
+		// DO NOT REMOVE THIS ADDITIONAL CHECK
+		if (mNumChannels && mChannels)
+		{
 			for( unsigned int a = 0; a < mNumChannels; a++)
 				delete mChannels[a];
 
 		delete [] mChannels;
+		}
 	}
 #endif // __cplusplus
 };

+ 8 - 3
include/aiMesh.h

@@ -452,9 +452,14 @@ struct aiMesh
 			delete [] mTextureCoords[a];
 		for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
 			delete [] mColors[a];
-		for( unsigned int a = 0; a < mNumBones; a++)
-			delete mBones[a];
-		delete [] mBones;
+
+		// DO NOT REMOVE THIS ADDITIONAL CHECK
+		if (mNumBones && mBones)
+		{
+			for( unsigned int a = 0; a < mNumBones; a++)
+				delete mBones[a];
+			delete [] mBones;
+		}
 		delete [] mFaces;
 	}