public SphereQuery(MyVector3Grid <T> parent, ref Vector3 point, float dist) { this.m_parent = parent; this.m_point = point; this.m_distSq = dist * dist; Vector3 vector = new Vector3(dist); Vector3I binIndex = this.m_parent.GetBinIndex(((Vector3)point) - vector); Vector3I end = this.m_parent.GetBinIndex(((Vector3)point) + vector); this.m_rangeIterator = new Vector3I_RangeIterator(ref binIndex, ref end); this.m_previousIndex = -1; this.m_storageIndex = -1; }
public SphereQuery(MyVector3Grid <T> parent, ref Vector3 point, float dist) { m_parent = parent; m_point = point; m_distSq = dist * dist; Vector3 offset = new Vector3(dist); Vector3I start = m_parent.GetBinIndex(point - offset); Vector3I end = m_parent.GetBinIndex(point + offset); m_rangeIterator = new Vector3I_RangeIterator(ref start, ref end); m_previousIndex = -1; m_storageIndex = -1; }
public Enumerator(MyVector3Grid <T> parent, ref Vector3 point, float dist) { m_parent = parent; m_point = point; m_distSq = dist * dist; Vector3 offset = new Vector3(dist); Vector3I start = Vector3I.Floor((point - offset) * parent.m_divisor); Vector3I end = Vector3I.Floor((point + offset) * parent.m_divisor); m_rangeIterator = new Vector3I.RangeIterator(ref start, ref end); m_previousIndex = -1; m_storageIndex = -1; }
private bool FindFirstAcceptableEntry() { do { while (this.m_storageIndex != -1) { MyVector3Grid <T> .Entry entry = this.m_parent.m_storage[this.m_storageIndex]; Vector3 vector = entry.Point - this.m_point; if (vector.LengthSquared() < this.m_distSq) { return(true); } this.m_previousIndex = this.m_storageIndex; this.m_storageIndex = entry.NextEntry; } this.m_rangeIterator.MoveNext(); }while (this.FindNextNonemptyBin()); return(false); }
public bool RemoveCurrent() { this.m_storageIndex = this.m_parent.RemoveEntry(this.m_storageIndex); if (this.m_previousIndex == -1) { if (this.m_storageIndex == -1) { this.m_parent.m_bins.Remove(this.m_rangeIterator.Current); } else { this.m_parent.m_bins[this.m_rangeIterator.Current] = this.m_storageIndex; } } else { MyVector3Grid <T> .Entry entry = this.m_parent.m_storage[this.m_previousIndex]; entry.NextEntry = this.m_storageIndex; this.m_parent.m_storage[this.m_previousIndex] = entry; } return(this.FindFirstAcceptableEntry()); }