Example #1
0
            public bool MoveNext()
            {
repeat:
                if (start)
                {
                    start = false;
                    return(true);
                }
                var t = stack.Peek();

                if (t.i > 3)
                {
                    if (stack.Count > 1)
                    {
                        stack.Pop();
                        goto repeat;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    if (t.child.isLeaf)
                    {
                        if (stack.Count > 1)
                        {
                            stack.Pop();
                            goto repeat;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        var size     = t.size / 2;
                        var posIndex = Quadtree.IndexToSigns(t.i);
                        var origin   = t.origin + (new Vector2(posIndex.x * size, posIndex.y * size));

                        stack.Push(new Tracker(t.child.children[t.i], origin, size));
                        t.i++;
                        return(true);
                    }
                }
            }
Example #2
0
            public bool MoveDown(int childIndex)
            {
                var t = stack.Peek();

                if (t.child.isLeaf)
                {
                    return(false);
                }
                else
                {
                    var size     = t.size / 2;
                    var posIndex = Quadtree.IndexToSigns(t.i);
                    var origin   = t.origin + (new Vector2(posIndex.x * size, posIndex.y * size));

                    stack.Push(new Tracker(t.child.children[childIndex], origin, size));
                    return(true);
                }
            }