@@ -192,7 +192,7 @@ private bool ExportComponentAttributes (MeshInfo mesh, FbxMesh fbxMesh, int[] un
192
192
// Set the normals on Layer 0.
193
193
FbxLayer fbxLayer = GetOrCreateLayer ( fbxMesh ) ;
194
194
195
- if ( mesh . HasValidNormals ( unmergedTriangles . Length ) ) {
195
+ if ( mesh . HasValidNormals ( ) ) {
196
196
using ( var fbxLayerElement = FbxLayerElementNormal . Create ( fbxMesh , "Normals" ) ) {
197
197
fbxLayerElement . SetMappingMode ( FbxLayerElement . EMappingMode . eByPolygonVertex ) ;
198
198
fbxLayerElement . SetReferenceMode ( FbxLayerElement . EReferenceMode . eDirect ) ;
@@ -211,7 +211,7 @@ private bool ExportComponentAttributes (MeshInfo mesh, FbxMesh fbxMesh, int[] un
211
211
}
212
212
213
213
/// Set the binormals on Layer 0.
214
- if ( mesh . HasValidBinormals ( unmergedTriangles . Length ) ) {
214
+ if ( mesh . HasValidBinormals ( ) ) {
215
215
using ( var fbxLayerElement = FbxLayerElementBinormal . Create ( fbxMesh , "Binormals" ) ) {
216
216
fbxLayerElement . SetMappingMode ( FbxLayerElement . EMappingMode . eByPolygonVertex ) ;
217
217
fbxLayerElement . SetReferenceMode ( FbxLayerElement . EReferenceMode . eDirect ) ;
@@ -229,7 +229,7 @@ private bool ExportComponentAttributes (MeshInfo mesh, FbxMesh fbxMesh, int[] un
229
229
}
230
230
231
231
/// Set the tangents on Layer 0.
232
- if ( mesh . HasValidTangents ( unmergedTriangles . Length ) ) {
232
+ if ( mesh . HasValidTangents ( ) ) {
233
233
using ( var fbxLayerElement = FbxLayerElementTangent . Create ( fbxMesh , "Tangents" ) ) {
234
234
fbxLayerElement . SetMappingMode ( FbxLayerElement . EMappingMode . eByPolygonVertex ) ;
235
235
fbxLayerElement . SetReferenceMode ( FbxLayerElement . EReferenceMode . eDirect ) ;
@@ -253,7 +253,7 @@ mesh.Tangents [unityTriangle] [2]
253
253
254
254
exportedAttribute |= ExportUVs ( fbxMesh , mesh , unmergedTriangles ) ;
255
255
256
- if ( mesh . HasValidVertexColors ( unmergedTriangles . Length ) ) {
256
+ if ( mesh . HasValidVertexColors ( ) ) {
257
257
using ( var fbxLayerElement = FbxLayerElementVertexColor . Create ( fbxMesh , "VertexColors" ) ) {
258
258
fbxLayerElement . SetMappingMode ( FbxLayerElement . EMappingMode . eByPolygonVertex ) ;
259
259
fbxLayerElement . SetReferenceMode ( FbxLayerElement . EReferenceMode . eIndexToDirect ) ;
@@ -1430,9 +1430,7 @@ public Vector3 [] Binormals {
1430
1430
var normals = Normals ;
1431
1431
var tangents = Tangents ;
1432
1432
1433
- if ( IsValidArray < Vector3 > ( normals ) & &
1434
- IsValidArray < Vector4 > ( tangents , normals . Length )
1435
- ) {
1433
+ if ( HasValidNormals ( ) && HasValidTangents ( ) ) {
1436
1434
m_Binormals = new Vector3 [ normals . Length ] ;
1437
1435
1438
1436
for ( int i = 0 ; i < normals . Length ; i ++ )
@@ -1513,34 +1511,20 @@ public MeshInfo (Mesh mesh, Material[] materials)
1513
1511
}
1514
1512
}
1515
1513
1516
- /// <summary>
1517
- /// Determines whether this instance is a valid array with the specified length.
1518
- /// </summary>
1519
- /// <returns><c>true</c> if this instance is valid array; otherwise, <c>false</c>.</returns>
1520
- /// <param name="array">Array.</param>
1521
- /// <param name="expectedLength">Expected length.</param>
1522
- /// <typeparam name="T">The 1st type parameter.</typeparam>
1523
- public static bool IsValidArray < T > ( T [ ] array , int expectedLength = - 1 )
1524
- {
1525
- return array != null &&
1526
- array . Length > 0 &&
1527
- ( expectedLength >= 0 ? array . Length == expectedLength : true ) ;
1528
- }
1529
-
1530
- public bool HasValidNormals ( int expectedLength ) {
1531
- return IsValidArray < Vector3 > ( Normals , expectedLength ) ;
1514
+ public bool HasValidNormals ( ) {
1515
+ return Normals != null && Normals . Length == Vertices . Length ;
1532
1516
}
1533
1517
1534
- public bool HasValidBinormals ( int expectedLength ) {
1535
- return IsValidArray < Vector3 > ( Binormals , expectedLength ) ;
1518
+ public bool HasValidBinormals ( ) {
1519
+ return HasValidNormals ( ) && HasValidTangents ( ) && Binormals != null ;
1536
1520
}
1537
1521
1538
- public bool HasValidTangents ( int expectedLength ) {
1539
- return IsValidArray < Vector4 > ( Tangents , expectedLength ) ;
1522
+ public bool HasValidTangents ( ) {
1523
+ return Tangents != null && Tangents . Length == Vertices . Length ;
1540
1524
}
1541
1525
1542
- public bool HasValidVertexColors ( int expectedLength ) {
1543
- return IsValidArray < Color32 > ( VertexColors , expectedLength ) ;
1526
+ public bool HasValidVertexColors ( ) {
1527
+ return VertexColors != null && VertexColors . Length == Vertices . Length ;
1544
1528
}
1545
1529
}
1546
1530
0 commit comments