Exemplo n.º 1
0
 private void considerForGVD(GridCell cell)
 {
     foreach (GridCell adj in grid.Get8Neighbors(cell))
     {
         if (obst[cell.C, cell.R] != obst[adj.C, adj.R])
         {
             tie[cell.C, cell.R] = adj;
             ties.Add(cell);
         }
     }
 }
Exemplo n.º 2
0
        private void updateDistanceMap()
        {
            while (!open.IsEmpty)
            {
                GridCell s = open.DeleteMin().Position;
                if (!toProcess[s.C, s.R])
                {
                    continue;
                }

                if (toRaise[s.C, s.R])
                {
                    // raise(s)
                    foreach (GridCell n in grid.Get8Neighbors(s))
                    {
                        if (obst[n.C, n.R] != GridCell.Unknown && !toRaise[n.C, n.R])
                        {
                            if (!isOcc(obst[n.C, n.R]))
                            {
                                dist[n.C, n.R]       = int.MaxValue;
                                distActual[n.C, n.R] = float.PositiveInfinity;
                                obst[n.C, n.R]       = GridCell.Unknown;
                                toRaise[n.C, n.R]    = true;
                            }

                            open.Add(new GridCellValue(n, dist[n.C, n.R]));
                            toProcess[n.C, n.R] = true;
                        }
                    }

                    toRaise[s.C, s.R] = false;
                }
                else if (isOcc(obst[s.C, s.R]))
                {
                    voro[s.C, s.R] = false;
                    unsetVoro(s);
                    toProcess[s.C, s.R] = false;

                    // lower(s)
                    foreach (GridCell n in grid.Get8Neighbors(s))
                    {
                        if (!toRaise[n.C, n.R])
                        {
                            int d = distanceSquared(obst[s.C, s.R], n);
                            if (d < dist[n.C, n.R])
                            {
                                dist[n.C, n.R]       = d;
                                distActual[n.C, n.R] = (float)Math.Sqrt(d);
                                obst[n.C, n.R]       = obst[s.C, s.R];
                                open.Add(new GridCellValue(n, d));
                                toProcess[n.C, n.R] = true;
                            }
                            else
                            {
                                chkVoro(s, n);
                            }
                        }
                    }
                }
            }
        }