Esempio n. 1
0
 public void Add(PosTab tab)
 /// Combines two hash sets in current
 {
     foreach (Transition trs in tab.All())
     {
         Add(trs);
     }
 }
Esempio n. 2
0
        public PosTab Copy()
        {
            PosTab copy = new PosTab(pos, size, resolution);

            for (int c = 0; c < cells.arr.Length; c++)
            {
                copy.cells.arr[c].count = cells.arr[c].count;
                copy.cells.arr[c].rect  = cells.arr[c].rect;

                if (cells.arr[c].poses == null)
                {
                    continue;
                }
                copy.cells.arr[c].poses = new Transition[cells.arr[c].poses.Length];
                Array.Copy(cells.arr[c].poses, copy.cells.arr[c].poses, cells.arr[c].poses.Length);
            }
            copy.totalCount = totalCount;
            copy.idCounter  = idCounter;
            return(copy);
        }
Esempio n. 3
0
        public void FillPosTab(PosTab posTab, float minHeight = -200000000)
        /// Copy all of the positions to posTab, skipping objects that out of range and those who have height below minHeight
        {
            Coord min = rect.Min; Coord max = rect.Max;

            for (int x = min.x; x < max.x; x++)
            {
                for (int z = min.z; z < max.z; z++)
                {
                    Vector3 pos = this[x, z];

                    //skipping out of cell
                    if (pos.x < x * cellSize || pos.x > (x + 1) * cellSize ||
                        pos.z < z * cellSize || pos.z > (z + 1) * cellSize)
                    {
                        continue;
                    }

                    //skipping out of range
                    if (pos.x < posTab.pos.x || pos.x > posTab.pos.x + posTab.size.x ||
                        pos.z < posTab.pos.z || pos.z > posTab.pos.z + posTab.size.z)
                    {
                        continue;
                    }

                    //skipping height
                    if (pos.y < minHeight)
                    {
                        continue;
                    }

                    Transition trs = new Transition(pos.x, pos.z);
                    trs.hash = x * 2000 + z;                   //to make hash independent from grid size
                    posTab.Add(trs);
                }
            }
        }
Esempio n. 4
0
        public static PosTab Combine(params PosTab[] posTabs)
        //NOTE: combine ids are not unique
        {
            if (posTabs.Length == 0)
            {
                return(null);
            }

            PosTab any = ArrayTools.Any(posTabs);

            if (any == null)
            {
                return(null);
            }
            PosTab result = new PosTab(any.pos, any.size, any.resolution);

            for (int i = 0; i < posTabs.Length; i++)
            {
                PosTab posTab = posTabs[i];
                if (posTab == null)
                {
                    continue;
                }

                for (int c = 0; c < posTab.cells.arr.Length; c++)
                {
                    Cell cell = posTab.cells.arr[c];
                    for (int p = 0; p < cell.count; p++)
                    {
                        result.Add(cell.poses[p]);
                    }
                }
            }

            return(result);
        }