示例#1
0
文件: QuadTree.cs 项目: emncan/Demo
    private void Split()
    {
        var hx = _bounds.width / 2;
        var hz = _bounds.height / 2;
        var sz = new Vector2(hx, hz);

        //split a
        var aLoc  = _bounds.position;
        var aRect = new Rect(aLoc, sz);
        //split b
        var bLoc  = new Vector2(_bounds.position.x + hx, _bounds.position.y);
        var bRect = new Rect(bLoc, sz);
        //split c
        var cLoc  = new Vector2(_bounds.position.x + hx, _bounds.position.y + hz);
        var cRect = new Rect(cLoc, sz);
        //split d
        var dLoc  = new Vector2(_bounds.position.x, _bounds.position.y + hz);
        var dRect = new Rect(dLoc, sz);

        //assign QuadTrees
        _childA = QuadTreePool.GetQuadTree(aRect, this);
        _childB = QuadTreePool.GetQuadTree(bRect, this);
        _childC = QuadTreePool.GetQuadTree(cRect, this);
        _childD = QuadTreePool.GetQuadTree(dRect, this);

        for (int i = _bodies.Count - 1; i >= 0; i--)
        {
            var child = GetQuadrant(_bodies[i].Position);
            child.AddBody(_bodies[i]);
            _bodies.RemoveAt(i);
        }
    }
示例#2
0
文件: QuadTree.cs 项目: emncan/Demo
 public void Clear()
 {
     QuadTreePool.PoolQuadTree(_childA);
     QuadTreePool.PoolQuadTree(_childB);
     QuadTreePool.PoolQuadTree(_childC);
     QuadTreePool.PoolQuadTree(_childD);
     _childA = null;
     _childB = null;
     _childC = null;
     _childD = null;
     _bodies.Clear();
 }
示例#3
0
 public void Clear()
 {
     QuadTreePool.PoolQuadTree(this.childA);
     QuadTreePool.PoolQuadTree(this.childB);
     QuadTreePool.PoolQuadTree(this.childC);
     QuadTreePool.PoolQuadTree(this.childD);
     this.childA = null;
     this.childB = null;
     this.childC = null;
     this.childD = null;
     this.bodies.Clear();
 }
示例#4
0
        public UITextElement(UIManager manager, BitmapFont font) : base(manager)
        {
            _font    = font;
            _segment = new TextSegment(font);
            _segment.GlyphCallback = GlyphCallback;
            _quadTree = QuadTreePool <CharSpriteInfo> .Rent(RectangleF.Empty, threshold : 2, allowOverflow : true, fuzzyBoundaries : true);

            Color               = Color.White;
            CaretColor          = Color.Orange;
            HorizontalAlignment = TextHorizontalAlignment.Left;
            VerticalAlignment   = TextVerticalAlignment.Top;

            IsShadowed    = false;
            ShadowColor   = new Color(Color.Black, 0.75f);
            ShadowSpacing = new ThicknessF(2, -1, 2, -1);

            IsMouseEventTrigger = true;
            OnMouseDown        += UITextElement_OnMousePress;
        }