Ejemplo n.º 1
0
    public void DownwardsLine()
    {
        int len  = 10;
        var line = new VectorLine(0, 0, 0, -len);

        var points = line.GetPoints(Allocator.Temp);

        Assert.AreEqual(len + 1, points.Length);

        for (int i = 0; i <= len; ++i)
        {
            Assert.AreEqual(new int2(0, -i), points[i]);
        }
    }
Ejemplo n.º 2
0
    public void UpwardsLine()
    {
        int endY = 10;
        var line = new VectorLine(0, 0, 0, endY);

        var points = line.GetPoints(Allocator.Temp);

        Assert.AreEqual(endY + 1, points.Length);

        for (int i = 0; i <= endY; ++i)
        {
            Assert.AreEqual(new int2(0, i), points[i]);
        }
    }
Ejemplo n.º 3
0
    public void BackwardLine()
    {
        int endX = 10;
        var line = new VectorLine(0, 0, -endX, 0);

        var points = line.GetPoints(Allocator.Temp);

        Assert.AreEqual(endX + 1, points.Length);

        for (int i = 0; i <= endX; ++i)
        {
            Assert.AreEqual(new int2(-i, 0), points[i]);
        }
    }
Ejemplo n.º 4
0
    public void ForwardLine()
    {
        int endX = 10;
        var line = new VectorLine(0, 0, endX, 0);

        var points = line.GetPoints(Allocator.Temp);

        Assert.AreEqual(endX + 1, points.Length);

        for (int x = 0; x <= endX; ++x)
        {
            Assert.AreEqual(new int2(x, 0), points[x]);
        }
    }
Ejemplo n.º 5
0
    public void DownLeftLine()
    {
        var begin = new int2(0, 0);
        var end   = new int2(-5, -5);

        var line   = new VectorLine(begin, end);
        var points = line.GetPoints(Allocator.Temp);

        Assert.AreEqual(6, points.Length);

        for (int i = 0; i < 6; ++i)
        {
            int x = points[i].x;
            int y = points[i].y;
            Assert.AreEqual(-i, x);
            Assert.AreEqual(-i, y);
        }
    }
Ejemplo n.º 6
0
        static void ScanFOVLine <T>(int2 start, int2 end, T map, NativeHashSet <int2> pointSet) where T : IVisibilityMap
        {
            var line       = new VectorLine(start, end);
            var linePoints = line.GetPoints(Allocator.Temp);

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

                if (!map.IsInBounds(p))
                {
                    return;
                }

                pointSet.TryAdd(p);

                if (map.IsOpaque(p))
                {
                    return;
                }
            }
        }