Skip to content

Commit 30ed0a7

Browse files
author
Benoit Hudson
committed
UNI-25723: Remove the 'weldVertices' option
We aren't using it ever, so we aren't testing that weldVertices: false actually works. Also, we don't have a use case for not welding vertices at all -- any use case we can come up with involves doing custom stuff that the callbacks are useful for.
1 parent 91410fa commit 30ed0a7

File tree

2 files changed

+19
-39
lines changed

2 files changed

+19
-39
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
119119
public const string kDefaultSavePath = ".";
120120

121121
// Note: default values are set in LoadDefaults().
122-
[HideInInspector]
123-
public bool weldVertices;
124-
125122
public bool mayaCompatibleNames;
126123
public bool centerObjects;
127124

@@ -150,7 +147,6 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
150147

151148
protected override void LoadDefaults()
152149
{
153-
weldVertices = true;
154150
mayaCompatibleNames = true;
155151
centerObjects = true;
156152
keepOriginalAfterConvert = false;

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -542,17 +542,16 @@ private void AssignLayerElementMaterial(FbxMesh fbxMesh, Mesh mesh, int material
542542
///
543543
/// Use fbxNode.GetMesh() to access the exported mesh.
544544
/// </summary>
545-
/// <param name="weldVertices">If set to <c>true</c>, combine identical vertices together into one Fbx vertex.</param>
546-
public void ExportMesh (Mesh mesh, FbxNode fbxNode, bool weldVertices = true, Material[] materials = null)
545+
public void ExportMesh (Mesh mesh, FbxNode fbxNode, Material[] materials = null)
547546
{
548547
var meshInfo = new MeshInfo(mesh, materials);
549-
ExportMesh(meshInfo, fbxNode, weldVertices);
548+
ExportMesh(meshInfo, fbxNode);
550549
}
551550

552551
/// <summary>
553552
/// Exports a unity mesh and attaches it to the node as an FbxMesh.
554553
/// </summary>
555-
void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, bool weldVertices)
554+
void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode)
556555
{
557556
if (!meshInfo.IsValid) {
558557
return;
@@ -567,31 +566,20 @@ void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, bool weldVertices)
567566

568567
// Create control points.
569568
Dictionary<Vector3, int> ControlPointToIndex = new Dictionary<Vector3, int> ();
570-
571-
int NumControlPoints = 0;
572-
if (weldVertices) {
573-
for (int v = 0; v < meshInfo.VertexCount; v++) {
574-
if (ControlPointToIndex.ContainsKey (meshInfo.Vertices [v])) {
569+
{
570+
var vertices = meshInfo.Vertices;
571+
for (int v = 0, n = meshInfo.VertexCount; v < n; v++) {
572+
if (ControlPointToIndex.ContainsKey (vertices [v])) {
575573
continue;
576574
}
577-
ControlPointToIndex [meshInfo.Vertices [v]] = NumControlPoints;
578-
579-
NumControlPoints++;
580-
}
581-
fbxMesh.InitControlPoints (NumControlPoints);
582-
583-
foreach (var controlPoint in ControlPointToIndex.Keys) {
584-
fbxMesh.SetControlPointAt (ConvertPositionToRightHanded(controlPoint),
585-
ControlPointToIndex [controlPoint]);
575+
ControlPointToIndex [vertices [v]] = ControlPointToIndex.Count();
586576
}
587-
} else {
588-
NumControlPoints = meshInfo.VertexCount;
589-
fbxMesh.InitControlPoints (NumControlPoints);
577+
fbxMesh.InitControlPoints (ControlPointToIndex.Count());
590578

591-
// copy control point data from Unity to FBX
592-
for (int v = 0; v < NumControlPoints; v++)
593-
{
594-
fbxMesh.SetControlPointAt(ConvertPositionToRightHanded(meshInfo.Vertices[v]), v);
579+
foreach (var kvp in ControlPointToIndex) {
580+
var controlPoint = kvp.Key;
581+
var index = kvp.Value;
582+
fbxMesh.SetControlPointAt (ConvertPositionToRightHanded(controlPoint), index);
595583
}
596584
}
597585

@@ -636,9 +624,7 @@ void ExportMesh (MeshInfo meshInfo, FbxNode fbxNode, bool weldVertices)
636624
// properly export UVs, normals, binormals, etc.
637625
unmergedPolygons [current] = polyVert;
638626

639-
if (weldVertices) {
640-
polyVert = ControlPointToIndex [meshInfo.Vertices [polyVert]];
641-
}
627+
polyVert = ControlPointToIndex [meshInfo.Vertices [polyVert]];
642628
fbxMesh.AddPolygon (polyVert);
643629

644630
current++;
@@ -746,8 +732,7 @@ protected bool ExportInstance (GameObject unityGo, FbxNode fbxNode, FbxScene fbx
746732

747733
if (!SharedMeshes.TryGetValue (unityPrefabParent.name, out fbxMesh))
748734
{
749-
bool weldVertices = ExportSettings.weldVertices;
750-
ExportMesh (unityGo, fbxNode, weldVertices);
735+
ExportMesh (unityGo, fbxNode);
751736
if (fbxNode.GetMesh() != null) {
752737
SharedMeshes [unityPrefabParent.name] = fbxNode.GetMesh();
753738
}
@@ -812,8 +797,7 @@ protected int ExportComponents (
812797

813798
// try exporting mesh as an instance, export regularly if we cannot
814799
if (!ExportInstance (unityGo, fbxNode, fbxScene)) {
815-
bool weldVertices = ExportSettings.weldVertices;
816-
ExportMesh (unityGo, fbxNode, weldVertices);
800+
ExportMesh (unityGo, fbxNode);
817801
}
818802

819803
if (Verbose)
@@ -1494,7 +1478,7 @@ public static void UnRegisterMeshCallback(GetMeshForObject callback)
14941478
/// This goes through the callback system to find the right mesh and
14951479
/// allow plugins to substitute their own meshes.
14961480
/// </summary>
1497-
void ExportMesh (GameObject gameObject, FbxNode fbxNode, bool weldVertices)
1481+
void ExportMesh (GameObject gameObject, FbxNode fbxNode)
14981482
{
14991483
// First allow the object-based callbacks to have a hack at it.
15001484
foreach(var callback in MeshForObjectCallbacks) {
@@ -1547,14 +1531,14 @@ void ExportMesh (GameObject gameObject, FbxNode fbxNode, bool weldVertices)
15471531
if (meshFilter) {
15481532
var renderer = gameObject.GetComponent<Renderer>();
15491533
var materials = renderer ? renderer.sharedMaterials : null;
1550-
ExportMesh(new MeshInfo(meshFilter.sharedMesh, materials), fbxNode, weldVertices);
1534+
ExportMesh(new MeshInfo(meshFilter.sharedMesh, materials), fbxNode);
15511535
} else {
15521536
var smr = defaultComponent as SkinnedMeshRenderer;
15531537
if (smr) {
15541538
var mesh = new Mesh();
15551539
smr.BakeMesh(mesh);
15561540
var materials = smr.sharedMaterials;
1557-
ExportMesh(new MeshInfo(mesh, materials), fbxNode, weldVertices);
1541+
ExportMesh(new MeshInfo(mesh, materials), fbxNode);
15581542
Object.DestroyImmediate(mesh);
15591543
}
15601544
}

0 commit comments

Comments
 (0)