mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 01:06:30 +08:00
varregion: push TerrainData implementation up and down the database storage stack.
Implement both LoadTerrain and StoreTerrain for all DBs. Move all database blob serialization/deserialization into TerrainData.
This commit is contained in:
@@ -68,13 +68,22 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="ter">HeightField data</param>
|
||||
/// <param name="regionID">region UUID</param>
|
||||
void StoreTerrain(TerrainData terrain, UUID regionID);
|
||||
|
||||
// Legacy version kept for downward compabibility
|
||||
void StoreTerrain(double[,] terrain, UUID regionID);
|
||||
|
||||
/// <summary>
|
||||
/// Load the latest terrain revision from region storage
|
||||
/// </summary>
|
||||
/// <param name="regionID">the region UUID</param>
|
||||
/// <param name="sizeX">the X dimension of the region being filled</param>
|
||||
/// <param name="sizeY">the Y dimension of the region being filled</param>
|
||||
/// <param name="sizeZ">the Z dimension of the region being filled</param>
|
||||
/// <returns>Heightfield data</returns>
|
||||
TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
|
||||
|
||||
// Legacy version kept for downward compabibility
|
||||
double[,] LoadTerrain(UUID regionID);
|
||||
|
||||
void StoreLandObject(ILandObject Parcel);
|
||||
|
||||
@@ -79,13 +79,22 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="ter">HeightField data</param>
|
||||
/// <param name="regionID">region UUID</param>
|
||||
void StoreTerrain(TerrainData terrain, UUID regionID);
|
||||
|
||||
// Legacy version kept for downward compabibility
|
||||
void StoreTerrain(double[,] terrain, UUID regionID);
|
||||
|
||||
/// <summary>
|
||||
/// Load the latest terrain revision from region storage
|
||||
/// </summary>
|
||||
/// <param name="regionID">the region UUID</param>
|
||||
/// <param name="pSizeX">the X dimension of the terrain being filled</param>
|
||||
/// <param name="pSizeY">the Y dimension of the terrain being filled</param>
|
||||
/// <param name="pSizeZ">the Z dimension of the terrain being filled</param>
|
||||
/// <returns>Heightfield data</returns>
|
||||
TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
|
||||
|
||||
// Legacy version kept for downward compabibility
|
||||
double[,] LoadTerrain(UUID regionID);
|
||||
|
||||
void StoreLandObject(ILandObject Parcel);
|
||||
|
||||
@@ -1894,7 +1894,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
try
|
||||
{
|
||||
double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID);
|
||||
TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
|
||||
if (map == null)
|
||||
{
|
||||
// This should be in the Terrain module, but it isn't because
|
||||
@@ -1911,7 +1911,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
else
|
||||
{
|
||||
Heightmap = new TerrainChannel(map, RegionInfo.RegionSizeZ);
|
||||
Heightmap = new TerrainChannel(map);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
|
||||
@@ -80,9 +80,26 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
PinHeadIsland();
|
||||
}
|
||||
|
||||
public TerrainChannel(double[,] pM, uint pAltitude)
|
||||
// Create channel passed a heightmap and expected dimensions of the region.
|
||||
// The heightmap might not fit the passed size so accomodations must be made.
|
||||
public TerrainChannel(double[,] pM, int pSizeX, int pSizeY, int pAltitude)
|
||||
{
|
||||
m_terrainData = new HeightmapTerrainData(pM);
|
||||
int hmSizeX = pM.GetLength(0);
|
||||
int hmSizeY = pM.GetLength(1);
|
||||
|
||||
m_terrainData = new HeightmapTerrainData(pSizeX, pSizeY, pAltitude);
|
||||
|
||||
for (int xx = 0; xx < pSizeX; xx++)
|
||||
for (int yy = 0; yy < pSizeY; yy++)
|
||||
if (xx > hmSizeX || yy > hmSizeY)
|
||||
m_terrainData[xx, yy] = TerrainData.DefaultTerrainHeight;
|
||||
else
|
||||
m_terrainData[xx, yy] = (float)pM[xx, yy];
|
||||
}
|
||||
|
||||
public TerrainChannel(TerrainData pTerrData)
|
||||
{
|
||||
m_terrainData = pTerrData;
|
||||
}
|
||||
|
||||
#region ITerrainChannel Members
|
||||
@@ -247,7 +264,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
byte[] dataArray = (byte[])serializer.Deserialize(xmlReader);
|
||||
int index = 0;
|
||||
|
||||
m_terrainData = new HeightmapTerrainData(Width, Height, Altitude);
|
||||
m_terrainData = new HeightmapTerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
|
||||
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
@@ -317,9 +334,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
private void FlatLand()
|
||||
{
|
||||
for (int xx = 0; xx < Width; xx++)
|
||||
for (int yy = 0; yy < Height; yy++)
|
||||
m_terrainData[xx, yy] = 21;
|
||||
m_terrainData.ClearLand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user