Merge pull request #1524 from Matter-and-Form/invalid-texture-coordinates-cleaning-fix
Invalid texture coordinates cleaning fixpull/1534/head
commit
c666a05e16
|
@ -339,32 +339,37 @@ void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim)
|
||||||
int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh)
|
int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
std::vector<bool> dirtyMask(pMesh->mNumVertices,(pMesh->mNumFaces ? true : false));
|
std::vector<bool> dirtyMask(pMesh->mNumVertices, pMesh->mNumFaces);
|
||||||
|
|
||||||
// Ignore elements that are not referenced by vertices.
|
// Ignore elements that are not referenced by vertices.
|
||||||
// (they are, for example, caused by the FindDegenerates step)
|
// (they are, for example, caused by the FindDegenerates step)
|
||||||
for (unsigned int m = 0; m < pMesh->mNumFaces;++m) {
|
for (unsigned int m = 0; m < pMesh->mNumFaces; ++m) {
|
||||||
const aiFace& f = pMesh->mFaces[m];
|
const aiFace& f = pMesh->mFaces[m];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < f.mNumIndices;++i) {
|
for (unsigned int i = 0; i < f.mNumIndices; ++i) {
|
||||||
dirtyMask[f.mIndices[i]] = false;
|
dirtyMask[f.mIndices[i]] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process vertex positions
|
// Process vertex positions
|
||||||
if(pMesh->mVertices && ProcessArray(pMesh->mVertices,pMesh->mNumVertices,"positions",dirtyMask)) {
|
if (pMesh->mVertices && ProcessArray(pMesh->mVertices, pMesh->mNumVertices, "positions", dirtyMask)) {
|
||||||
DefaultLogger::get()->error("Deleting mesh: Unable to continue without vertex positions");
|
DefaultLogger::get()->error("Deleting mesh: Unable to continue without vertex positions");
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// process texture coordinates
|
// process texture coordinates
|
||||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS && pMesh->mTextureCoords[i];++i) {
|
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS && pMesh->mTextureCoords[i]; ++i) {
|
||||||
if (ProcessArray(pMesh->mTextureCoords[i],pMesh->mNumVertices,"uvcoords",dirtyMask)) {
|
if (ProcessArray(pMesh->mTextureCoords[i], pMesh->mNumVertices, "uvcoords", dirtyMask)) {
|
||||||
|
pMesh->mNumUVComponents[i] = 0;
|
||||||
|
|
||||||
// delete all subsequent texture coordinate sets.
|
// delete all subsequent texture coordinate sets.
|
||||||
for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a) {
|
for (unsigned int a = i + 1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
||||||
delete[] pMesh->mTextureCoords[a]; pMesh->mTextureCoords[a] = NULL;
|
delete[] pMesh->mTextureCoords[a];
|
||||||
|
pMesh->mTextureCoords[a] = NULL;
|
||||||
|
pMesh->mNumUVComponents[a] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue