public virtual void Receive(IQtUserData userData) { if (!UQtAlgo.Intersects(Bound, userData)) { return; } foreach (var sub in SubNodes) { sub.Receive(userData); } }
private void PerformSwapInOut(UQtLeaf activeLeaf) { // 1. the initial in/out leaves generation List <UQtLeaf> inLeaves; List <UQtLeaf> outLeaves; UQtAlgo.GenerateSwappingLeaves(_root, activeLeaf, _holdingLeaves, out inLeaves, out outLeaves); // 2. filter out leaves which are already in the ideal states inLeaves.RemoveAll((leaf) => { return(_swapInQueue.Contains(leaf)); }); // 3. append these new items to in/out queue SwapIn(inLeaves); SwapOut(outLeaves); }
public override void Receive(IQtUserData userData) { if (!UQtAlgo.Intersects(Bound, userData)) { return; } if (Bound.Contains(new Vector2(userData.GetCenter().x, userData.GetCenter().z))) { _ownedObjects.Add(userData); } else { _affectedObjects.Add(userData); } }
private bool UpdateFocus(Vector2 focusPoint) { _focusPoint = focusPoint; UQtLeaf newLeaf = UQtAlgo.FindLeafRecursively(_root, _focusPoint); if (newLeaf == _focusLeaf) { return(false); } if (FocusCellChanged != null) { FocusCellChanged(_focusLeaf, newLeaf); } _focusLeaf = newLeaf; return(true); }
private void DrawDebugLines() { UQtAlgo.TraverseAllLeaves(_root, (leaf) => { Color c = Color.gray; if (leaf == _focusLeaf) { c = Color.blue; } else if (_swapInQueue.Contains(leaf)) { c = Color.green; } else if (_swapOutQueue.Contains(leaf)) { c = Color.red; } else if (_holdingLeaves.Contains(leaf)) { c = Color.white; } UCore.DrawRect(leaf.Bound, 0.1f, c, 1.0f); }); }
public UQuadtree(Rect bound) { _root = new UQtNode(bound); UQtAlgo.BuildRecursively(_root); }