Esempio n. 1
0
 // Token: 0x0600286E RID: 10350 RVA: 0x001B800C File Offset: 0x001B620C
 private int GetNodeIndex()
 {
     if (this.filledNodes == this.nodes.Length)
     {
         RVOQuadtree.Node[] array = new RVOQuadtree.Node[this.nodes.Length * 2];
         for (int i = 0; i < this.nodes.Length; i++)
         {
             array[i] = this.nodes[i];
         }
         this.nodes = array;
     }
     this.nodes[this.filledNodes]         = default(RVOQuadtree.Node);
     this.nodes[this.filledNodes].child00 = this.filledNodes;
     this.filledNodes++;
     return(this.filledNodes - 1);
 }
Esempio n. 2
0
        // Token: 0x0600286F RID: 10351 RVA: 0x001B80B0 File Offset: 0x001B62B0
        public void Insert(Agent agent)
        {
            int     num    = 0;
            Rect    r      = this.bounds;
            Vector2 vector = new Vector2(agent.position.x, agent.position.y);

            agent.next     = null;
            this.maxRadius = Math.Max(agent.radius, this.maxRadius);
            int num2 = 0;

            for (;;)
            {
                num2++;
                if (this.nodes[num].child00 == num)
                {
                    if (this.nodes[num].count < 15 || num2 > 10)
                    {
                        break;
                    }
                    RVOQuadtree.Node node = this.nodes[num];
                    node.child00    = this.GetNodeIndex();
                    node.child01    = this.GetNodeIndex();
                    node.child10    = this.GetNodeIndex();
                    node.child11    = this.GetNodeIndex();
                    this.nodes[num] = node;
                    this.nodes[num].Distribute(this.nodes, r);
                }
                if (this.nodes[num].child00 != num)
                {
                    Vector2 center = r.center;
                    if (vector.x > center.x)
                    {
                        if (vector.y > center.y)
                        {
                            num = this.nodes[num].child11;
                            r   = Rect.MinMaxRect(center.x, center.y, r.xMax, r.yMax);
                        }
                        else
                        {
                            num = this.nodes[num].child10;
                            r   = Rect.MinMaxRect(center.x, r.yMin, r.xMax, center.y);
                        }
                    }
                    else if (vector.y > center.y)
                    {
                        num = this.nodes[num].child01;
                        r   = Rect.MinMaxRect(r.xMin, center.y, center.x, r.yMax);
                    }
                    else
                    {
                        num = this.nodes[num].child00;
                        r   = Rect.MinMaxRect(r.xMin, r.yMin, center.x, center.y);
                    }
                }
            }
            this.nodes[num].Add(agent);
            RVOQuadtree.Node[] array = this.nodes;
            int num3 = num;

            array[num3].count = array[num3].count + 1;
        }
        public void Insert(Agent agent)
        {
            int   num = 0;
            VRect r   = this.bounds;
            VInt2 xz  = agent.position.xz;

            agent.next     = null;
            this.maxRadius = IntMath.Max((long)agent.radius.i, this.maxRadius);
            int num2 = 0;

            while (true)
            {
                num2++;
                if (this.nodes[num].child00 == num)
                {
                    if (this.nodes[num].count < 15 || num2 > 10)
                    {
                        break;
                    }
                    RVOQuadtree.Node node = this.nodes[num];
                    node.child00    = this.GetNodeIndex();
                    node.child01    = this.GetNodeIndex();
                    node.child10    = this.GetNodeIndex();
                    node.child11    = this.GetNodeIndex();
                    this.nodes[num] = node;
                    this.nodes[num].Distribute(this.nodes, r);
                }
                if (this.nodes[num].child00 != num)
                {
                    VInt2 center = r.center;
                    if (xz.x > center.x)
                    {
                        if (xz.y > center.y)
                        {
                            num = this.nodes[num].child11;
                            r   = VRect.MinMaxRect(center.x, center.y, r.xMax, r.yMax);
                        }
                        else
                        {
                            num = this.nodes[num].child10;
                            r   = VRect.MinMaxRect(center.x, r.yMin, r.xMax, center.y);
                        }
                    }
                    else if (xz.y > center.y)
                    {
                        num = this.nodes[num].child01;
                        r   = VRect.MinMaxRect(r.xMin, center.y, center.x, r.yMax);
                    }
                    else
                    {
                        num = this.nodes[num].child00;
                        r   = VRect.MinMaxRect(r.xMin, r.yMin, center.x, center.y);
                    }
                }
            }
            this.nodes[num].Add(agent);
            RVOQuadtree.Node[] array = this.nodes;
            int num3 = num;

            array[num3].count = array[num3].count + 1;
        }