From b49d30865df2e8921b4baaef93000902d8883ff9 Mon Sep 17 00:00:00 2001 From: julianknodt Date: Mon, 9 Sep 2024 18:17:25 -0700 Subject: [PATCH] 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. --- code/AssetLib/FBX/FBXExporter.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/code/AssetLib/FBX/FBXExporter.cpp b/code/AssetLib/FBX/FBXExporter.cpp index 79fa572af..80339af22 100644 --- a/code/AssetLib/FBX/FBXExporter.cpp +++ b/code/AssetLib/FBX/FBXExporter.cpp @@ -1770,23 +1770,25 @@ void FBXExporter::WriteObjects () indent++; if (pAnimMesh->HasPositions()) { std::vectorshape_indices; - std::vectorpPositionDiff; - std::vectorpNormalDiff; + std::vectorpPositionDiff; + std::vectorpNormalDiff; for (unsigned int vt = 0; vt < vertex_indices.size(); ++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]); - pPositionDiff.push_back(pDiff[0]); - pPositionDiff.push_back(pDiff[1]); - pPositionDiff.push_back(pDiff[2]); + shape_indices.push_back(vertex_indices[vt]); + pPositionDiff.push_back(pDiff[0]); + pPositionDiff.push_back(pDiff[1]); + pPositionDiff.push_back(pDiff[2]); - if (pAnimMesh->HasNormals()) { - aiVector3D nDiff = (pAnimMesh->mNormals[vertex_indices[vt]] - m->mNormals[vertex_indices[vt]]); - pNormalDiff.push_back(nDiff[0]); - pNormalDiff.push_back(nDiff[1]); - pNormalDiff.push_back(nDiff[2]); - } + if (pAnimMesh->HasNormals()) { + aiVector3D nDiff = (pAnimMesh->mNormals[vertex_indices[vt]] - m->mNormals[vertex_indices[vt]]); + pNormalDiff.push_back(nDiff[0]); + pNormalDiff.push_back(nDiff[1]); + pNormalDiff.push_back(nDiff[2]); + } else { + pNormalDiff.push_back(0.0); + pNormalDiff.push_back(0.0); + pNormalDiff.push_back(0.0); } }