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
pull/1/head
aramis_acg 2008-11-16 14:39:54 +00:00
parent dce1a8e7ce
commit 68ef00ef09
4 changed files with 15 additions and 7 deletions

View File

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

View File

@ -298,7 +298,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene)
for (VertexWeightTable::const_iterator it = tbl.begin(), end = tbl.end(); for (VertexWeightTable::const_iterator it = tbl.begin(), end = tbl.end();
it != end; ++it) 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->mNumWeights = (unsigned int)in.size();
bone->mWeights = new aiVertexWeight[bone->mNumWeights]; 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; ++real;
} }

View File

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

View File

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