protected override bool OnNext(out Pair <T> current)
            {
                while (true)
                {
                    if (_otherCandidates == null)
                    {
                        if (_candidates.MoveNext())
                        {
                            var  candidate     = _candidates.Current;
                            Aabb candidateAabb = _partition.GetAabbForItem(candidate);
                            _otherCandidates = _otherPartition.GetOverlaps(candidateAabb).GetEnumerator();
                        }
                        else
                        {
                            current = default(Pair <T>);
                            return(false);
                        }
                    }

                    while (_otherCandidates.MoveNext())
                    {
                        var candidate      = _candidates.Current;
                        var otherCandidate = _otherCandidates.Current;
                        var overlap        = new Pair <T>(candidate, otherCandidate);
                        if (_partition.Filter == null || _partition.Filter.Filter(overlap))
                        {
                            current = overlap;
                            return(true);
                        }
                    }

                    _otherCandidates.Dispose();
                    _otherCandidates = null;
                }
            }
            public static IEnumerable <T> Create(BasePartition <T> partition, T item)
            {
                var enumerable = Pool.Obtain();

                enumerable._partition = partition;
                enumerable._item      = item;
                Aabb aabb = partition.GetAabbForItem(item);

                enumerable._enumerator = partition.GetOverlaps(aabb).GetEnumerator();
                return(enumerable);
            }
 protected override bool OnNext(out T current)
 {
     while (_enumerator.MoveNext())
     {
         var candidate = _enumerator.Current;
         if (GeometryHelper.HaveContact(_partition.GetAabbForItem(candidate), _ray.Origin, _rayDirectionInverse, _ray.Length, _epsilon))
         {
             current = candidate;
             return(true);
         }
     }
     current = default(T);
     return(false);
 }