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);
}