Ejemplo n.º 1
0
        public static uint[] PackedGenVoxels(IntVector3 size, Func <IntVector3, bool> shouldBeSolid)
        {
            var dims = size;

            dims.y /= VGenConfig.VoxelsPerMapData;
            uint[] result = new uint[dims.Area];

            for (int x = 0; x < dims.x; ++x)
            {
                for (int z = 0; z < dims.z; ++z)
                {
                    for (int y = 0; y < dims.y; ++y)
                    {
                        var pos   = new IntVector3(x, y, z);
                        int index = pos.ToFlatXZYIndex(dims);
                        pos.y *= VGenConfig.VoxelsPerMapData;
                        int voxels = 0;
                        for (int i = 0; i < VGenConfig.VoxelsPerMapData; ++i)
                        {
                            if (shouldBeSolid(pos))
                            {
                                voxels |= (2 << (i * VGenConfig.VoxelMapDataBitSize));
                            }
                            pos.y++;
                        }
                        result[index] = (uint)voxels;
                    }
                }
            }
            return(result);
        }