Introduce limits for vertices, faces (per mesh), face indices (per face) and weights (per bone).
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@783 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
@@ -370,14 +370,21 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh)
|
||||
ReportError("The mesh contains no vertices");
|
||||
}
|
||||
|
||||
if (pMesh->mNumVertices > AI_MAX_VERTICES) {
|
||||
ReportError("Mesh has too many vertices: %u, but the limit is %u",pMesh->mNumVertices,AI_MAX_VERTICES);
|
||||
}
|
||||
if (pMesh->mNumFaces > AI_MAX_FACES) {
|
||||
ReportError("Mesh has too many faces: %u, but the limit is %u",pMesh->mNumFaces,AI_MAX_FACES);
|
||||
}
|
||||
|
||||
// if tangents are there there must also be bitangent vectors ...
|
||||
if ((pMesh->mTangents != NULL) != (pMesh->mBitangents != NULL)) {
|
||||
ReportError("If there are tangents there must also be bitangent vectors");
|
||||
ReportError("If there are tangents, bitangent vectors must be present as well");
|
||||
}
|
||||
|
||||
// faces, too
|
||||
if (!pMesh->mNumFaces || (!pMesh->mFaces && !mScene->mFlags)) {
|
||||
ReportError("The mesh contains no faces");
|
||||
ReportError("Mesh contains no faces");
|
||||
}
|
||||
|
||||
// now check whether the face indexing layout is correct:
|
||||
@@ -387,6 +394,10 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh)
|
||||
for (unsigned int i = 0; i < pMesh->mNumFaces;++i)
|
||||
{
|
||||
aiFace& face = pMesh->mFaces[i];
|
||||
if (face.mNumIndices > AI_MAX_FACE_INDICES) {
|
||||
ReportError("Face %u has too many faces: %u, but the limit is %u",i,face.mNumIndices,AI_MAX_FACE_INDICES);
|
||||
}
|
||||
|
||||
for (unsigned int a = 0; a < face.mNumIndices;++a)
|
||||
{
|
||||
if (face.mIndices[a] >= pMesh->mNumVertices) {
|
||||
@@ -450,10 +461,10 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh)
|
||||
ReportError("aiMesh::mBones is NULL (aiMesh::mNumBones is %i)",
|
||||
pMesh->mNumBones);
|
||||
}
|
||||
float* afSum = NULL;
|
||||
boost::scoped_array<float> afSum(NULL);
|
||||
if (pMesh->mNumVertices)
|
||||
{
|
||||
afSum = new float[pMesh->mNumVertices];
|
||||
afSum.reset(new float[pMesh->mNumVertices]);
|
||||
for (unsigned int i = 0; i < pMesh->mNumVertices;++i)
|
||||
afSum[i] = 0.0f;
|
||||
}
|
||||
@@ -461,19 +472,22 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh)
|
||||
// check whether there are duplicate bone names
|
||||
for (unsigned int i = 0; i < pMesh->mNumBones;++i)
|
||||
{
|
||||
const aiBone* bone = pMesh->mBones[i];
|
||||
if (bone->mNumWeights > AI_MAX_BONE_WEIGHTS) {
|
||||
ReportError("Bone %u has too many weights: %u, but the limit is %u",i,bone->mNumWeights,AI_MAX_BONE_WEIGHTS);
|
||||
}
|
||||
|
||||
if (!pMesh->mBones[i])
|
||||
{
|
||||
delete[] afSum;
|
||||
ReportError("aiMesh::mBones[%i] is NULL (aiMesh::mNumBones is %i)",
|
||||
i,pMesh->mNumBones);
|
||||
}
|
||||
Validate(pMesh,pMesh->mBones[i],afSum);
|
||||
Validate(pMesh,pMesh->mBones[i],afSum.get());
|
||||
|
||||
for (unsigned int a = i+1; a < pMesh->mNumBones;++a)
|
||||
{
|
||||
if (pMesh->mBones[i]->mName == pMesh->mBones[a]->mName)
|
||||
{
|
||||
delete[] afSum;
|
||||
ReportError("aiMesh::mBones[%i] has the same name as "
|
||||
"aiMesh::mBones[%i]",i,a);
|
||||
}
|
||||
@@ -486,7 +500,6 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh)
|
||||
ReportWarning("aiMesh::mVertices[%i]: bone weight sum != 1.0 (sum is %f)",i,afSum[i]);
|
||||
}
|
||||
}
|
||||
delete[] afSum;
|
||||
}
|
||||
else if (pMesh->mBones)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user