/// <summary> /// 获取最边缘一圈的顶点。 /// </summary> /// <param name="lineStart">起点</param> /// <param name="far">远处的交点</param> /// <param name="outdir">外包边</param> /// <param name="listOutEdgePoint"></param> /// <returns></returns> private static List <Float2> SearchOutPoint(Float2 lineStart, Float2 far, Float2 outdir, List <Float2> listOutEdgePoint) { if (listOutEdgePoint == null || listOutEdgePoint.Count == 0) { return(listOutEdgePoint); } // 开始搜寻了。 List <Float2> lResult = new List <Float2>(); Float2 startPoint = lineStart; Float2 bestPoint = Float2.zero; Float2 indir = far - lineStart; bool isHaveBestPoint = false; List <Float2> listinPoints = new List <Float2>(); List <Float2> lHave = listOutEdgePoint; while (lHave != null && lHave.Count > 0) { // 先过滤了。 foreach (Float2 pos in lHave) { if (Float2.CheckPointInCorns(pos, startPoint, indir, outdir) == true) { listinPoints.Add(pos); if (isHaveBestPoint == false) { bestPoint = pos; isHaveBestPoint = true; } } } // 再则优。 if (isHaveBestPoint == true) { for (int i = 1; i < listinPoints.Count; i++) { // 比较更好的点。 if (Float2.CheckPointInCorns(listinPoints[i], startPoint, bestPoint - startPoint, outdir) == true) { bestPoint = listinPoints[i]; } } // 进行交换,执行下一轮迭代。 lResult.Add(bestPoint); outdir = (bestPoint - startPoint).normalized; startPoint = bestPoint; indir = far - startPoint; listinPoints.Remove(bestPoint); lHave = listinPoints; listinPoints = new List <Float2>(); isHaveBestPoint = false; } else { break; } } return(lResult); }