Skip to content

Commit 408c0b1

Browse files
committed
Don't add bone weights for duplicate vertices
1 parent 4e695a3 commit 408c0b1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,17 @@ private bool ExportSkin (SkinnedMeshRenderer skinnedMesh,
10251025
/// </summary>
10261026
private void SetVertexWeights (MeshInfo meshInfo, Dictionary<int, FbxCluster> boneCluster)
10271027
{
1028+
HashSet<int> visitedVertices = new HashSet<int> ();
1029+
10281030
// set the vertex weights for each bone
10291031
for (int i = 0; i < meshInfo.BoneWeights.Length; i++) {
1032+
var actualIndex = ControlPointToIndex [meshInfo.Vertices [i]];
1033+
1034+
if (visitedVertices.Contains (actualIndex)) {
1035+
continue;
1036+
}
1037+
visitedVertices.Add (actualIndex);
1038+
10301039
var boneWeights = meshInfo.BoneWeights;
10311040
int[] indices = {
10321041
boneWeights [i].boneIndex0,
@@ -1048,7 +1057,8 @@ boneWeights [i].weight3
10481057
if (!boneCluster.ContainsKey (indices [j])) {
10491058
continue;
10501059
}
1051-
boneCluster [indices [j]].AddControlPointIndex (ControlPointToIndex[meshInfo.Vertices[i]], weights [j]);
1060+
// add vertex and weighting on vertex to this bone's cluster
1061+
boneCluster [indices [j]].AddControlPointIndex (actualIndex, weights [j]);
10521062
}
10531063
}
10541064
}

0 commit comments

Comments
 (0)