private void ReadRaw(string path)
{
byte[] buffer;
using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open, FileAccess.Read)))
{
buffer = reader.ReadBytes((this.m_Width * this.m_Height) * this.m_Depth);
reader.Close();
}
int heightmapWidth = base.terrainData.heightmapWidth;
int heightmapHeight = base.terrainData.heightmapHeight;
float[,] heights = new float[heightmapHeight, heightmapWidth];
if (this.m_Depth == Depth.Bit16)
{
float num3 = 1.525879E-05f;
for (int i = 0; i < heightmapHeight; i++)
{
for (int j = 0; j < heightmapWidth; j++)
{
int num6 = Mathf.Clamp(j, 0, this.m_Width - 1) + (Mathf.Clamp(i, 0, this.m_Height - 1) * this.m_Width);
if ((this.m_ByteOrder == ByteOrder.Mac) == BitConverter.IsLittleEndian)
{
byte num7 = buffer[num6 * 2];
buffer[num6 * 2] = buffer[(num6 * 2) + 1];
buffer[(num6 * 2) + 1] = num7;
}
float num9 = BitConverter.ToUInt16(buffer, num6 * 2) * num3;
int num10 = !this.m_FlipVertically ? i : ((heightmapHeight - 1) - i);
heights[num10, j] = num9;
}
}
}
else
{
float num11 = 0.00390625f;
for (int k = 0; k < heightmapHeight; k++)
{
for (int m = 0; m < heightmapWidth; m++)
{
int index = Mathf.Clamp(m, 0, this.m_Width - 1) + (Mathf.Clamp(k, 0, this.m_Height - 1) * this.m_Width);
byte num15 = buffer[index];
float num16 = num15 * num11;
int num17 = !this.m_FlipVertically ? k : ((heightmapHeight - 1) - k);
heights[num17, m] = num16;
}
}
}
base.terrainData.SetHeights(0, 0, heights);
}