Pathfinding.GridGraph.Scan C# (CSharp) Method

Scan() public method

public Scan ( ) : void
return void
        public override void Scan()
        {
            AstarPath.OnPostScan += new OnScanDelegate (OnPostScan);

            scans++;

            if (nodeSize <= 0) {
                return;
            }

            GenerateMatrix ();

            if (width > 1024 || depth > 1024) {
                Debug.LogError ("One of the grid's sides is longer than 1024 nodes");
                return;
            }

            //GenerateBounds ();

            /*neighbourOffsets = new int[8] {
                -width-1,-width,-width+1,
                -1,1,
                width-1,width,width+1
            }*/

            SetUpOffsetsAndCosts ();

            //GridNode.RemoveGridGraph (this);

            int gridIndex = GridNode.SetGridGraph (this);

            //graphNodes = new GridNode[width*depth];

            nodes = CreateNodes (width*depth);
            GridNode[] graphNodes = nodes as GridNode[];

            if (collision == null) {
                collision = new GraphCollision ();
            }
            collision.Initialize (matrix,nodeSize);

            //Max slope in cosinus
            //float cosAngle = Mathf.Cos (maxSlope*Mathf.Deg2Rad);

            for (int z = 0; z < depth; z ++) {
                for (int x = 0; x < width; x++) {

                    GridNode node = graphNodes[z*width+x];//new GridNode ();

                    node.SetIndex (z*width+x);

                    UpdateNodePositionCollision (node,x,z);

                    /*node.position = matrix.MultiplyPoint3x4 (new Vector3 (x+0.5F,0,z+0.5F));

                    RaycastHit hit;

                    bool walkable = true;

                    node.position = collision.CheckHeight (node.position, out hit, out walkable);

                    node.penalty = 0;//Mathf.RoundToInt (Random.value*100);

                    //Check if the node is on a slope steeper than permitted
                    if (walkable && useRaycastNormal && collision.heightCheck) {

                        if (hit.normal != Vector3.zero) {
                            //Take the dot product to find out the cosinus of the angle it has (faster than Vector3.Angle)
                            float angle = Vector3.Dot (hit.normal.normalized,Vector3.up);

                            if (angle < cosAngle) {
                                walkable = false;
                            }
                        }
                    }

                    //If the walkable flag has already been set to false, there is no point in checking for it again
                    if (walkable) {
                        node.walkable = collision.Check (node.position);
                    } else {
                        node.walkable = walkable;
                    }*/

                    node.SetGridIndex (gridIndex);
                }
            }

            for (int z = 0; z < depth; z ++) {
                for (int x = 0; x < width; x++) {

                    GridNode node = graphNodes[z*width+x];

                    CalculateConnections (nodes,x,z,node);

                }
            }

            ErodeWalkableArea ();
            //Assign the nodes to the main storage

            //startIndex = AstarPath.active.AssignNodes (graphNodes);
            //endIndex = startIndex+graphNodes.Length;
        }