/// <summary> /// Test if another triangle shares any edges with this triangle by checking if the share at least two vertices. /// </summary> public bool IsConnected(GpTriangle otherTriangle) { var connectCount = 0; for (var i = 0; i < 3; i++) { if (this[i] == otherTriangle.V1 || this[i] == otherTriangle.V2 || this[i] == otherTriangle.V3) { connectCount++; } } return(connectCount > 1); }
public GpNavMesh(GpVector3[] vertices, int[] triangles) { Vertices = vertices; TriangleIndices = triangles; Triangles = new GpTriangle[triangles.Length / 3]; // Calculate triangles for all vertices var index = 0; for (var i = 0; i < TriangleIndices.Length; i += 3) { var v1 = Vertices[TriangleIndices[i]]; var v2 = Vertices[TriangleIndices[i + 1]]; var v3 = Vertices[TriangleIndices[i + 2]]; Triangles[index] = new GpTriangle(v1, v2, v3); index++; } }