Exemple #1
0
        public bool OverlapBox(OBB box, List <SphereTreeNode <T> > nodes)
        {
            nodes.Clear();
            if (_root == null)
            {
                return(false);
            }

            _root.StackPush(_root);
            while (_root.StackTop != null)
            {
                var node = _root.StackPop();
                if (!node.IsLeaf)
                {
                    if (SphereMath.ContainsPoint(box.GetClosestPoint(node.Center), node.Center, node.Radius))
                    {
                        if (SphereMath.ContainsPoint(box.GetClosestPoint(node.Children[0].Center), node.Children[0].Center, node.Children[0].Radius))
                        {
                            _root.StackPush(node.Children[0]);
                        }
                        if (node.Children[1] != null && SphereMath.ContainsPoint(box.GetClosestPoint(node.Children[1].Center), node.Children[1].Center, node.Children[1].Radius))
                        {
                            _root.StackPush(node.Children[1]);
                        }
                    }
                }
                else
                {
                    if (SphereMath.ContainsPoint(box.GetClosestPoint(node.Center), node.Center, node.Radius))
                    {
                        nodes.Add(node);
                    }
                }
            }

            return(nodes.Count != 0);
        }
 public bool ContainsPoint(Vector3 point)
 {
     return(SphereMath.ContainsPoint(point, _center, _radius, _epsilon));
 }