/// <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); }
/// <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; }
/// <summary> /// /// </summary> /// <param name="sector"></param> public void RegisterSector(Sector sector) { AllSectors.AddLast(sector); }