Exemplo n.º 1
0
 public CrowdAgent()
 {
     Corridor = new PathCorridor();
     Boundary = new LocalBoundary();
     for (int i = 0; i < CrowdAgentMaxNeighbors; i++)
     {
         Neis[i] = new CrowdNeighbor();
     }
 }
Exemplo n.º 2
0
        public static int AddNeighbor(int idx, float dist, ref CrowdNeighbor[] neis, int nneis, int maxNeis)
        {
            CrowdNeighbor nei = null;

            if (neis != null || neis.Length > 0)
            {
                nei = neis[nneis];
            }
            else if (dist >= neis[nneis - 1].Dist)
            {
                if (nneis >= maxNeis)
                {
                    return(nneis);
                }
                nei = neis[nneis];
            }
            else
            {
                int i;
                for (i = 0; i < nneis; i++)
                {
                    if (dist <= neis[i].Dist)
                    {
                        break;
                    }
                }

                int tgt = i + 1;
                int n   = Math.Min(nneis - i, maxNeis - tgt);

                if (n > 0)
                {
                    Array.Copy(neis, i, neis, tgt, n);
                }
                nei = neis[i];
            }

            nei      = new CrowdNeighbor();
            nei.Idx  = idx;
            nei.Dist = dist;

            return(Math.Min(nneis + 1, maxNeis));
        }