Пример #1
0
 public IntRect1(IntRect1 source)
 {
     this.m_XMin   = source.m_XMin;
     this.m_YMin   = source.m_YMin;
     this.m_Width  = source.m_Width;
     this.m_Height = source.m_Height;
 }
Пример #2
0
            public void Distribute(RVOQuadtree.Node[] nodes, IntRect1 r)
            {
                Int2 center = r.center;

                while (this.linkedList != null)
                {
                    Agent next = this.linkedList.next;
                    if (this.linkedList.position.x > center.x)
                    {
                        if (this.linkedList.position.z > center.y)
                        {
                            nodes[this.child11].Add(this.linkedList);
                        }
                        else
                        {
                            nodes[this.child10].Add(this.linkedList);
                        }
                    }
                    else if (this.linkedList.position.z > center.y)
                    {
                        nodes[this.child01].Add(this.linkedList);
                    }
                    else
                    {
                        nodes[this.child00].Add(this.linkedList);
                    }
                    this.linkedList = next;
                }
                this.count = 0;
            }
Пример #3
0
    public override bool Equals(object other)
    {
        if (!(other is IntRect1))
        {
            return(false);
        }
        IntRect1 vRect = (IntRect1)other;

        return(this.x.Equals(vRect.x) && this.y.Equals(vRect.y) && this.width.Equals(vRect.width) && this.height.Equals(vRect.height));
    }
Пример #4
0
    public bool Overlaps(IntRect1 other, bool allowInverse)
    {
        IntRect1 rect = this;

        if (allowInverse)
        {
            rect  = IntRect1.OrderMinMax(rect);
            other = IntRect1.OrderMinMax(other);
        }
        return(rect.Overlaps(other));
    }
Пример #5
0
 private static IntRect1 OrderMinMax(IntRect1 rect)
 {
     if (rect.xMin > rect.xMax)
     {
         int xMin = rect.xMin;
         rect.xMin = rect.xMax;
         rect.xMax = xMin;
     }
     if (rect.yMin > rect.yMax)
     {
         int yMin = rect.yMin;
         rect.yMin = rect.yMax;
         rect.yMax = yMin;
     }
     return(rect);
 }
Пример #6
0
 private void BuildQuadtree()
 {
     this.quadtree.Clear();
     if (this.agents.Count > 0)
     {
         IntRect1 bounds = IntRect1.MinMaxRect(this.agents[0].position.x, this.agents[0].position.y, this.agents[0].position.x, this.agents[0].position.y);
         for (int i = 1; i < this.agents.Count; i++)
         {
             Int3 position = this.agents[i].position;
             bounds = IntRect1.MinMaxRect(Mathf.Min(bounds.xMin, position.x), Mathf.Min(bounds.yMin, position.z), Mathf.Max(bounds.xMax, position.x), Mathf.Max(bounds.yMax, position.z));
         }
         this.quadtree.SetBounds(bounds);
         for (int j = 0; j < this.agents.Count; j++)
         {
             this.quadtree.Insert(this.agents[j]);
         }
     }
 }
Пример #7
0
 private long QueryRec(int i, Int2 p, long radius, Agent agent, IntRect1 r)
 {
     if (this.nodes[i].child00 == i)
     {
         for (Agent agent2 = this.nodes[i].linkedList; agent2 != null; agent2 = agent2.next)
         {
             long num = agent.InsertAgentNeighbour(agent2, radius * radius);
             if (num < radius * radius)
             {
                 radius = (long)IntMath.Sqrt(num);
             }
         }
     }
     else
     {
         Int2 center = r.center;
         if ((long)p.x - radius < (long)center.x)
         {
             if ((long)p.y - radius < (long)center.y)
             {
                 radius = this.QueryRec(this.nodes[i].child00, p, radius, agent, IntRect1.MinMaxRect(r.xMin, r.yMin, center.x, center.y));
             }
             if ((long)p.y + radius > (long)center.y)
             {
                 radius = this.QueryRec(this.nodes[i].child01, p, radius, agent, IntRect1.MinMaxRect(r.xMin, center.y, center.x, r.yMax));
             }
         }
         if ((long)p.x + radius > (long)center.x)
         {
             if ((long)p.y - radius < (long)center.y)
             {
                 radius = this.QueryRec(this.nodes[i].child10, p, radius, agent, IntRect1.MinMaxRect(center.x, r.yMin, r.xMax, center.y));
             }
             if ((long)p.y + radius > (long)center.y)
             {
                 radius = this.QueryRec(this.nodes[i].child11, p, radius, agent, IntRect1.MinMaxRect(center.x, center.y, r.xMax, r.yMax));
             }
         }
     }
     return(radius);
 }
Пример #8
0
 public bool Overlaps(IntRect1 other)
 {
     return(other.xMax > this.xMin && other.xMin < this.xMax && other.yMax > this.yMin && other.yMin < this.yMax);
 }
Пример #9
0
        public void Insert(Agent agent)
        {
            int      num = 0;
            IntRect1 r   = this.bounds;
            Int2     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)
                {
                    Int2 center = r.center;
                    if (xz.x > center.x)
                    {
                        if (xz.y > center.y)
                        {
                            num = this.nodes[num].child11;
                            r   = IntRect1.MinMaxRect(center.x, center.y, r.xMax, r.yMax);
                        }
                        else
                        {
                            num = this.nodes[num].child10;
                            r   = IntRect1.MinMaxRect(center.x, r.yMin, r.xMax, center.y);
                        }
                    }
                    else if (xz.y > center.y)
                    {
                        num = this.nodes[num].child01;
                        r   = IntRect1.MinMaxRect(r.xMin, center.y, center.x, r.yMax);
                    }
                    else
                    {
                        num = this.nodes[num].child00;
                        r   = IntRect1.MinMaxRect(r.xMin, r.yMin, center.x, center.y);
                    }
                }
            }
            this.nodes[num].Add(agent);
            RVOQuadtree.Node[] expr_94_cp_0 = this.nodes;
            int expr_94_cp_1 = num;

            expr_94_cp_0[expr_94_cp_1].count = (byte)(expr_94_cp_0[expr_94_cp_1].count + 1);
        }
Пример #10
0
 public void SetBounds(IntRect1 r)
 {
     this.bounds = r;
 }