Exemple #1
0
    /// <summary>
    /// Output a column of data into the columnbuilder; after doing this with all columns the builder will be resolved to a new, merged column
    /// </summary>
    unsafe void DownSamplePartial(int x, int z, int extraLods, ref WorldBuilder.RLEColumnBuilder columnBuilder)
    {
        RLEColumn column = *Storage.GetColumnPointer(GetIndexKnownInBounds(int2(x, z)));

        if (column.RunCount <= 0)
        {
            return;
        }

        int2         elementBounds = dimensions.y >> lod;
        int          nextLod       = lod + extraLods;
        ColorARGB32 *colorPointer  = column.ColorPointer(ref Storage);

        for (int run = 0; run < column.RunCount; run++)
        {
            RLEElement element = column.GetIndex(ref Storage, run);

            elementBounds = int2(elementBounds.x - element.Length, elementBounds.x);

            if (element.IsAir)
            {
                continue;
            }

            for (int i = 0; i < element.Length; i++)
            {
                int Y        = elementBounds.x + i;
                int colorIdx = element.ColorsIndex + element.Length - i - 1;
                columnBuilder.SetVoxel(Y >> nextLod, colorPointer[colorIdx]);
            }
        }
    }