From ff5885ab234bc9a7efda49eea0e2200711c4933c Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Fri, 1 Nov 2013 11:35:31 -0700
Subject: 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.
---
.../Framework/Interfaces/ISimulationDataService.cs | 9 ++++++++
.../Framework/Interfaces/ISimulationDataStore.cs | 9 ++++++++
OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++--
OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 27 +++++++++++++++++-----
4 files changed, 41 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
index 085b5ca..8948f04 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
@@ -68,13 +68,22 @@ namespace OpenSim.Region.Framework.Interfaces
///
/// HeightField data
/// region UUID
+ void StoreTerrain(TerrainData terrain, UUID regionID);
+
+ // Legacy version kept for downward compabibility
void StoreTerrain(double[,] terrain, UUID regionID);
///
/// Load the latest terrain revision from region storage
///
/// the region UUID
+ /// the X dimension of the region being filled
+ /// the Y dimension of the region being filled
+ /// the Z dimension of the region being filled
/// Heightfield data
+ TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
+
+ // Legacy version kept for downward compabibility
double[,] LoadTerrain(UUID regionID);
void StoreLandObject(ILandObject Parcel);
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
index 5ba5b31..917b5d1 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
@@ -79,13 +79,22 @@ namespace OpenSim.Region.Framework.Interfaces
///
/// HeightField data
/// region UUID
+ void StoreTerrain(TerrainData terrain, UUID regionID);
+
+ // Legacy version kept for downward compabibility
void StoreTerrain(double[,] terrain, UUID regionID);
///
/// Load the latest terrain revision from region storage
///
/// the region UUID
+ /// the X dimension of the terrain being filled
+ /// the Y dimension of the terrain being filled
+ /// the Z dimension of the terrain being filled
/// Heightfield data
+ TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
+
+ // Legacy version kept for downward compabibility
double[,] LoadTerrain(UUID regionID);
void StoreLandObject(ILandObject Parcel);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e2880e3..a19f31f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -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)
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
index d641c87..03499e8 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
@@ -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();
}
}
}
--
cgit v1.1