* Terrain now uses the new StorageManager.

afrisby
Adam Frisby 2007-07-15 15:51:09 +00:00
parent 6d455f3b6c
commit 2dea3dbd6b
3 changed files with 32 additions and 6 deletions

View File

@ -352,7 +352,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
try try
{ {
float[] map = this.localStorage.LoadWorld(); double[,] map = this.storageManager.DataStore.LoadTerrain();
if (map == null) if (map == null)
{ {
if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile)) if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile))
@ -360,7 +360,7 @@ namespace OpenSim.Region.Environment.Scenes
Console.WriteLine("No default terrain, procedurally generating..."); Console.WriteLine("No default terrain, procedurally generating...");
this.Terrain.hills(); this.Terrain.hills();
this.localStorage.SaveMap(this.Terrain.getHeights1D()); this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD());
} }
else else
{ {
@ -374,12 +374,12 @@ namespace OpenSim.Region.Environment.Scenes
Console.WriteLine("Unable to load default terrain, procedurally generating instead..."); Console.WriteLine("Unable to load default terrain, procedurally generating instead...");
Terrain.hills(); Terrain.hills();
} }
this.localStorage.SaveMap(this.Terrain.getHeights1D()); this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD());
} }
} }
else else
{ {
this.Terrain.setHeights1D(map); this.Terrain.setHeights2D(map);
} }
CreateTerrainTexture(); CreateTerrainTexture();

View File

@ -29,7 +29,7 @@ namespace OpenSim.DataStore.NullStorage
public List<SceneObject> LoadObjects() public List<SceneObject> LoadObjects()
{ {
return null; return new List<SceneObject>();
} }
public void StoreTerrain(double[,] ter) public void StoreTerrain(double[,] ter)
@ -54,7 +54,7 @@ namespace OpenSim.DataStore.NullStorage
public List<OpenSim.Region.Environment.Parcel> LoadParcels() public List<OpenSim.Region.Environment.Parcel> LoadParcels()
{ {
return null; return new List<OpenSim.Region.Environment.Parcel>();
} }
public void Shutdown() public void Shutdown()

View File

@ -123,6 +123,15 @@ namespace OpenSim.Region.Terrain
return heights; return heights;
} }
/// <summary>
/// Converts the heightmap to a 256x256 value 2D floating point array. Double precision version.
/// </summary>
/// <returns>An array of 256,256 values containing the heightmap</returns>
public double[,] getHeights2DD()
{
return heightmap.map;
}
/// <summary> /// <summary>
/// Imports a 1D floating point array into the 2D heightmap array /// Imports a 1D floating point array into the 2D heightmap array
/// </summary> /// </summary>
@ -155,6 +164,23 @@ namespace OpenSim.Region.Terrain
tainted++; tainted++;
} }
/// <summary>
/// Loads a 2D array of values into the heightmap (Double Precision Version)
/// </summary>
/// <param name="heights">An array of 256,256 float values</param>
public void setHeights2D(double[,] heights)
{
int x, y;
for (x = 0; x < w; x++)
{
for (y = 0; y < h; y++)
{
heightmap.set(x, y, heights[x, y]);
}
}
tainted++;
}
/// <summary> /// <summary>
/// Swaps the two heightmap buffers (the 'revert map' and the heightmap) /// Swaps the two heightmap buffers (the 'revert map' and the heightmap)
/// </summary> /// </summary>