// Builds Chunk's VoxelData using Decompression algorithm
    public static void DecompressBlocks(Chunk c, byte[] buffer)
    {
        // Preparation Variables
        Pallete       p           = Compression.BiomeToPallete(c.biomeName);
        List <ushort> palleteList = Compression.GetPallete(p);

        NativeArray <ushort> data     = new NativeArray <ushort>(Chunk.chunkWidth * Chunk.chunkWidth * Chunk.chunkDepth, Allocator.TempJob);
        NativeArray <byte>   readData = new NativeArray <byte>(buffer, Allocator.TempJob);
        NativeArray <ushort> pallete  = new NativeArray <ushort>(palleteList.ToArray(), Allocator.TempJob);

        DecompressJob dbJob = new DecompressJob {
            data     = data,
            readData = readData,
            pallete  = pallete
        };
        JobHandle job = dbJob.Schedule();

        job.Complete();

        c.data.SetData(data.ToArray());


        data.Dispose();
        readData.Dispose();
        pallete.Dispose();
    }
示例#2
0
    // Builds Chunk's State Metadata using Decompression algorithm
    public static void DecompressMetadataStateClient(Chunk c, byte[] buffer, int initialPos)
    {
        // Preparation Variables
        List <ushort> palleteList = Compression.GetPallete(Pallete.METADATA);

        NativeArray <ushort> data     = new NativeArray <ushort>(Chunk.chunkWidth * Chunk.chunkWidth * Chunk.chunkDepth, Allocator.TempJob);
        NativeArray <byte>   readData = NativeTools.CopyToNative(buffer);
        NativeArray <ushort> pallete  = NativeTools.CopyToNative(palleteList.ToArray());

        DecompressJob dbJob = new DecompressJob {
            data       = data,
            readData   = readData,
            pallete    = pallete,
            initialPos = initialPos
        };
        JobHandle job = dbJob.Schedule();

        job.Complete();

        c.metadata.SetStateData(data.ToArray());

        data.Dispose();
        readData.Dispose();
        pallete.Dispose();
    }
    // Builds Chunk's HP Metadata using Decompression algorithm
    public static void DecompressMetadataHP(Chunk c, byte[] buffer)
    {
        // Preparation Variables
        List <ushort> palleteList = Compression.GetPallete(Pallete.METADATA);

        NativeArray <ushort> data     = new NativeArray <ushort>(Chunk.chunkWidth * Chunk.chunkWidth * Chunk.chunkDepth, Allocator.TempJob);
        NativeArray <byte>   readData = new NativeArray <byte>(buffer, Allocator.TempJob);
        NativeArray <ushort> pallete  = new NativeArray <ushort>(palleteList.ToArray(), Allocator.TempJob);

        DecompressJob dbJob = new DecompressJob {
            data     = data,
            readData = readData,
            pallete  = pallete
        };
        JobHandle job = dbJob.Schedule();

        job.Complete();

        c.metadata.SetHPData(data.ToArray());

        data.Dispose();
        readData.Dispose();
        pallete.Dispose();
    }