/// <summary> /// Adds a layer element to the mesh, hence adding a new entry to the vertex buffer /// </summary> /// <param name="_LayerElement"></param> public void AddLayerElement( FBXImporter.LayerElement _LayerElement ) { if ( _LayerElement == null ) throw new Exception( "Invalid layer element!" ); // Compact identical UV sets if ( m_Owner.CompactUVs && _LayerElement.ElementType == FBXImporter.LayerElement.ELEMENT_TYPE.UV ) { m_UVSetsCount++; // DEBUG // if ( m_Name == "Body" ) // m_Pivot = null; // DEBUG // Compare the new layer element with any existing UV element if ( m_UVSetsCount > m_Owner.MinUVsCount ) foreach ( FBXImporter.LayerElement Element in m_LayerElements ) if ( Element.ElementType == FBXImporter.LayerElement.ELEMENT_TYPE.UV ) { object[] ExistingUV = Element.ToArray(); object[] NewUV = _LayerElement.ToArray(); // This array is cached, so the cost of evaluation is only one if ( ExistingUV.Length != NewUV.Length ) continue; // They already differ by length... // Compare each entry of the arrays bool bEqual = true; for ( int i=0; i < ExistingUV.Length; i++ ) { Vector2D UV0 = ExistingUV[i] as Vector2D; Vector2D UV1 = NewUV[i] as Vector2D; if ( UV0 != UV1 ) { // They differ! bEqual = false; break; } } if ( bEqual ) return; // Both UV sets are equal, so we don't add the new one... } } // Add this as a new entry... m_LayerElements.Add( _LayerElement ); }