public static int doSubmeshesShareVertsOrTris(Mesh m, ref MeshAnalysisResult mar) { MB_Triangle consider = new MB_Triangle(); MB_Triangle other = new MB_Triangle(); //cache all triangles int[][] tris = new int[m.subMeshCount][]; for (int i = 0; i < m.subMeshCount; i++) { tris[i] = m.GetTriangles(i); } bool sharesVerts = false; bool sharesTris = false; for (int i = 0; i < m.subMeshCount; i++) { int[] smA = tris[i]; for (int j = i + 1; j < m.subMeshCount; j++) { int[] smB = tris[j]; for (int k = 0; k < smA.Length; k += 3) { consider.Initialize(smA, k, i); for (int l = 0; l < smB.Length; l += 3) { other.Initialize(smB, l, j); if (consider.isSame(other)) { sharesTris = true; break; } if (consider.sharesVerts(other)) { sharesVerts = true; break; } } } } } if (sharesTris) { mar.hasOverlappingSubmeshVerts = true; mar.hasOverlappingSubmeshTris = true; return(2); } else if (sharesVerts) { mar.hasOverlappingSubmeshVerts = true; mar.hasOverlappingSubmeshTris = false; return(1); } else { mar.hasOverlappingSubmeshTris = false; mar.hasOverlappingSubmeshVerts = false; return(0); } }
public static int doSubmeshesShareVertsOrTris(Mesh m) { List <MB_Triangle> tlist = new List <MB_Triangle>(); bool sharesVerts = false; bool sharesTris = false; for (int i = 0; i < m.subMeshCount; i++) { int[] sm = m.GetTriangles(i); for (int j = 0; j < sm.Length; j += 3) { MB_Triangle consider = new MB_Triangle(sm, j, i); for (int k = 0; k < tlist.Count; k++) { if (consider.isSame(tlist[k])) { sharesTris = true; } if (consider.sharesVerts(tlist[k])) { sharesVerts = true; } } tlist.Add(consider); } } if (sharesTris) { return(2); } if (sharesVerts) { return(1); } return(0); }
public static int doSubmeshesShareVertsOrTris(Mesh m, ref MeshAnalysisResult mar){ MB_Triangle consider = new MB_Triangle(); MB_Triangle other = new MB_Triangle(); //cache all triangles int[][] tris = new int[m.subMeshCount][]; for (int i = 0; i < m.subMeshCount; i++){ tris[i] = m.GetTriangles(i); } bool sharesVerts = false; bool sharesTris = false; for (int i = 0; i < m.subMeshCount; i++){ int[] smA = tris[i]; for (int j = i+1; j < m.subMeshCount; j++){ int[] smB = tris[j]; for (int k = 0; k < smA.Length; k+=3){ consider.Initialize(smA,k,i); for (int l = 0; l < smB.Length; l+=3){ other.Initialize(smB,l,j); if (consider.isSame(other)){ sharesTris = true; break; } if (consider.sharesVerts(other)){ sharesVerts = true; break; } } } } } if (sharesTris){ mar.hasOverlappingSubmeshVerts = true; mar.hasOverlappingSubmeshTris = true; return 2; } else if (sharesVerts){ mar.hasOverlappingSubmeshVerts = true; mar.hasOverlappingSubmeshTris = false; return 1; } else { mar.hasOverlappingSubmeshTris = false; mar.hasOverlappingSubmeshVerts = false; return 0; } }
public static int doSubmeshesShareVertsOrTris(Mesh m){ List<MB_Triangle> tlist = new List<MB_Triangle>(); bool sharesVerts = false; bool sharesTris = false; for (int i = 0; i < m.subMeshCount; i++){ int[] sm = m.GetTriangles(i); for (int j = 0; j < sm.Length; j+=3){ MB_Triangle consider = new MB_Triangle(sm,j,i); for (int k = 0; k < tlist.Count; k++){ if (consider.isSame(tlist[k])) sharesTris = true; if (consider.sharesVerts(tlist[k])){ sharesVerts = true; } } tlist.Add(consider); } } if (sharesTris) return 2; if (sharesVerts) return 1; return 0; }