public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (GetType() != obj.GetType()) { return(false); } IndexConnection other = (IndexConnection)obj; if (edgeVertexIndex1 != other.edgeVertexIndex1) { return(false); } if (edgeVertexIndex2 != other.edgeVertexIndex2) { return(false); } if (fromTriIndex != other.fromTriIndex) { return(false); } if (toTriIndex != other.toTriIndex) { return(false); } return(true); }
private static HashSet <IndexConnection> GetIndexConnections(int[] indices) { var indexConnections = new HashSet <IndexConnection>(); int[] edge = { -1, -1 }; short i = 0; int j, a0, a1, a2, b0, b1, b2, triAIndex, triBIndex; while (i < indices.Length) { triAIndex = (short)(i / 3); // A三角形编号 a0 = indices[i++]; a1 = indices[i++]; a2 = indices[i++]; j = i; while (j < indices.Length) { triBIndex = (short)(j / 3); // B三角形编号 b0 = indices[j++]; b1 = indices[j++]; b2 = indices[j++]; if (HasSharedEdgeIndices(a0, a1, a2, b0, b1, b2, edge)) { var indexConnection1 = new IndexConnection(edge[0], edge[1], triAIndex, triBIndex); var indexConnection2 = new IndexConnection(edge[1], edge[0], triBIndex, triAIndex); indexConnections.Add(indexConnection1); indexConnections.Add(indexConnection2); edge[0] = -1; edge[1] = -1; // Debug.LogError("共享边:{} -> // {}",indexConnection1.ToString(),indexConnection2.ToString()); } } } Debug.Log($"连接个数:{indexConnections.Count}"); return(indexConnections); }