private void FilterSegmentIntersectionPoints(RoadSegment segment)
        {
            var outerNode     = segment.PointA == Node ? segment.PointB : segment.PointA;
            var minSqrDist    = float.MaxValue;
            var tuple         = new Tuple <Node, Node>(segment.PointA, segment.PointB);
            var directionSign = outerNode == segment.PointB ? -1 : 1;
            var outerNodeData = outerNode.NodeDataDict[tuple];
            var nodeData      = Node.NodeDataDict[tuple];

            if (segment.LeftBound.BoundIntersectionPoints.Count > 0)
            {
                var leftIntersectionBoundPos = Vector3.zero;

                foreach (var point in segment.LeftBound.BoundIntersectionPoints)
                {
                    var sqrDist = Vector3.SqrMagnitude(outerNodeData.LeftBoundPoint - point);

                    if (sqrDist < minSqrDist)
                    {
                        minSqrDist = sqrDist;
                        leftIntersectionBoundPos = point;
                    }
                }

                nodeData.LeftBoundPoint = leftIntersectionBoundPos - segment.Direction * directionSign * Padding;
            }

            if (segment.RightBound.BoundIntersectionPoints.Count > 0)
            {
                minSqrDist = float.MaxValue;
                var rightIntersectionBoundPos = Vector3.zero;

                foreach (var point in segment.RightBound.BoundIntersectionPoints)
                {
                    var sqrDist = Vector3.SqrMagnitude(outerNodeData.RightBoundPoint - point);

                    if (sqrDist < minSqrDist)
                    {
                        minSqrDist = sqrDist;
                        rightIntersectionBoundPos = point;
                    }
                }

                nodeData.RightBoundPoint = rightIntersectionBoundPos - segment.Direction * directionSign * Padding;
            }
        }
Esempio n. 2
0
 public void SetRoadSegment()
 {
     Segment = new RoadSegment(Tuple);
 }