/// <summary> /// Remove long and short edges from the connections so we don't choose really long or stubby connections accidentally /// </summary> /// <param name="num"></param> private void RemoveLongShortEdges(int num) { num = Mathf.RoundToInt(num / 2f); for (int i = 0; i < num; i++) { float longestLength = 0; VertexPair longestEdge = null; float shortestLength = float.PositiveInfinity; VertexPair shortestEdge = null; foreach (var kV in triangulator.connectedVertices) { foreach (var vertex in kV.Value) { VertexPair edge = new VertexPair(kV.Key, vertex); float distance = triangulator.EdgeLength(edge); if (distance > longestLength) { longestLength = distance; longestEdge = edge; } if (distance < shortestLength) { shortestLength = distance; shortestEdge = edge; } } } triangulator.connectedVertices[longestEdge.v1].Remove(longestEdge.v0); triangulator.connectedVertices[longestEdge.v0].Remove(longestEdge.v1); triangulator.connectedVertices[shortestEdge.v1].Remove(shortestEdge.v0); triangulator.connectedVertices[shortestEdge.v0].Remove(shortestEdge.v1); } }