Пример #1
0
 public static IEnumerable <IntVector3> IteratorXZAtY(IntBounds3 bounds, int y)
 {
     foreach (var pos in bounds.IteratorXZ)
     {
         yield return(pos.ToIntVector3XZWithY(y));
     }
 }
Пример #2
0
        public static IEnumerable <IntVector3> IteratorXZWithNeighborsAtY(IntBounds3 bounds, int y)
        {
            foreach (var pos in bounds.IteratorXZ)
            {
                var p = pos.ToIntVector3XZWithY(y);
                yield return(p);

                foreach (var relEscape in CubeNeighbors6.EscapeFacesXZ(bounds.RelativeOrigin(p), bounds.size))
                {
                    yield return(p + relEscape);
                }
            }
        }
Пример #3
0
        public static IntVector3[] ProximityOrderedIntVectors(IntVector3 cubeSize)
        {
            var bounds = IntBounds3.FromCenterHalfSize(IntVector3.zero, cubeSize / 2);
            var iter   = ProximityOrderedIntVectors(cubeSize.MaxComponent);
            var result = new List <IntVector3>(cubeSize.Area);

            foreach (var v in iter)
            {
                if (bounds.Contains(v))
                {
                    result.Add(v);
                }
            }
            return(result.ToArray());
        }
Пример #4
0
        public static IEnumerable <IntVector3> IteratorXZYWithNeighbors(IntBounds3 bounds)
        {
            foreach (var pos in bounds.IteratorXZYTopDown)
            {
                yield return(pos);

                foreach (var nei in CubeNeighbors6.NeighborsOf(pos))
                {
                    if (!bounds.Contains(nei))
                    {
                        yield return(nei);
                    }
                }
            }
        }
Пример #5
0
        public static IntVector3[] ProximityOrderedIntVectors(int cubeSize)
        {
            IntBounds3 b = new IntBounds3
            {
                start = IntVector3.zero,
                size  = new IntVector3(1)
            };

            IntBounds3 p = new IntBounds3
            {
                start = b.start,
                size  = IntVector3.zero
            };

            var ivs = new List <IntVector3>(cubeSize * cubeSize * cubeSize);

            while (b.size.x <= cubeSize)
            {
                foreach (var iv in b.IteratorYXZ)
                {
                    if (p.Contains(iv))
                    {
                        continue;
                    }
                    ivs.Add(iv);
                }
                p = b;
                b = b.ExpandedBordersAdditive(new IntVector3(1));
            }

            if (cubeSize % 2 == 0)
            {
                b.size  -= new IntVector3(1);
                b.start += new IntVector3(1);
                foreach (var iv in b.IteratorXYZ)
                {
                    if (p.Contains(iv))
                    {
                        continue;
                    }
                    ivs.Add(iv);
                }
            }
            return(ivs.ToArray());
        }