コード例 #1
0
ファイル: QuadTree.cs プロジェクト: BlankRip/ExportToFbx
    public List <Point_Test> GetPointsInArea(Rectangle_Test area, List <Point_Test> found)
    {
        if (found == null)
        {
            found = new List <Point_Test>();
        }

        if (!boundary.AreaOverlap(area))
        {
            return(found);
        }
        else
        {
            foreach (Point_Test point in pointsInQuad)
            {
                if (area.InMe(point))
                {
                    found.Add(point);
                }

                if (divided)
                {
                    for (int i = 0; i < subDividedQuads.Length; i++)
                    {
                        found = subDividedQuads[i].GetPointsInArea(area, found);
                    }
                }
            }
            return(found);
        }
    }
コード例 #2
0
ファイル: QuadTree.cs プロジェクト: BlankRip/ExportToFbx
    public bool AddPoint(Point_Test point)
    {
        if (!boundary.InMe(point))
        {
            return(false);
        }

        if (pointsInQuad.Count < capacity)
        {
            pointsInQuad.Add(point);
            return(true);
        }
        else
        {
            if (!divided)
            {
                SubDevide();
            }

            for (int i = 0; i < subDividedQuads.Length; i++)
            {
                if (subDividedQuads[i].AddPoint(point))
                {
                    return(true);
                }
            }
            return(false);
        }
    }