Example #1
0
        public void Query(List <int> my, ref TSBBox aabb)
        {
            Stack <int> @new = this.stackPool.GetNew();

            @new.Push(this._root);
            while (@new.Count > 0)
            {
                int  num  = @new.Pop();
                bool flag = num == -1;
                if (!flag)
                {
                    DynamicTreeNode <T> dynamicTreeNode = this._nodes[num];
                    bool flag2 = aabb.Contains(ref dynamicTreeNode.AABB) > TSBBox.ContainmentType.Disjoint;
                    if (flag2)
                    {
                        bool flag3 = dynamicTreeNode.IsLeaf();
                        if (flag3)
                        {
                            my.Add(num);
                        }
                        else
                        {
                            @new.Push(dynamicTreeNode.Child1);
                            @new.Push(dynamicTreeNode.Child2);
                        }
                    }
                }
            }
            this.stackPool.GiveBack(@new);
        }
Example #2
0
        private int CountLeaves(int nodeId)
        {
            bool flag = nodeId == -1;
            int  result;

            if (flag)
            {
                result = 0;
            }
            else
            {
                Debug.Assert(0 <= nodeId && nodeId < this._nodeCapacity);
                DynamicTreeNode <T> dynamicTreeNode = this._nodes[nodeId];
                bool flag2 = dynamicTreeNode.IsLeaf();
                if (flag2)
                {
                    Debug.Assert(dynamicTreeNode.LeafCount == 1);
                    result = 1;
                }
                else
                {
                    int num  = this.CountLeaves(dynamicTreeNode.Child1);
                    int num2 = this.CountLeaves(dynamicTreeNode.Child2);
                    int num3 = num + num2;
                    Debug.Assert(num3 == dynamicTreeNode.LeafCount);
                    result = num3;
                }
            }
            return(result);
        }
Example #3
0
        public void Query(TSVector origin, TSVector direction, List <int> collisions)
        {
            Stack <int> @new = this.stackPool.GetNew();

            @new.Push(this._root);
            while (@new.Count > 0)
            {
                int num = @new.Pop();
                DynamicTreeNode <T> dynamicTreeNode = this._nodes[num];
                bool flag = dynamicTreeNode.AABB.RayIntersect(ref origin, ref direction);
                if (flag)
                {
                    bool flag2 = dynamicTreeNode.IsLeaf();
                    if (flag2)
                    {
                        collisions.Add(num);
                    }
                    else
                    {
                        bool flag3 = this._nodes[dynamicTreeNode.Child1].AABB.RayIntersect(ref origin, ref direction);
                        if (flag3)
                        {
                            @new.Push(dynamicTreeNode.Child1);
                        }
                        bool flag4 = this._nodes[dynamicTreeNode.Child2].AABB.RayIntersect(ref origin, ref direction);
                        if (flag4)
                        {
                            @new.Push(dynamicTreeNode.Child2);
                        }
                    }
                }
            }
            this.stackPool.GiveBack(@new);
        }
Example #4
0
        private int ComputeHeight(int nodeId)
        {
            bool flag = nodeId == -1;
            int  result;

            if (flag)
            {
                result = 0;
            }
            else
            {
                Debug.Assert(0 <= nodeId && nodeId < this._nodeCapacity);
                DynamicTreeNode <T> dynamicTreeNode = this._nodes[nodeId];
                int val  = this.ComputeHeight(dynamicTreeNode.Child1);
                int val2 = this.ComputeHeight(dynamicTreeNode.Child2);
                result = 1 + Math.Max(val, val2);
            }
            return(result);
        }