Example #1
0
        public static TSBBox CreateMerged(TSBBox original, TSBBox additional)
        {
            TSBBox result;

            TSBBox.CreateMerged(ref original, ref additional, out result);
            return(result);
        }
Example #2
0
 protected void UpdateInternalBoundingBox()
 {
     this.mInternalBBox.min = new TSVector(FP.MaxValue);
     this.mInternalBBox.max = new TSVector(FP.MinValue);
     for (int i = 0; i < this.shapes.Length; i++)
     {
         this.shapes[i].UpdateBoundingBox();
         TSBBox.CreateMerged(ref this.mInternalBBox, ref this.shapes[i].boundingBox, out this.mInternalBBox);
     }
 }
Example #3
0
        private void RemoveLeaf(int leaf)
        {
            bool flag = leaf == this._root;

            if (flag)
            {
                this._root = -1;
            }
            else
            {
                int  num          = this._nodes[leaf].ParentOrNext;
                int  parentOrNext = this._nodes[num].ParentOrNext;
                bool flag2        = this._nodes[num].Child1 == leaf;
                int  num2;
                if (flag2)
                {
                    num2 = this._nodes[num].Child2;
                }
                else
                {
                    num2 = this._nodes[num].Child1;
                }
                bool flag3 = parentOrNext != -1;
                if (flag3)
                {
                    bool flag4 = this._nodes[parentOrNext].Child1 == num;
                    if (flag4)
                    {
                        this._nodes[parentOrNext].Child1 = num2;
                    }
                    else
                    {
                        this._nodes[parentOrNext].Child2 = num2;
                    }
                    this._nodes[num2].ParentOrNext = parentOrNext;
                    this.FreeNode(num);
                    for (num = parentOrNext; num != -1; num = this._nodes[num].ParentOrNext)
                    {
                        TSBBox.CreateMerged(ref this._nodes[this._nodes[num].Child1].AABB, ref this._nodes[this._nodes[num].Child2].AABB, out this._nodes[num].AABB);
                        Debug.Assert(this._nodes[num].LeafCount > 0);
                        DynamicTreeNode <T>[] expr_17E_cp_0_cp_0 = this._nodes;
                        int expr_17E_cp_0_cp_1 = num;
                        expr_17E_cp_0_cp_0[expr_17E_cp_0_cp_1].LeafCount = expr_17E_cp_0_cp_0[expr_17E_cp_0_cp_1].LeafCount - 1;
                    }
                }
                else
                {
                    this._root = num2;
                    this._nodes[num2].ParentOrNext = -1;
                    this.FreeNode(num);
                }
            }
        }
Example #4
0
        public override void GetBoundingBox(ref TSMatrix orientation, out TSBBox box)
        {
            TSBBox largeBox = TSBBox.LargeBox;
            int    num      = this.Prepare(ref largeBox);

            box = TSBBox.SmallBox;
            for (int i = 0; i < num; i++)
            {
                this.SetCurrentShape(i);
                base.GetBoundingBox(ref orientation, out largeBox);
                TSBBox.CreateMerged(ref box, ref largeBox, out box);
            }
        }
Example #5
0
        private void InsertLeaf(int leaf)
        {
            this._insertionCount++;
            bool flag = this._root == -1;

            if (flag)
            {
                this._root = leaf;
                this._nodes[this._root].ParentOrNext = -1;
            }
            else
            {
                TSBBox aABB = this._nodes[leaf].AABB;
                int    num  = this._root;
                while (!this._nodes[num].IsLeaf())
                {
                    int child  = this._nodes[num].Child1;
                    int child2 = this._nodes[num].Child2;
                    TSBBox.CreateMerged(ref this._nodes[num].AABB, ref aABB, out this._nodes[num].AABB);
                    DynamicTreeNode <T>[] expr_C2_cp_0_cp_0 = this._nodes;
                    int expr_C2_cp_0_cp_1 = num;
                    expr_C2_cp_0_cp_0[expr_C2_cp_0_cp_1].LeafCount = expr_C2_cp_0_cp_0[expr_C2_cp_0_cp_1].LeafCount + 1;
                    FP     perimeter = this._nodes[num].AABB.Perimeter;
                    TSBBox tSBBox    = default(TSBBox);
                    TSBBox.CreateMerged(ref this._nodes[num].AABB, ref aABB, out this._nodes[num].AABB);
                    FP   perimeter2 = tSBBox.Perimeter;
                    FP   x          = 2 * FP.One * perimeter2;
                    FP   y          = 2 * FP.One * (perimeter2 - perimeter);
                    bool flag2      = this._nodes[child].IsLeaf();
                    FP   fP;
                    if (flag2)
                    {
                        TSBBox tSBBox2 = default(TSBBox);
                        TSBBox.CreateMerged(ref aABB, ref this._nodes[child].AABB, out tSBBox2);
                        fP = tSBBox2.Perimeter + y;
                    }
                    else
                    {
                        TSBBox tSBBox3 = default(TSBBox);
                        TSBBox.CreateMerged(ref aABB, ref this._nodes[child].AABB, out tSBBox3);
                        FP perimeter3 = this._nodes[child].AABB.Perimeter;
                        FP perimeter4 = tSBBox3.Perimeter;
                        fP = perimeter4 - perimeter3 + y;
                    }
                    bool flag3 = this._nodes[child2].IsLeaf();
                    FP   y2;
                    if (flag3)
                    {
                        TSBBox tSBBox4 = default(TSBBox);
                        TSBBox.CreateMerged(ref aABB, ref this._nodes[child2].AABB, out tSBBox4);
                        y2 = tSBBox4.Perimeter + y;
                    }
                    else
                    {
                        TSBBox tSBBox5 = default(TSBBox);
                        TSBBox.CreateMerged(ref aABB, ref this._nodes[child2].AABB, out tSBBox5);
                        FP perimeter5 = this._nodes[child2].AABB.Perimeter;
                        FP perimeter6 = tSBBox5.Perimeter;
                        y2 = perimeter6 - perimeter5 + y;
                    }
                    bool flag4 = x < fP && x < y2;
                    if (flag4)
                    {
                        break;
                    }
                    TSBBox.CreateMerged(ref aABB, ref this._nodes[num].AABB, out this._nodes[num].AABB);
                    bool flag5 = fP < y2;
                    if (flag5)
                    {
                        num = child;
                    }
                    else
                    {
                        num = child2;
                    }
                }
                int parentOrNext = this._nodes[num].ParentOrNext;
                int num2         = this.AllocateNode();
                this._nodes[num2].ParentOrNext = parentOrNext;
                this._nodes[num2].UserData     = default(T);
                TSBBox.CreateMerged(ref aABB, ref this._nodes[num].AABB, out this._nodes[num2].AABB);
                this._nodes[num2].LeafCount = this._nodes[num].LeafCount + 1;
                bool flag6 = parentOrNext != -1;
                if (flag6)
                {
                    bool flag7 = this._nodes[parentOrNext].Child1 == num;
                    if (flag7)
                    {
                        this._nodes[parentOrNext].Child1 = num2;
                    }
                    else
                    {
                        this._nodes[parentOrNext].Child2 = num2;
                    }
                    this._nodes[num2].Child1       = num;
                    this._nodes[num2].Child2       = leaf;
                    this._nodes[num].ParentOrNext  = num2;
                    this._nodes[leaf].ParentOrNext = num2;
                }
                else
                {
                    this._nodes[num2].Child1       = num;
                    this._nodes[num2].Child2       = leaf;
                    this._nodes[num].ParentOrNext  = num2;
                    this._nodes[leaf].ParentOrNext = num2;
                    this._root = num2;
                }
            }
        }