public PathFinderFast(Cell[] grid, int gridWidth, int gridHeight)
        {
            if (grid == null)
            {
                throw new Exception("Grid cannot be null");
            }

            mGrid        = grid;
            mGridX       = (ushort)gridWidth;                 // (ushort) (mGrid.GetUpperBound(0) + 1);
            mGridY       = (ushort)gridHeight;                // (ushort) (mGrid.GetUpperBound(1) + 1);
            mGridXMinus1 = (ushort)(mGridX - 1);
            mGridYLog2   = (ushort)Math.Log(mGridX, 2);

            // This should be done at the constructor, for now we leave it here.
            if (Math.Log(mGridX, 2) != (int)Math.Log(mGridX, 2))
            {
                throw new Exception("Invalid Grid, size in X must be power of 2");
            }

            if (mCalcGrid == null || mCalcGrid.Length != (mGridX * mGridY))
            {
                mCalcGrid = new PathFinderNodeFast[mGridX * mGridY];
            }

            mOpen = new PriorityQueueB <int>(new ComparePFNodeMatrix(mCalcGrid));
        }
Exemplo n.º 2
0
        public PathFinderFastNonSQR(Cell[] grid, int gridWidth, int gridHeight)
        {
            if (grid == null)
            {
                throw new Exception("Grid cannot be null");
            }

            mGrid  = grid;
            mGridX = (ushort)gridWidth;                       // (ushort) (mGrid.GetUpperBound(0) + 1);
            mGridY = (ushort)gridHeight;                      // (ushort) (mGrid.GetUpperBound(1) + 1);

            if (mCalcGrid == null || mCalcGrid.Length != (mGridX * mGridY))
            {
                mCalcGrid = new PathFinderNodeFast[mGridX * mGridY];
            }

            mOpen = new PriorityQueueB <int>(new ComparePFNodeMatrix(mCalcGrid));
        }