예제 #1
0
파일: DynamicTree.cs 프로젝트: vb0067/LGame
        /// Query an AABB for overlapping proxies. The callback class
        /// is called for each proxy that overlaps the supplied AABB.
        public void Query(IQueryEnabled callback, AABB aabb)
        {
            const int k_stackSize = 128;

            int[] stack = new int[k_stackSize];

            int count = 0;

            stack[count++] = _root;

            while (count > 0)
            {
                int nodeId = stack[--count];
                if (nodeId == NullNode)
                {
                    continue;
                }

                DynamicTreeNode node = _nodes[nodeId];

                if (Collision.TestOverlap(node.Aabb, aabb))
                {
                    if (node.IsLeaf())
                    {
                        bool proceed = callback.QueryCallback(nodeId);
                        if (proceed == false)
                        {
                            return;
                        }
                    }
                    else
                    {
                        Box2DXDebug.Assert(count + 1 < k_stackSize);
                        stack[count++] = node.Child1;
                        stack[count++] = node.Child2;
                    }
                }
            }
        }
예제 #2
0
        /// Query an AABB for overlapping proxies. The callback class
        /// is called for each proxy that overlaps the supplied AABB.
        public void Query(IQueryEnabled callback, AABB aabb)
        {
            const int k_stackSize = 128;
            int[] stack = new int[k_stackSize];

            int count = 0;
            stack[count++] = _root;

            while (count > 0)
            {
                int nodeId = stack[--count];
                if (nodeId == NullNode)
                {
                    continue;
                }

                DynamicTreeNode node = _nodes[nodeId];

                if (Collision.TestOverlap(node.Aabb, aabb))
                {
                    if (node.IsLeaf())
                    {
                        bool proceed = callback.QueryCallback(nodeId);
                        if (proceed == false)
                        {
                            return;
                        }
                    }
                    else
                    {
                        Box2DXDebug.Assert(count + 1 < k_stackSize);
                        stack[count++] = node.Child1;
                        stack[count++] = node.Child2;
                    }
                }
            }
        }