Example #1
0
        /// <summary>
        /// Not thread safe. Be sure no threads are accessing data
        /// </summary>
        public void Clear()
        {
            foreach (Sector sector in AllSectors)
            {
                sector.Clear();
            }

            AllSectors.Clear();
            _blackHoles.Clear();
            _allStars.Clear();

            _root = new Sector(this, MaxStarsPerSector, 0);
            RegisterSector(_root);
        }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        private void DivideAndConquer()
        {
            StarBufferIndex star;

            _children = new Sector[8];

            for (int a = 0; a < 8; a++)
            {
                _children[a] = new Sector(_universe, MaxStarsPerSector, CurrentLevel + 1);
                _universe.RegisterSector(_children[a]);
            }

            _averageX = _aggregateStarPosition.X / MaxStarsPerSector;
            _averageY = _aggregateStarPosition.Y / MaxStarsPerSector;
            _averageZ = _aggregateStarPosition.Z / MaxStarsPerSector;

            while (_stars.Count > 0)
            {
                star = _stars.First.Value;

                GetAppropriateChildSector(star).AddStar(star);

                _stars.RemoveFirst();
            }

            _stars.Clear();
            _stars = null;
        }
Example #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sector"></param>
 public void RegisterSector(Sector sector)
 {
     AllSectors.AddLast(sector);
 }