コード例 #1
0
    public void TestRadius3()
    {
        int radius = 3;

        var circle = new BresenhamCircle(0, radius);
        var points = circle.GetPoints();

        Assert.AreEqual(16, points.Length);

        Assert.AreEqual(new int2(3, 0), points[0]);
        Assert.AreEqual(new int2(0, 3), points[1]);
        Assert.AreEqual(new int2(-3, 0), points[2]);
        Assert.AreEqual(new int2(0, -3), points[3]);
        Assert.AreEqual(new int2(3, 1), points[4]);
        Assert.AreEqual(new int2(-1, 3), points[5]);
        Assert.AreEqual(new int2(-3, -1), points[6]);
        Assert.AreEqual(new int2(1, -3), points[7]);
        Assert.AreEqual(new int2(2, 2), points[8]);
        Assert.AreEqual(new int2(-2, 2), points[9]);
        Assert.AreEqual(new int2(-2, -2), points[10]);
        Assert.AreEqual(new int2(2, -2), points[11]);
        Assert.AreEqual(new int2(1, 3), points[12]);
        Assert.AreEqual(new int2(-3, 1), points[13]);
        Assert.AreEqual(new int2(-1, -3), points[14]);
        Assert.AreEqual(new int2(3, -1), points[15]);

        points.Dispose();
    }
コード例 #2
0
        public void CircleTestRadius3()
        {
            var circle     = new BresenhamCircle(int2.zero, 3);
            var enumerator = circle.GetEnumerator();
            var points     = new List <int2>(16);

            while (enumerator.MoveNext())
            {
                points.Add(enumerator.Current);
            }

            CollectionAssert.AreEqual(points, new List <int2>
            {
                new int2(3, 0),
                new int2(0, 3),
                new int2(-3, 0),
                new int2(0, -3),
                new int2(3, 1),
                new int2(-1, 3),
                new int2(-3, -1),
                new int2(1, -3),
                new int2(2, 2),
                new int2(-2, 2),
                new int2(-2, -2),
                new int2(2, -2),
                new int2(1, 3),
                new int2(-3, 1),
                new int2(-1, -3),
                new int2(3, -1)
            });
        }
コード例 #3
0
 public void TestRadius()
 {
     for (int radius = 1; radius < 200; ++radius)
     {
         var circle = new BresenhamCircle(0, radius);
         var points = circle.GetPoints(Allocator.Temp);
     }
 }
コード例 #4
0
ファイル: Bresenham.cs プロジェクト: r2d2m/rltk_unity
        static void BuildVisibleSet <T>(int2 origin, int range, T visibilityMap, NativeHashSet <int2> buffer)
            where T : IVisibilityMap
        {
            BresenhamCircle circle = new BresenhamCircle(origin, range);
            var             points = circle.GetPoints(Allocator.Temp);

            for (int i = 0; i < points.Length; ++i)
            {
                var p = points[i];

                ScanFOVLine(origin, p, visibilityMap, buffer);
            }
        }
コード例 #5
0
    public void TestRadius1()
    {
        int radius = 1;

        var circle = new BresenhamCircle(0, radius);
        var points = circle.GetPoints();

        Assert.AreEqual(4, points.Length);

        Assert.AreEqual(new int2(1, 0), points[0]);
        Assert.AreEqual(new int2(0, 1), points[1]);
        Assert.AreEqual(new int2(-1, 0), points[2]);
        Assert.AreEqual(new int2(0, -1), points[3]);

        points.Dispose();
    }
コード例 #6
0
    public void UseCircleInsideAJob()
    {
        var circle = new BresenhamCircle(0, 1);
        var points = new NativeArray <int2>(4, Allocator.TempJob);

        new CircleUsingJob
        {
            circle = circle,
            points = points
        }.Schedule().Complete();

        Assert.AreEqual(new int2(1, 0), points[0]);
        Assert.AreEqual(new int2(0, 1), points[1]);
        Assert.AreEqual(new int2(-1, 0), points[2]);
        Assert.AreEqual(new int2(0, -1), points[3]);

        points.Dispose();
    }
コード例 #7
0
        public void CircleTestRadius1()
        {
            var circle     = new BresenhamCircle(int2.zero, 1);
            var enumerator = circle.GetEnumerator();
            var points     = new List <int2>(4);

            while (enumerator.MoveNext())
            {
                points.Add(enumerator.Current);
            }

            CollectionAssert.AreEqual(points, new List <int2>
            {
                int2(1, 0),
                int2(0, 1),
                int2(-1, 0),
                int2(0, -1)
            });
        }