@@ -21,7 +21,7 @@ public class MeshInfo
2121 public List < Vector3 > m_Verts ;
2222 public List < int > m_VertUsedCounts ;
2323 public Dictionary < Vector3 , int > m_VertSimilars ;
24- public List < Vector3 > m_VertToIndicesDir ;
24+ public List < List < int > > m_VertToIndicesDir ;
2525
2626 public List < int > [ ] m_Indices ;
2727 public int [ ] m_IndiceOffsets ;
@@ -173,11 +173,14 @@ public void Update()
173173 var indice = m_Indices [ i ] ;
174174 for ( int j = 0 ; j < indice . Count ; j ++ )
175175 {
176- var idx = indice [ j ] ;
177- m_VertToIndicesDir [ idx ] = ( m_IndiceMedians [ i ] [ j / m_TopologyDivision [ m_IndiceTypes [ i ] ] ] - m_Verts [ idx ] ) ;
176+ var idx = indice [ j ] ; // this is index of vertex, btw
178177 if ( m_VertUsedCounts [ idx ] == 0 )
178+ {
179179 m_VertOrphan -- ;
180- m_VertUsedCountMax = Mathf . Max ( m_VertUsedCountMax , ++ m_VertUsedCounts [ idx ] ) ;
180+ m_VertToIndicesDir [ idx ] = new List < int > ( ) ;
181+ }
182+ m_VertToIndicesDir [ idx ] . Add ( m_IndiceOffsets [ i ] + j ) ;
183+ m_VertUsedCountMax = Mathf . Max ( m_VertUsedCountMax , ++ m_VertUsedCounts [ idx ] ) ;
181184 }
182185 }
183186 }
@@ -270,6 +273,20 @@ private static void Set<T>(ref List<T> list, T[] array)
270273 Reset < T > ( ref list ) ;
271274 list . AddRange ( array ) ;
272275 }
276+
277+ public void UnpackTriangleIdx ( int src , out int submesh , out int localidx )
278+ {
279+ for ( int i = m_MeshSubmeshCount ; i -- > 0 ; )
280+ {
281+ if ( i > 0 && m_IndiceOffsets [ i - 1 ] > src )
282+ continue ;
283+ submesh = i ;
284+ localidx = src - m_IndiceOffsets [ i ] ;
285+ return ;
286+ }
287+ submesh = 0 ;
288+ localidx = src ;
289+ }
273290}
274291
275292internal static class InternalMeshUtil
0 commit comments