Пример #1
0
            internal override void GetOverlaps <TElement>(BoundingBoxTree <TElement> .Node opposingNode, IList <TreeOverlapPair <T, TElement> > outputOverlappedElements)
            {
                bool intersects;

                if (opposingNode.IsLeaf)
                {
                    //We're both leaves!  Our parents have already done the testing for us, so we know we're overlapping.
                    outputOverlappedElements.Add(new TreeOverlapPair <T, TElement>(element, opposingNode.Element));
                }
                else
                {
                    var opposingChildA = opposingNode.ChildA;
                    var opposingChildB = opposingNode.ChildB;
                    //If it's not a leaf, try to go deeper in the opposing hierarchy.
                    BoundingBox.Intersects(ref opposingChildA.BoundingBox, out intersects);
                    if (intersects)
                    {
                        GetOverlaps <TElement>(opposingChildA, outputOverlappedElements);
                    }
                    BoundingBox.Intersects(ref opposingChildB.BoundingBox, out intersects);
                    if (intersects)
                    {
                        GetOverlaps <TElement>(opposingChildB, outputOverlappedElements);
                    }
                }
            }
Пример #2
0
        /// <summary>
        /// Gets the pairs of elements in each tree with overlapping bounding boxes.
        /// </summary>
        /// <typeparam name="TElement">Type of the elements in the opposing tree.</typeparam>
        /// <param name="tree">Other tree to test.</param>
        /// <param name="outputOverlappedElements">List of overlaps found by the query.</param>
        /// <returns>Whether or not any overlaps were found.</returns>
        public bool GetOverlaps <TElement>(BoundingBoxTree <TElement> tree, IList <TreeOverlapPair <T, TElement> > outputOverlappedElements)
            where TElement : IBoundingBoxOwner
        {
            bool intersects;

            root.BoundingBox.Intersects(ref tree.root.BoundingBox, out intersects);
            if (intersects)
            {
                root.GetOverlaps <TElement>(tree.root, outputOverlappedElements);
            }
            return(outputOverlappedElements.Count > 0);
        }
Пример #3
0
            internal override void GetOverlaps <TElement>(BoundingBoxTree <TElement> .Node opposingNode, IList <TreeOverlapPair <T, TElement> > outputOverlappedElements)
            {
                bool intersects;

                if (opposingNode.IsLeaf)
                {
                    //If it's a leaf, go deeper in our hierarchy, but not the opposition.
                    childA.BoundingBox.Intersects(ref opposingNode.BoundingBox, out intersects);
                    if (intersects)
                    {
                        childA.GetOverlaps(opposingNode, outputOverlappedElements);
                    }
                    childB.BoundingBox.Intersects(ref opposingNode.BoundingBox, out intersects);
                    if (intersects)
                    {
                        childB.GetOverlaps(opposingNode, outputOverlappedElements);
                    }
                }
                else
                {
                    var opposingChildA = opposingNode.ChildA;
                    var opposingChildB = opposingNode.ChildB;
                    //If it's not a leaf, try to go deeper in both hierarchies.
                    childA.BoundingBox.Intersects(ref opposingChildA.BoundingBox, out intersects);
                    if (intersects)
                    {
                        childA.GetOverlaps(opposingChildA, outputOverlappedElements);
                    }
                    childA.BoundingBox.Intersects(ref opposingChildB.BoundingBox, out intersects);
                    if (intersects)
                    {
                        childA.GetOverlaps(opposingChildB, outputOverlappedElements);
                    }
                    childB.BoundingBox.Intersects(ref opposingChildA.BoundingBox, out intersects);
                    if (intersects)
                    {
                        childB.GetOverlaps(opposingChildA, outputOverlappedElements);
                    }
                    childB.BoundingBox.Intersects(ref opposingChildB.BoundingBox, out intersects);
                    if (intersects)
                    {
                        childB.GetOverlaps(opposingChildB, outputOverlappedElements);
                    }
                }
            }
Пример #4
0
 internal abstract void GetOverlaps <TElement>(BoundingBoxTree <TElement> .Node opposingNode, IList <TreeOverlapPair <T, TElement> > outputOverlappedElements) where TElement : IBoundingBoxOwner;