aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2013-11-01 11:35:31 -0700
committerRobert Adams2013-11-01 11:35:31 -0700
commitff5885ab234bc9a7efda49eea0e2200711c4933c (patch)
tree21ef180072b30891700f139792d34ca9b2c7e0d6 /OpenSim/Region
parentvarregion: fix problem of X/Y dimensions swapped and incorrect terrain (diff)
downloadopensim-SC_OLD-ff5885ab234bc9a7efda49eea0e2200711c4933c.zip
opensim-SC_OLD-ff5885ab234bc9a7efda49eea0e2200711c4933c.tar.gz
opensim-SC_OLD-ff5885ab234bc9a7efda49eea0e2200711c4933c.tar.bz2
opensim-SC_OLD-ff5885ab234bc9a7efda49eea0e2200711c4933c.tar.xz
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.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs9
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainChannel.cs27
4 files changed, 41 insertions, 8 deletions
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
68 /// </summary> 68 /// </summary>
69 /// <param name="ter">HeightField data</param> 69 /// <param name="ter">HeightField data</param>
70 /// <param name="regionID">region UUID</param> 70 /// <param name="regionID">region UUID</param>
71 void StoreTerrain(TerrainData terrain, UUID regionID);
72
73 // Legacy version kept for downward compabibility
71 void StoreTerrain(double[,] terrain, UUID regionID); 74 void StoreTerrain(double[,] terrain, UUID regionID);
72 75
73 /// <summary> 76 /// <summary>
74 /// Load the latest terrain revision from region storage 77 /// Load the latest terrain revision from region storage
75 /// </summary> 78 /// </summary>
76 /// <param name="regionID">the region UUID</param> 79 /// <param name="regionID">the region UUID</param>
80 /// <param name="sizeX">the X dimension of the region being filled</param>
81 /// <param name="sizeY">the Y dimension of the region being filled</param>
82 /// <param name="sizeZ">the Z dimension of the region being filled</param>
77 /// <returns>Heightfield data</returns> 83 /// <returns>Heightfield data</returns>
84 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
85
86 // Legacy version kept for downward compabibility
78 double[,] LoadTerrain(UUID regionID); 87 double[,] LoadTerrain(UUID regionID);
79 88
80 void StoreLandObject(ILandObject Parcel); 89 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
79 /// </summary> 79 /// </summary>
80 /// <param name="ter">HeightField data</param> 80 /// <param name="ter">HeightField data</param>
81 /// <param name="regionID">region UUID</param> 81 /// <param name="regionID">region UUID</param>
82 void StoreTerrain(TerrainData terrain, UUID regionID);
83
84 // Legacy version kept for downward compabibility
82 void StoreTerrain(double[,] terrain, UUID regionID); 85 void StoreTerrain(double[,] terrain, UUID regionID);
83 86
84 /// <summary> 87 /// <summary>
85 /// Load the latest terrain revision from region storage 88 /// Load the latest terrain revision from region storage
86 /// </summary> 89 /// </summary>
87 /// <param name="regionID">the region UUID</param> 90 /// <param name="regionID">the region UUID</param>
91 /// <param name="pSizeX">the X dimension of the terrain being filled</param>
92 /// <param name="pSizeY">the Y dimension of the terrain being filled</param>
93 /// <param name="pSizeZ">the Z dimension of the terrain being filled</param>
88 /// <returns>Heightfield data</returns> 94 /// <returns>Heightfield data</returns>
95 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
96
97 // Legacy version kept for downward compabibility
89 double[,] LoadTerrain(UUID regionID); 98 double[,] LoadTerrain(UUID regionID);
90 99
91 void StoreLandObject(ILandObject Parcel); 100 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
1894 { 1894 {
1895 try 1895 try
1896 { 1896 {
1897 double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID); 1897 TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
1898 if (map == null) 1898 if (map == null)
1899 { 1899 {
1900 // This should be in the Terrain module, but it isn't because 1900 // This should be in the Terrain module, but it isn't because
@@ -1911,7 +1911,7 @@ namespace OpenSim.Region.Framework.Scenes
1911 } 1911 }
1912 else 1912 else
1913 { 1913 {
1914 Heightmap = new TerrainChannel(map, RegionInfo.RegionSizeZ); 1914 Heightmap = new TerrainChannel(map);
1915 } 1915 }
1916 } 1916 }
1917 catch (IOException e) 1917 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
80 PinHeadIsland(); 80 PinHeadIsland();
81 } 81 }
82 82
83 public TerrainChannel(double[,] pM, uint pAltitude) 83 // Create channel passed a heightmap and expected dimensions of the region.
84 // The heightmap might not fit the passed size so accomodations must be made.
85 public TerrainChannel(double[,] pM, int pSizeX, int pSizeY, int pAltitude)
84 { 86 {
85 m_terrainData = new HeightmapTerrainData(pM); 87 int hmSizeX = pM.GetLength(0);
88 int hmSizeY = pM.GetLength(1);
89
90 m_terrainData = new HeightmapTerrainData(pSizeX, pSizeY, pAltitude);
91
92 for (int xx = 0; xx < pSizeX; xx++)
93 for (int yy = 0; yy < pSizeY; yy++)
94 if (xx > hmSizeX || yy > hmSizeY)
95 m_terrainData[xx, yy] = TerrainData.DefaultTerrainHeight;
96 else
97 m_terrainData[xx, yy] = (float)pM[xx, yy];
98 }
99
100 public TerrainChannel(TerrainData pTerrData)
101 {
102 m_terrainData = pTerrData;
86 } 103 }
87 104
88 #region ITerrainChannel Members 105 #region ITerrainChannel Members
@@ -247,7 +264,7 @@ namespace OpenSim.Region.Framework.Scenes
247 byte[] dataArray = (byte[])serializer.Deserialize(xmlReader); 264 byte[] dataArray = (byte[])serializer.Deserialize(xmlReader);
248 int index = 0; 265 int index = 0;
249 266
250 m_terrainData = new HeightmapTerrainData(Width, Height, Altitude); 267 m_terrainData = new HeightmapTerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
251 268
252 for (int y = 0; y < Height; y++) 269 for (int y = 0; y < Height; y++)
253 { 270 {
@@ -317,9 +334,7 @@ namespace OpenSim.Region.Framework.Scenes
317 334
318 private void FlatLand() 335 private void FlatLand()
319 { 336 {
320 for (int xx = 0; xx < Width; xx++) 337 m_terrainData.ClearLand();
321 for (int yy = 0; yy < Height; yy++)
322 m_terrainData[xx, yy] = 21;
323 } 338 }
324 } 339 }
325} 340}