Ejemplo n.º 1
0
            protected override bool OnNext(out int current)
            {
                var nodes = _compressedAabbTree._nodes;

                if (nodes != null)
                {
                    while (_index < nodes.Length)
                    {
                        Node node        = nodes[_index];
                        bool haveContact = GeometryHelper.HaveContact(_compressedAabbTree.GetAabb(node), _ray.Origin, _rayDirectionInverse, _ray.Length, _epsilon);

                        if (haveContact || node.IsLeaf)
                        {
                            _index++;
                        }
                        else
                        {
                            _index += node.EscapeOffset;
                        }

                        if (haveContact && node.IsLeaf)
                        {
                            current = node.Item;
                            return(true);
                        }
                    }
                }
                current = 0;
                return(false);
            }
Ejemplo n.º 2
0
            protected override bool OnNext(out Node current)
            {
                var nodes = _compressedAabbTree._nodes;

                if (nodes != null)
                {
                    while (_index < nodes.Length)
                    {
                        Node node        = nodes[_index];
                        bool haveContact = GeometryHelper.HaveContact(_compressedAabbTree.GetAabb(node), _aabb);

                        if (haveContact || node.IsLeaf)
                        {
                            _index++;
                        }
                        else
                        {
                            _index += node.EscapeOffset;
                        }

                        if (haveContact && node.IsLeaf)
                        {
                            current = node;
                            return(true);
                        }
                    }
                }
                current = default(Node);
                return(false);
            }
Ejemplo n.º 3
0
            protected override bool OnNext(out Pair <int> current)
            {
                while (true)
                {
                    if (_otherCandidates == null)
                    {
                        if (_leafNodes.MoveNext())
                        {
                            var  leaf     = _leafNodes.Current;
                            Aabb leafAabb = _partition.GetAabb(leaf);
                            _otherCandidates = _otherPartition.GetOverlaps(leafAabb).GetEnumerator();
                        }
                        else
                        {
                            current = default(Pair <int>);
                            return(false);
                        }
                    }

                    while (_otherCandidates.MoveNext())
                    {
                        var leaf           = _leafNodes.Current;
                        var otherCandidate = _otherCandidates.Current;
                        var overlap        = new Pair <int>(leaf.Item, otherCandidate);
                        if (_partition.Filter == null || _partition.Filter.Filter(overlap))
                        {
                            current = overlap;
                            return(true);
                        }
                    }

                    _otherCandidates.Dispose();
                    _otherCandidates = null;
                }
            }