Exemplo n.º 1
0
        public Sector3D <T> CreateSector(ref Int3 s)
        {
            var sector = new Sector3D <T>();

            sector.bounds = new Bounds(new Vector3(s.x * sectorSize.x, s.y * sectorSize.y, s.z * sectorSize.z) + (sectorGridOffset - halfTotalSize), sectorSize);

            sectors[s.x, s.y, s.z] = sector;
            sectorList.Add(sector);
            return(sector);
        }
Exemplo n.º 2
0
        public void DrawSectors(FastList <Sector3D <T> > sectors, Color color)
        {
            Gizmos.color = color;

            for (int i = 0; i < sectors.Count; i++)
            {
                Sector3D <T> sector = sectors.items[i];
                Bounds       bounds = sector.bounds;
                Gizmos.DrawWireCube(bounds.center, bounds.size);
            }
        }
Exemplo n.º 3
0
        public void GetOrCreateSector(Vector3 pos, out Sector3D <T> sector)
        {
            Int3 s = GetSectorIndex(pos);

            // Debug.Log("Cell " + c.ToString() + " " + pos);

            sector = sectors[s.x, s.y, s.z];
            if (sector == null)
            {
                sector = CreateSector(ref s);
            }
        }
Exemplo n.º 4
0
        public void Reset()
        {
            //for (int y = 0; y < sectorCount.y; y++)
            //{
            //    for (int x = 0; x < sectorCount.x; x++)
            //    {
            //        sectors[x, y] = null;
            //    }
            //}
            sectors = new Sector3D <T> [sectorCount.y, sectorCount.x, sectorCount.z];

            sectorList.Clear();
        }
Exemplo n.º 5
0
        public SectorGrid3D(Int3 sectorCount, Vector3 sectorSize, Vector3 sectorGridOffset)
        {
            sectors               = new Sector3D <T> [sectorCount.x, sectorCount.y, sectorCount.z];
            this.sectorCount      = sectorCount;
            this.sectorSize       = sectorSize;
            this.sectorGridOffset = sectorGridOffset;

            invSectorSize  = Mathw.Divide(1.0f, sectorSize);
            halfSectorSize = sectorSize / 2;

            totalSize     = Mathw.Scale(sectorSize, sectorCount);
            halfTotalSize = totalSize * 0.5f;

            rect = new Rect(sectorGridOffset - halfTotalSize, totalSize);
        }