/* Sometimes it happens that we split the road too close to another segment. If that occur, the roads do glitch. In that case
         * we remove one more segment up the road. This method is still glitchy, would need improvement. */
        /* intersection - node outside the ellipse */
        private bool nextSegmentInfo(WrappedSegment closeSegmentW, ref WrappedNode outerNodeW, ref Vector3 endDirection)
        {
            NetSegment closeSegment = closeSegmentW.Get;
            //outerNodeId = 0;
            //directions = new Vector3(0,0,0);
            NetNode node         = outerNodeW.Get;
            int     segmentcount = node.CountSegments();

            /* If there is an intersection right behind the ellipse, we can't go on as we can merge only segments which are in fact
             * only one road without an intersection. */
            if (segmentcount != 2)
            {
                //Debug.Log("Ambiguous node.");
                return(false);
            }

            /*string debugString = "Close segment id: " + closeSegmentId + "; ";
             * for(int i = 0; i < 8; i++)
             * {
             *  debugString += node.GetSegment(i) + ", ";
             * }
             * Debug.Log(debugString);*/
            ushort nextSegmentId = NetUtil.GetNonzeroSegment(node, 0);

            /* We need the segment that goes away from the ellipse, not the one we already have. */
            if (closeSegmentW.Id == nextSegmentId)
            {
                //Debug.Log("Taking the other of the two segments. " + node.GetSegment(1));
                nextSegmentId = NetUtil.GetNonzeroSegment(node, 1);
                if (nextSegmentId == 0)
                {
                    return(false);
                }
            }
            NetSegment nextSegment = NetUtil.Segment(nextSegmentId);

            ushort  outerNodeId = nextSegment.m_startNode;
            Vector3 directions  = nextSegment.m_startDirection;

            /* We need the node further away */
            if (outerNodeId == outerNodeW.Id)
            {
                //Debug.Log("Taking the other of the nodes.");
                outerNodeId = nextSegment.m_endNode;
                directions  = nextSegment.m_endDirection;
                if (outerNodeId == 0)
                {
                    return(false);
                }
            }

            WrappedSegment nextSegmentW = networkDictionary.RegisterSegment(nextSegmentId);

            // Release old
            ToBeReleasedNodes.Add(outerNodeW);
            ToBeReleasedSegments.Add(nextSegmentW);

            // Return values
            outerNodeW   = networkDictionary.RegisterNode(outerNodeId);
            endDirection = directions;

            /* After merging the roads, we release the segment and intersection inbetween. When I was debugging this method, I tried to release them after
             * everything is done. It might not be necessary.*/
            return(true);
        }