GetParent() public method

public GetParent ( GraphNode node ) : GraphNode
node GraphNode
return GraphNode
Beispiel #1
0
        /** Traces the calculated path from the start node to the end.
         * This will build an array (#path) of the nodes this path will pass through and also set the #vectorPath array to the #path arrays positions.
         * This implementation will use the #flood (FloodPath) to trace the path from precalculated data.
         */
        public void Trace(Node from)
        {
            Node c     = from;
            int  count = 0;

            while (c != null)
            {
                path.Add(c);
                vectorPath.Add((Vector3)c.position);
                c = flood.GetParent(c);

                count++;
                if (count > 1024)
                {
                    Debug.LogWarning("Inifinity loop? >1024 node path. Remove this message if you really have that long paths (FloodPathTracer.cs, Trace function)");
                    break;
                }
            }

            /*int count = 0;
             * NodeRun c = from;
             * while (c != null) {
             *      c = c.parent;
             *      count++;
             *      if (count > 1024) {
             *              Debug.LogWarning ("Inifinity loop? >1024 node path. Remove this message if you really have that long paths (FloodPathTracer.cs, Trace function)");
             *              break;
             *      }
             * }
             *
             * //path = new Node[count];
             * //Ensure capacities for lists
             * if (path.Capacity < count) path.Capacity = count;
             * if (vectorPath.Capacity < count) vectorPath.Capacity = count;
             *
             * c = from;
             *
             * for (int i = 0;i<count;i++) {
             *      //path[count-1-i] = c.node;
             *      path.Add (c.node);
             *      vectorPath.Add ((Vector3)c.node.position);
             *      c = c.parent;
             * }*/
        }
Beispiel #2
0
        /// <summary>
        /// Traces the calculated path from the start node to the end.
        /// This will build an array (<see cref="path)"/> of the nodes this path will pass through and also set the <see cref="vectorPath"/> array to the <see cref="path"/> arrays positions.
        /// This implementation will use the <see cref="flood"/> (FloodPath) to trace the path from precalculated data.
        /// </summary>
        public void Trace(GraphNode from)
        {
            GraphNode c     = from;
            int       count = 0;

            while (c != null)
            {
                path.Add(c);
                vectorPath.Add((Vector3)c.position);
                c = flood.GetParent(c);

                count++;
                if (count > 1024)
                {
                    Debug.LogWarning("Inifinity loop? >1024 node path. Remove this message if you really have that long paths (FloodPathTracer.cs, Trace function)");
                    break;
                }
            }
        }