Exemple #1
0
        //MARK: Misc Functions

        public void GetBB(IObjectBox obj, IObjectBox dest)
        {
            //TODO: GETBB

            var velocityFunc = this.velocityFunc;

            if (velocityFunc != null)
            {
                float coef = 0.1f;
                float x    = (obj.bb.r - obj.bb.l) * coef;
                float y    = (obj.bb.t - obj.bb.b) * coef;

                var v = cpVect.cpvmult(velocityFunc(obj), 0.1f);

                dest.bb.l = obj.bb.l + cp.cpfmin(-x, v.x);
                dest.bb.b = obj.bb.b + cp.cpfmin(-y, v.y);
                dest.bb.r = obj.bb.r + cp.cpfmax(x, v.x);
                dest.bb.t = obj.bb.t + cp.cpfmax(y, v.y);
            }
            else
            {
                dest.bb.l = obj.bb.l;
                dest.bb.b = obj.bb.b;
                dest.bb.r = obj.bb.r;
                dest.bb.t = obj.bb.t;
            }
        }
Exemple #2
0
        public bool ContainsObj(IObjectBox obj)
        {
            if (obj == null)
            {
                return(false);
            }

            return(this.bb.l <= obj.bb.l && this.bb.r >= obj.bb.r && this.bb.b <= obj.bb.b && this.bb.t >= obj.bb.t);
        }
Exemple #3
0
        public Node(Node a, Node b, cpBBTree tree)
        {
            this.obj = null;

            bb = cpBB.Merge(a.bb, b.bb);

            parent = null;

            this.SetA(a);
            this.SetB(b);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cpBBTree"></param>
        /// <param name="value"></param>

        public Leaf(cpBBTree tree, IObjectBox obj)
            : base()
        {
            this.obj = obj;             //THIS IS THE GENERIC REAL VALUE

            tree.GetBB(obj, this);

            this.parent = null;

            this.STAMP = 1;
            this.PAIRS = null;

            cp.numLeaves++;
        }
Exemple #5
0
        public Leaf Insert(ulong hashid, IObjectBox obj)
        {
            Leaf leaf = new Leaf(this, obj);


            this.leaves.Add(hashid, leaf);

            Node root = this.root;

            this.root = SubtreeInsert(root, leaf);


            //this.root = cp.subtreeInsert(root, leaf, this);

            leaf.STAMP = GetStamp();
            leaf.AddPairs(this);             //.AddPairs(this);
            IncrementStamp();
            return(leaf);
        }
Exemple #6
0
        public cpBB GetBB(IObjectBox obj)
        {
            cpBB bb = obj.bb;

            var velocityFunc = this.velocityFunc;            // tree->velocityFunc;

            if (velocityFunc != null)
            {
                float coef = 0.1f;
                float x    = (bb.r - bb.l) * coef;
                float y    = (bb.t - bb.b) * coef;

                cpVect v = cpVect.cpvmult(velocityFunc(obj), 0.1f);
                return(new cpBB(bb.l + cp.cpfmin(-x, v.x), bb.b + cp.cpfmin(-y, v.y), bb.r + cp.cpfmax(x, v.x), bb.t + cp.cpfmax(y, v.y)));
            }
            else
            {
                return(bb);
            }
        }
Exemple #7
0
        public bool ContainsObj(IObjectBox obj)
        {
            if (obj == null)
                return false;

            return (this.bb.l <= obj.bb.l && this.bb.r >= obj.bb.r && this.bb.b <= obj.bb.b && this.bb.t >= obj.bb.t);
        }
Exemple #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cpBBTree"></param>
        /// <param name="value"></param>
        public Leaf(cpBBTree tree, IObjectBox obj)
            : base()
        {
            this.obj = obj; //THIS IS THE GENERIC REAL VALUE

            tree.GetBB(obj, this);

            this.parent = null;

            this.STAMP = 1;
            this.PAIRS = null;

            cp.numLeaves++;
        }
Exemple #9
0
        public Leaf Insert(ulong hashid, IObjectBox obj)
        {
            Leaf leaf = new Leaf(this, obj);

            this.leaves.Add(hashid, leaf);

            Node root = this.root;

            this.root = SubtreeInsert(root, leaf);

            //this.root = cp.subtreeInsert(root, leaf, this);

            leaf.STAMP = GetStamp();
            leaf.AddPairs(this); //.AddPairs(this);
            IncrementStamp();
            return leaf;
        }
Exemple #10
0
        //MARK: Misc Functions
        public void GetBB(IObjectBox obj, IObjectBox dest)
        {
            //TODO: GETBB

            var velocityFunc = this.velocityFunc;
            if (velocityFunc != null)
            {
                float coef = 0.1f;
                float x = (obj.bb.r - obj.bb.l) * coef;
                float y = (obj.bb.t - obj.bb.b) * coef;

                var v = cpVect.cpvmult(velocityFunc(obj), 0.1f);

                dest.bb.l = obj.bb.l + cp.cpfmin(-x, v.x);
                dest.bb.b = obj.bb.b + cp.cpfmin(-y, v.y);
                dest.bb.r = obj.bb.r + cp.cpfmax(x, v.x);
                dest.bb.t = obj.bb.t + cp.cpfmax(y, v.y);
            }
            else
            {
                dest.bb.l = obj.bb.l;
                dest.bb.b = obj.bb.b;
                dest.bb.r = obj.bb.r;
                dest.bb.t = obj.bb.t;
            }
        }
Exemple #11
0
        public cpBB GetBB(IObjectBox obj)
        {
            cpBB bb = obj.bb;

            var velocityFunc = this.velocityFunc;// tree->velocityFunc;
            if (velocityFunc != null)
            {
                float coef = 0.1f;
                float x = (bb.r - bb.l) * coef;
                float y = (bb.t - bb.b) * coef;

                cpVect v = cpVect.cpvmult(velocityFunc(obj), 0.1f);
                return new cpBB(bb.l + cp.cpfmin(-x, v.x), bb.b + cp.cpfmin(-y, v.y), bb.r + cp.cpfmax(x, v.x), bb.t + cp.cpfmax(y, v.y));
            }
            else
            {
                return bb;
            }
        }
Exemple #12
0
        public Node(Node a, Node b, cpBBTree tree)
        {
            this.obj = null;

            bb = cpBB.Merge(a.bb, b.bb);

            parent = null;

            this.SetA(a);
            this.SetB(b);
        }