more precise vert weight distribution

This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent 9903f6983b
commit b215eeadfa
3 changed files with 36 additions and 17 deletions
+14 -2
View File
@@ -288,8 +288,20 @@ namespace vb01{
vertPos.push_back(vPos);
vertNorm.push_back(vNorm);
for(int j = 0; j < numBones; j++)
vertWeights.push_back(atof(data[6 + j].c_str()));
float weightCoefs[numBones];
for(int i = 0; i < numBones; i++)
weightCoefs[i] = atof(data[6 + i].c_str());
int numPosWeights = 0;
float sumWeightCoefs = 0;
for(int i = 0; i < numBones; i++)
if(weightCoefs[i] > 0){
sumWeightCoefs += weightCoefs[i];
}
float root = 1. / sumWeightCoefs;
for(int i = 0; i < numBones; i++)
vertWeights.push_back(root * weightCoefs[i]);
}
}