fix vertices being joined duplicating weights

This bug causes weights to duplicate, i.e. one bone will have several (equal) weights assigned to the same vertex - which then has the potential to cause even bigger problems when combined with `LimitBoneWeightsProcess`.
pull/4707/head
Gargaj 2022-08-31 22:27:34 +02:00 committed by GitHub
parent 2c3538fc46
commit a22aa75bca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -394,6 +394,16 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
const aiVertexWeight& ow = bone->mWeights[ b ];
// if the vertex is a unique one, translate it
if ( !( replaceIndex[ ow.mVertexId ] & 0x80000000 ) ) {
bool weightAlreadyExists = false;
for (std::vector<aiVertexWeight>::iterator vit = newWeights.begin(); vit != newWeights.end(); ++vit) {
if (vit->mVertexId == replaceIndex[ow.mVertexId]) {
weightAlreadyExists = true;
break;
}
}
if (weightAlreadyExists) {
continue;
}
aiVertexWeight nw;
nw.mVertexId = replaceIndex[ ow.mVertexId ];
nw.mWeight = ow.mWeight;