@@ -1992,27 +1992,19 @@ public void AddBlendShapes(BlendShape[] blendShapes)
19921992 #region Initialize
19931993 /// <summary>
19941994 /// Initializes the algorithm with the original mesh.
1995- /// Will automatically detect the count of UV components used on the mesh.
19961995 /// </summary>
19971996 /// <param name="mesh">The mesh.</param>
19981997 public void Initialize ( Mesh mesh )
1999- {
2000- Initialize ( mesh , - 1 ) ;
2001- }
2002-
2003- /// <summary>
2004- /// Initializes the algorithm with the original mesh.
2005- /// </summary>
2006- /// <param name="mesh">The mesh.</param>
2007- /// <param name="uvComponentCount">The count of UV components that are used on the mesh.
2008- /// -1 means that it will be automatically detected.
2009- /// Note that all UV channels would use the same UV component count.</param>
2010- public void Initialize ( Mesh mesh , int uvComponentCount )
20111998 {
20121999 if ( mesh == null )
20132000 throw new ArgumentNullException ( nameof ( mesh ) ) ;
2014- if ( uvComponentCount < - 1 || uvComponentCount > 4 )
2015- throw new ArgumentOutOfRangeException ( nameof ( uvComponentCount ) ) ;
2001+
2002+ int uvComponentCount = simplificationOptions . UVComponentCount ;
2003+ if ( simplificationOptions . ManualUVComponentCount )
2004+ {
2005+ if ( uvComponentCount < 0 || uvComponentCount > 4 )
2006+ throw new InvalidOperationException ( "The UV component count cannot be below 0 or above 4." ) ;
2007+ }
20162008
20172009 this . Vertices = mesh . vertices ;
20182010 this . Normals = mesh . normals ;
@@ -2024,33 +2016,35 @@ public void Initialize(Mesh mesh, int uvComponentCount)
20242016
20252017 for ( int channel = 0 ; channel < UVChannelCount ; channel ++ )
20262018 {
2027- switch ( uvComponentCount )
2019+ if ( simplificationOptions . ManualUVComponentCount )
20282020 {
2029- case - 1 :
2030- {
2031- var uvs = MeshUtils . GetMeshUVs ( mesh , channel ) ;
2032- SetUVsAuto ( channel , uvs ) ;
2033- break ;
2034- }
2035- case 1 :
2036- case 2 :
2037- {
2038- var uvs = MeshUtils . GetMeshUVs2D ( mesh , channel ) ;
2039- SetUVs ( channel , uvs ) ;
2040- break ;
2041- }
2042- case 3 :
2043- {
2044- var uvs = MeshUtils . GetMeshUVs3D ( mesh , channel ) ;
2045- SetUVs ( channel , uvs ) ;
2046- break ;
2047- }
2048- case 4 :
2049- {
2050- var uvs = MeshUtils . GetMeshUVs ( mesh , channel ) ;
2051- SetUVs ( channel , uvs ) ;
2052- break ;
2053- }
2021+ switch ( uvComponentCount )
2022+ {
2023+ case 1 :
2024+ case 2 :
2025+ {
2026+ var uvs = MeshUtils . GetMeshUVs2D ( mesh , channel ) ;
2027+ SetUVs ( channel , uvs ) ;
2028+ break ;
2029+ }
2030+ case 3 :
2031+ {
2032+ var uvs = MeshUtils . GetMeshUVs3D ( mesh , channel ) ;
2033+ SetUVs ( channel , uvs ) ;
2034+ break ;
2035+ }
2036+ case 4 :
2037+ {
2038+ var uvs = MeshUtils . GetMeshUVs ( mesh , channel ) ;
2039+ SetUVs ( channel , uvs ) ;
2040+ break ;
2041+ }
2042+ }
2043+ }
2044+ else
2045+ {
2046+ var uvs = MeshUtils . GetMeshUVs ( mesh , channel ) ;
2047+ SetUVsAuto ( channel , uvs ) ;
20542048 }
20552049 }
20562050
0 commit comments