OpenMetaverse.TerrainCompressor.CreatePatchFromHeightmap C# (CSharp) Method

CreatePatchFromHeightmap() public static method

Add a patch of terrain to a BitPacker
public static CreatePatchFromHeightmap ( OpenMetaverse.BitPack output, float heightmap, int x, int y ) : void
output OpenMetaverse.BitPack BitPacker to write the patch to
heightmap float Heightmap of the simulator, must be a 256 * /// 256 float array
x int X offset of the patch to create, valid values are /// from 0 to 15
y int Y offset of the patch to create, valid values are /// from 0 to 15
return void
        public static void CreatePatchFromHeightmap(BitPack output, float[] heightmap, int x, int y)
        {
            if (heightmap.Length != 256 * 256)
                throw new ArgumentException("Heightmap data must be 256x256");

            if (x < 0 || x > 15 || y < 0 || y > 15)
                throw new ArgumentException("X and Y patch offsets must be from 0 to 15");

            TerrainPatch.Header header = PrescanPatch(heightmap, x, y);
            header.QuantWBits = 136;
            header.PatchIDs = (y & 0x1F);
            header.PatchIDs += (x << 5);

            // NOTE: No idea what prequant and postquant should be or what they do
            int[] patch = CompressPatch(heightmap, x, y, header, 10);
            int wbits = EncodePatchHeader(output, header, patch);
            EncodePatch(output, patch, 0, wbits);
        }