Esempio n. 1
0
        public override void Initialize()
        {
            PathNode startRNode = pathHandler.GetPathNode(startNode);

            startRNode.node    = startNode;
            startRNode.pathID  = pathHandler.PathID;
            startRNode.parent  = null;
            startRNode.cost    = 0;
            startRNode.G       = GetTraversalCost(startNode);
            startRNode.H       = CalculateHScore(startNode);
            parents[startNode] = null;

            startNode.Open(this, startRNode, pathHandler);

            searchedNodes++;

            // Any nodes left to search?
            if (pathHandler.HeapEmpty())
            {
                CompleteState = PathCompleteState.Complete;
            }

            currentR = pathHandler.PopNode();
        }
Esempio n. 2
0
        public override void Initialize()
        {
            // Mark nodes to enable special connection costs for start and end nodes
            // See GetConnectionSpecialCost
            if (startNode != null)
            {
                pathHandler.GetPathNode(startNode).flag2 = true;
            }
            if (endNode != null)
            {
                pathHandler.GetPathNode(endNode).flag2 = true;
            }

            if (hasEndPoint && startNode == endNode)
            {
                PathNode endNodeR = pathHandler.GetPathNode(endNode);
                endNodeR.node   = endNode;
                endNodeR.parent = null;
                endNodeR.H      = 0;
                endNodeR.G      = 0;
                Trace(endNodeR);
                CompleteState = PathCompleteState.Complete;
                return;
            }

            //Adjust the costs for the end node

            /*if (hasEndPoint && recalcStartEndCosts) {
             *      endNodeCosts = endNode.InitialOpen (open,hTarget,(Int3)endPoint,this,false);
             *      callback += ResetCosts; /* \todo Might interfere with other paths since other paths might be calculated before #callback is called *
             * }*/

            PathNode startRNode = pathHandler.GetPathNode(startNode);

            startRNode.node   = startNode;
            startRNode.pathID = pathHandler.PathID;
            startRNode.parent = null;
            startRNode.cost   = 0;
            startRNode.G      = GetTraversalCost(startNode);
            startRNode.H      = CalculateHScore(startNode);

            /*if (recalcStartEndCosts) {
             *      startNode.InitialOpen (open,hTarget,startIntPoint,this,true);
             * } else {*/
            startNode.Open(this, startRNode, pathHandler);
            //}

            searchedNodes++;

            partialBestTarget = startRNode;

            //any nodes left to search?
            if (pathHandler.HeapEmpty())
            {
                if (calculatePartial)
                {
                    CompleteState = PathCompleteState.Partial;
                    Trace(partialBestTarget);
                }
                else
                {
                    Error();
                    LogError("No open points, the start node didn't open any nodes");
                    return;
                }
            }

            currentR = pathHandler.PopNode();
        }