Exemplo n.º 1
0
    public virtual void Receive(IQtUserData userData)
    {
        if (!UQtAlgo.Intersects(Bound, userData))
        {
            return;
        }

        foreach (var sub in SubNodes)
        {
            sub.Receive(userData);
        }
    }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
    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);
        }
    }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 5
0
    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);
        });
    }
Exemplo n.º 6
0
 public UQuadtree(Rect bound)
 {
     _root = new UQtNode(bound);
     UQtAlgo.BuildRecursively(_root);
 }