diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/TerrainChannel.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 27 |
1 files changed, 21 insertions, 6 deletions
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 | } |