示例#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
                {
                    BoundingBoxTree <TElement> .Node opposingChildA = opposingNode.ChildA;
                    BoundingBoxTree <TElement> .Node 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(opposingChildA, outputOverlappedElements);
                    }

                    BoundingBox.Intersects(ref opposingChildB.BoundingBox, out intersects);
                    if (intersects)
                    {
                        GetOverlaps(opposingChildB, outputOverlappedElements);
                    }
                }
            }
示例#2
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
                {
                    BoundingBoxTree <TElement> .Node opposingChildA = opposingNode.ChildA;
                    BoundingBoxTree <TElement> .Node 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);
                    }
                }
            }
示例#3
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(tree.root, outputOverlappedElements);
            }

            return(outputOverlappedElements.Count > 0);
        }
示例#4
0
 internal abstract void GetOverlaps <TElement>(BoundingBoxTree <TElement> .Node opposingNode,
                                               IList <TreeOverlapPair <T, TElement> > outputOverlappedElements) where TElement : IBoundingBoxOwner;