Beispiel #1
0
        public void AddSegment(RoadTemplate template, MapObject start, MapObject end)
        {
            var startNode = GetOrCreateNode(start.Position);
            var endNode   = GetOrCreateNode(end.Position);

            if (endNode == startNode)
            {
                // create a new dummy node, otherwise this edge gets counted twice as incoming edge of startNode
                // add a small offset to make sure that other map objects use the 'normal' node
                endNode = GetOrCreateNode(end.Position + 0.001f * Vector3.UnitX);
            }

            var edge = new RoadTopologyEdge(
                template,
                startNode,
                start.RoadType,
                endNode,
                end.RoadType,
                Edges.Count);

            Edges.Add(edge);

            startNode.Edges.Add(edge);
            endNode.Edges.Add(edge);
        }
Beispiel #2
0
        public void AddSegment(RoadTemplate template, MapObject start, MapObject end)
        {
            // ignore duplicate segments (e.g. in Alpine Assault)
            if (Edges.Any(e => (e.Start.Position == start.Position && e.End.Position == end.Position) ||
                          (e.End.Position == start.Position && e.Start.Position == end.Position)))
            {
                return;
            }

            var startNode = GetOrCreateNode(start.Position);
            var endNode   = GetOrCreateNode(end.Position);

            if (endNode == startNode)
            {
                // create a new dummy node, otherwise this edge gets counted twice as incoming edge of startNode
                // add a small offset to make sure that other map objects use the 'normal' node
                endNode = GetOrCreateNode(end.Position + 0.001f * Vector3.UnitX);
            }

            var edge = new RoadTopologyEdge(
                template,
                startNode,
                start.RoadType,
                endNode,
                end.RoadType,
                Edges.Count);

            Edges.Add(edge);

            startNode.Edges.Add(edge);
            endNode.Edges.Add(edge);
        }
Beispiel #3
0
 public RoadNetworkEdge(
     RoadTopologyEdge topologyEdge,
     RoadNetworkNode start,
     RoadNetworkNode end)
 {
     TopologyEdge = topologyEdge;
     Start        = start;
     End          = end;
 }
Beispiel #4
0
        private static IncomingRoadData GetIncomingRoadData(RoadTopologyNode node, RoadTopologyEdge incomingEdge)
        {
            var isStart            = incomingEdge.Start.Position == node.Position;
            var targetNodePosition = isStart ? incomingEdge.End.Position : incomingEdge.Start.Position;
            var roadVector         = targetNodePosition - node.Position;
            var direction          = roadVector.LengthSquared() < 0.01f ? Vector3.UnitX : Vector3.Normalize(roadVector);

            return(new IncomingRoadData(
                       incomingEdge,
                       targetNodePosition,
                       direction,
                       MathF.Atan2(direction.Y, direction.X)));
        }
Beispiel #5
0
        private static IncomingRoadData GetIncomingRoadData(RoadTopologyNode node, RoadTopologyEdge incomingEdge, StraightRoadSegment edgeSegment)
        {
            var isStart       = incomingEdge.Start.Position == node.Position;
            var fromPosition  = isStart ? edgeSegment.EndPosition : edgeSegment.StartPosition;
            var segmentVector = (edgeSegment.EndPosition - edgeSegment.StartPosition) * (isStart ? 1 : -1);
            var direction     = segmentVector.LengthSquared() < 0.01f ? Vector3.UnitX : Vector3.Normalize(segmentVector);

            return(new IncomingRoadData(
                       incomingEdge,
                       fromPosition,
                       direction,
                       MathF.Atan2(direction.Y, direction.X)));
        }
Beispiel #6
0
        public void AddEdge(RoadTopologyEdge topologyEdge)
        {
            var startNode = GetOrCreateNode(topologyEdge.Start);
            var endNode   = GetOrCreateNode(topologyEdge.End);

            var edge = new RoadNetworkEdge(
                topologyEdge,
                startNode,
                endNode);

            Edges.Add(edge);

            startNode.Edges.Add(edge);
            endNode.Edges.Add(edge);
        }
Beispiel #7
0
        public void AddSegment(RoadTemplate template, MapObject start, MapObject end)
        {
            var startNode = GetOrCreateNode(start);
            var endNode   = GetOrCreateNode(end);

            var edge = new RoadTopologyEdge(
                template,
                startNode,
                start.RoadType,
                endNode,
                end.RoadType);

            Edges.Add(edge);

            startNode.Edges.Add(edge);
            endNode.Edges.Add(edge);
        }
Beispiel #8
0
 public IncomingRoadData(
     RoadTopologyEdge topologyEdge,
     in Vector3 targetNodePosition,
Beispiel #9
0
 public IncomingRoadData(
     RoadTopologyEdge topologyEdge,
     RoadSegmentEndPoint targetEndPoint,
     in Vector3 outDirection,