//Updated private void DrawNodeNet(ref bool elementClicked) { //Nodes for (int i = 0; i < creator.NNodes; i++) { DrawNode(creator.GetNode(i), ref elementClicked); DrawNodeID(i); } //Stretches for (int i = 0; i < creator.NStretches; i++) { Stretch st = creator.GetStretch(i); Vector3[] points = st.GetPoints(); DrawHandler(st, ref elementClicked); DrawStretch(points); if (creator.displayNet) { DrawBezier(points, netDisplaySettings, st.IsIntersection()); } DrawDeleteButton(st); if (netDisplaySettings.showArrows) { DrawArrow(st); } if (netDisplaySettings.showVertices) { DrawVertices(st); } } }
public Vector3 GetClosestPoint(Vector3 worldPos, bool includeIntersections = true) { float minDst = float.MaxValue; Vector3 closestPoint = Vector3.zero; Stretch st = null; for (int i = 0; i < stretches.Count; i++) { st = GetStretch(i); Vector3 p = st.GetClosestPointOnStretch(worldPos); float dst = (worldPos - p).sqrMagnitude; if (dst < minDst) { if (!includeIntersections) { if (!st.IsIntersection()) { minDst = dst; closestPoint = p; } } else { minDst = dst; closestPoint = p; } } } return(closestPoint); }