Skip to content

Commit 8563aed

Browse files
committed
store control point to index dict instead of recalculating
1 parent a0010df commit 8563aed

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ public bool ExportMesh (Mesh mesh, FbxNode fbxNode, Material[] materials = null)
590590
return ExportMesh(meshInfo, fbxNode);
591591
}
592592

593+
private Dictionary<Vector3, int> ControlPointToIndex = new Dictionary<Vector3, int> ();
594+
593595
/// <summary>
594596
/// Exports a unity mesh and attaches it to the node as an FbxMesh.
595597
/// </summary>
@@ -607,7 +609,7 @@ bool ExportMesh (MeshInfo meshInfo, FbxNode fbxNode)
607609
FbxMesh fbxMesh = FbxMesh.Create (fbxScene, "Scene");
608610

609611
// Create control points.
610-
Dictionary<Vector3, int> ControlPointToIndex = new Dictionary<Vector3, int> ();
612+
ControlPointToIndex.Clear();
611613
{
612614
var vertices = meshInfo.Vertices;
613615
for (int v = 0, n = meshInfo.VertexCount; v < n; v++) {
@@ -898,16 +900,6 @@ private bool ExportSkin (SkinnedMeshRenderer skinnedMesh,
898900
/// </summary>
899901
private void SetVertexWeights (MeshInfo meshInfo, Dictionary<int, FbxCluster> boneCluster)
900902
{
901-
// Create control points.
902-
Dictionary<Vector3, int> ControlPointToIndex = new Dictionary<Vector3, int> ();
903-
var vertices = meshInfo.Vertices;
904-
for (int v = 0, n = meshInfo.VertexCount; v < n; v++) {
905-
if (ControlPointToIndex.ContainsKey (vertices [v])) {
906-
continue;
907-
}
908-
ControlPointToIndex [vertices [v]] = ControlPointToIndex.Count();
909-
}
910-
911903
// set the vertex weights for each bone
912904
for (int i = 0; i < meshInfo.BoneWeights.Length; i++) {
913905
var boneWeights = meshInfo.BoneWeights;
@@ -931,7 +923,6 @@ boneWeights [i].weight3
931923
if (!boneCluster.ContainsKey (indices [j])) {
932924
continue;
933925
}
934-
//boneCluster [indices [j]].AddControlPointIndex (i, weights [j]);
935926
boneCluster [indices [j]].AddControlPointIndex (ControlPointToIndex[meshInfo.Vertices[i]], weights [j]);
936927
}
937928
}

0 commit comments

Comments
 (0)