Blendshape export float & same # verts

Previously it was possible that the number of vertices between the mesh and morph mesh varied.
This may have caused problems in tools like Blender, and this ensures there's a 1-1
correspondence between vertices.

In addition, exporting doubles broke meshlab on import, so now it exports floats.
pull/5775/head
julianknodt 2024-09-09 18:17:25 -07:00
parent 4024726eca
commit b49d30865d
1 changed files with 15 additions and 13 deletions

View File

@ -1770,12 +1770,11 @@ void FBXExporter::WriteObjects ()
indent++; indent++;
if (pAnimMesh->HasPositions()) { if (pAnimMesh->HasPositions()) {
std::vector<int32_t>shape_indices; std::vector<int32_t>shape_indices;
std::vector<double>pPositionDiff; std::vector<float>pPositionDiff;
std::vector<double>pNormalDiff; std::vector<float>pNormalDiff;
for (unsigned int vt = 0; vt < vertex_indices.size(); ++vt) { for (unsigned int vt = 0; vt < vertex_indices.size(); ++vt) {
aiVector3D pDiff = (pAnimMesh->mVertices[vertex_indices[vt]] - m->mVertices[vertex_indices[vt]]); aiVector3D pDiff = (pAnimMesh->mVertices[vertex_indices[vt]] - m->mVertices[vertex_indices[vt]]);
if(pDiff.Length()>1e-8){
shape_indices.push_back(vertex_indices[vt]); shape_indices.push_back(vertex_indices[vt]);
pPositionDiff.push_back(pDiff[0]); pPositionDiff.push_back(pDiff[0]);
pPositionDiff.push_back(pDiff[1]); pPositionDiff.push_back(pDiff[1]);
@ -1786,7 +1785,10 @@ void FBXExporter::WriteObjects ()
pNormalDiff.push_back(nDiff[0]); pNormalDiff.push_back(nDiff[0]);
pNormalDiff.push_back(nDiff[1]); pNormalDiff.push_back(nDiff[1]);
pNormalDiff.push_back(nDiff[2]); pNormalDiff.push_back(nDiff[2]);
} } else {
pNormalDiff.push_back(0.0);
pNormalDiff.push_back(0.0);
pNormalDiff.push_back(0.0);
} }
} }