void GetEdgePosition(MarkupPoint.Type pointType, float offset, out Vector3 position, out Vector3 direction) { float lineShift; switch (pointType) { case MarkupPoint.Type.LeftEdge: RightLane.NetLane.CalculatePositionAndDirection(Point, out position, out direction); lineShift = -RightLane.HalfWidth; break; case MarkupPoint.Type.RightEdge: LeftLane.NetLane.CalculatePositionAndDirection(Point, out position, out direction); lineShift = LeftLane.HalfWidth; break; default: throw new Exception(); } direction = SegmentEnter.IsStartSide ? -direction : direction; var angle = Vector3.Angle(direction, SegmentEnter.CornerDir); angle = (angle > 90 ? 180 - angle : angle); lineShift /= Mathf.Sin(angle * Mathf.Deg2Rad); direction.Normalize(); position += SegmentEnter.CornerDir * (lineShift + offset); }
public void GetPositionAndDirection(MarkupPoint.Type pointType, float offset, out Vector3 position, out Vector3 direction) { if ((pointType & MarkupPoint.Type.Between) != MarkupPoint.Type.None) { GetMiddlePosition(offset, out position, out direction); } else if ((pointType & MarkupPoint.Type.Edge) != MarkupPoint.Type.None) { GetEdgePosition(pointType, offset, out position, out direction); } else { throw new Exception(); } }