* Allow terrain load-tile for RAW files
* Patch from Sophie Lee [webmage] - IBM. Thanks very much!ThreadPoolClientBranch
parent
2d7fbf6137
commit
aa9d3f7aed
|
@ -609,6 +609,10 @@ namespace OpenSim.Region.Terrain
|
|||
LoadFromFileF32(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
|
||||
Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
|
||||
break;
|
||||
case "raw":
|
||||
LoadFromFileSLRAW(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
|
||||
Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
|
||||
break;
|
||||
case "img":
|
||||
LoadFromFileIMG(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
|
||||
Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
|
||||
|
@ -961,6 +965,58 @@ namespace OpenSim.Region.Terrain
|
|||
tainted++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a section of a larger heightmap (RAW)
|
||||
/// </summary>
|
||||
/// <param name="filename">File to load</param>
|
||||
/// <param name="dimensionX">Size of the file</param>
|
||||
/// <param name="dimensionY">Size of the file</param>
|
||||
/// <param name="lowerboundX">Where do the region coords start for this terrain?</param>
|
||||
/// <param name="lowerboundY">Where do the region coords start for this terrain?</param>
|
||||
public void LoadFromFileSLRAW(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY)
|
||||
{
|
||||
// TODO: Mutex fails to release readlock on folder! --> only one file can be loaded into sim
|
||||
//fileIOLock.WaitOne();
|
||||
//try
|
||||
//{
|
||||
int sectionToLoadX = ((offsetX - lowerboundX)*w);
|
||||
int sectionToLoadY = ((offsetY - lowerboundY)*h);
|
||||
|
||||
double[,] tempMap = new double[dimensionX,dimensionY];
|
||||
|
||||
FileInfo file = new FileInfo(filename);
|
||||
FileStream s = file.Open(FileMode.Open, FileAccess.Read);
|
||||
BinaryReader bs = new BinaryReader(s);
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < dimensionX; x++)
|
||||
{
|
||||
for (y = 0; y < dimensionY; y++)
|
||||
{
|
||||
tempMap[x, y] = (double) bs.ReadByte()*((double) bs.ReadByte()/127.0);
|
||||
bs.ReadBytes(11); // Advance the stream to next bytes.
|
||||
}
|
||||
}
|
||||
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
heightmap.Set(x, y, tempMap[x + sectionToLoadX, y + sectionToLoadY]);
|
||||
}
|
||||
}
|
||||
|
||||
bs.Close();
|
||||
s.Close();
|
||||
|
||||
tainted++;
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// fileIOLock.ReleaseMutex();
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue