Merge pull request #3512 from boguscoder/master
Fix for 3489 | Preserve morph targets when splitting by bone countpull/3516/head^2
commit
63f1b66224
|
@ -408,6 +408,45 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
|||
}
|
||||
}
|
||||
|
||||
// ... and copy all the morph targets for all the vertices which made it into the new submesh
|
||||
if (pMesh->mNumAnimMeshes > 0) {
|
||||
newMesh->mNumAnimMeshes = pMesh->mNumAnimMeshes;
|
||||
newMesh->mAnimMeshes = new aiAnimMesh*[newMesh->mNumAnimMeshes];
|
||||
|
||||
for (unsigned int morphIdx = 0; morphIdx < newMesh->mNumAnimMeshes; ++morphIdx) {
|
||||
aiAnimMesh* origTarget = pMesh->mAnimMeshes[morphIdx];
|
||||
aiAnimMesh* newTarget = new aiAnimMesh;
|
||||
newTarget->mName = origTarget->mName;
|
||||
newTarget->mWeight = origTarget->mWeight;
|
||||
newTarget->mNumVertices = numSubMeshVertices;
|
||||
newTarget->mVertices = new aiVector3D[numSubMeshVertices];
|
||||
newMesh->mAnimMeshes[morphIdx] = newTarget;
|
||||
|
||||
if (origTarget->HasNormals()) {
|
||||
newTarget->mNormals = new aiVector3D[numSubMeshVertices];
|
||||
}
|
||||
|
||||
if (origTarget->HasTangentsAndBitangents()) {
|
||||
newTarget->mTangents = new aiVector3D[numSubMeshVertices];
|
||||
newTarget->mBitangents = new aiVector3D[numSubMeshVertices];
|
||||
}
|
||||
|
||||
for( unsigned int vi = 0; vi < numSubMeshVertices; ++vi) {
|
||||
// find the source vertex for it in the source mesh
|
||||
unsigned int previousIndex = previousVertexIndices[vi];
|
||||
newTarget->mVertices[vi] = origTarget->mVertices[previousIndex];
|
||||
|
||||
if (newTarget->HasNormals()) {
|
||||
newTarget->mNormals[vi] = origTarget->mNormals[previousIndex];
|
||||
}
|
||||
if (newTarget->HasTangentsAndBitangents()) {
|
||||
newTarget->mTangents[vi] = origTarget->mTangents[previousIndex];
|
||||
newTarget->mBitangents[vi] = origTarget->mBitangents[previousIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// I have the strange feeling that this will break apart at some point in time...
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue