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); } }
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(); }
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(); }
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; }