aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/TerrainData.cs34
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainChannel.cs4
2 files changed, 19 insertions, 19 deletions
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs
index 25f9ca6..6b1be4e 100644
--- a/OpenSim/Framework/TerrainData.cs
+++ b/OpenSim/Framework/TerrainData.cs
@@ -72,8 +72,8 @@ namespace OpenSim.Framework
72 return new HeightmapTerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob); 72 return new HeightmapTerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob);
73 } 73 }
74 74
75 // return a special compressed representation of the heightmap in shorts 75 // return a special compressed representation of the heightmap in ints
76 public abstract short[] GetCompressedMap(); 76 public abstract int[] GetCompressedMap();
77 public abstract float CompressionFactor { get; } 77 public abstract float CompressionFactor { get; }
78 78
79 public abstract float[] GetFloatsSerialized(); 79 public abstract float[] GetFloatsSerialized();
@@ -99,7 +99,7 @@ namespace OpenSim.Framework
99 Variable2D = 22, 99 Variable2D = 22,
100 // Terrain is 'int32, int32, int32, int16[]' where the ints are X and Y dimensions 100 // Terrain is 'int32, int32, int32, int16[]' where the ints are X and Y dimensions
101 // and third int is the 'compression factor'. The heights are compressed as 101 // and third int is the 'compression factor'. The heights are compressed as
102 // "short compressedHeight = (short)(height * compressionFactor);" 102 // "int compressedHeight = (int)(height * compressionFactor);"
103 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. 103 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256.
104 Compressed2D = 27, 104 Compressed2D = 27,
105 // A revision that is not listed above or any revision greater than this value is 'Legacy256'. 105 // A revision that is not listed above or any revision greater than this value is 'Legacy256'.
@@ -109,8 +109,8 @@ namespace OpenSim.Framework
109 // Version of terrain that is a heightmap. 109 // Version of terrain that is a heightmap.
110 // This should really be 'LLOptimizedHeightmapTerrainData' as it includes knowledge 110 // This should really be 'LLOptimizedHeightmapTerrainData' as it includes knowledge
111 // of 'patches' which are 16x16 terrain areas which can be sent separately to the viewer. 111 // of 'patches' which are 16x16 terrain areas which can be sent separately to the viewer.
112 // The heighmap is kept as an array of short integers. The integer values are converted to 112 // The heighmap is kept as an array of integers. The integer values are converted to
113 // and from floats by TerrainCompressionFactor. Shorts are used to limit storage used. 113 // and from floats by TerrainCompressionFactor.
114 public class HeightmapTerrainData : TerrainData 114 public class HeightmapTerrainData : TerrainData
115 { 115 {
116 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 116 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -121,7 +121,7 @@ namespace OpenSim.Framework
121 { 121 {
122 get { return FromCompressedHeight(m_heightmap[x, y]); } 122 get { return FromCompressedHeight(m_heightmap[x, y]); }
123 set { 123 set {
124 short newVal = ToCompressedHeight(value); 124 int newVal = ToCompressedHeight(value);
125 if (m_heightmap[x, y] != newVal) 125 if (m_heightmap[x, y] != newVal)
126 { 126 {
127 m_heightmap[x, y] = newVal; 127 m_heightmap[x, y] = newVal;
@@ -164,7 +164,7 @@ namespace OpenSim.Framework
164 // TerrainData.ClearLand(float) 164 // TerrainData.ClearLand(float)
165 public override void ClearLand(float pHeight) 165 public override void ClearLand(float pHeight)
166 { 166 {
167 short flatHeight = ToCompressedHeight(pHeight); 167 int flatHeight = ToCompressedHeight(pHeight);
168 for (int xx = 0; xx < SizeX; xx++) 168 for (int xx = 0; xx < SizeX; xx++)
169 for (int yy = 0; yy < SizeY; yy++) 169 for (int yy = 0; yy < SizeY; yy++)
170 m_heightmap[xx, yy] = flatHeight; 170 m_heightmap[xx, yy] = flatHeight;
@@ -214,9 +214,9 @@ namespace OpenSim.Framework
214 public override float CompressionFactor { get { return m_compressionFactor; } } 214 public override float CompressionFactor { get { return m_compressionFactor; } }
215 215
216 // TerrainData.GetCompressedMap 216 // TerrainData.GetCompressedMap
217 public override short[] GetCompressedMap() 217 public override int[] GetCompressedMap()
218 { 218 {
219 short[] newMap = new short[SizeX * SizeY]; 219 int[] newMap = new int[SizeX * SizeY];
220 220
221 int ind = 0; 221 int ind = 0;
222 for (int xx = 0; xx < SizeX; xx++) 222 for (int xx = 0; xx < SizeX; xx++)
@@ -230,7 +230,7 @@ namespace OpenSim.Framework
230 public override TerrainData Clone() 230 public override TerrainData Clone()
231 { 231 {
232 HeightmapTerrainData ret = new HeightmapTerrainData(SizeX, SizeY, SizeZ); 232 HeightmapTerrainData ret = new HeightmapTerrainData(SizeX, SizeY, SizeZ);
233 ret.m_heightmap = (short[,])this.m_heightmap.Clone(); 233 ret.m_heightmap = (int[,])this.m_heightmap.Clone();
234 return ret; 234 return ret;
235 } 235 }
236 236
@@ -267,19 +267,19 @@ namespace OpenSim.Framework
267 267
268 // ============================================================= 268 // =============================================================
269 269
270 private short[,] m_heightmap; 270 private int[,] m_heightmap;
271 // Remember subregions of the heightmap that has changed. 271 // Remember subregions of the heightmap that has changed.
272 private bool[,] m_taint; 272 private bool[,] m_taint;
273 273
274 // To save space (especially for large regions), keep the height as a short integer 274 // To save space (especially for large regions), keep the height as a short integer
275 // that is coded as the float height times the compression factor (usually '100' 275 // that is coded as the float height times the compression factor (usually '100'
276 // to make for two decimal points). 276 // to make for two decimal points).
277 public short ToCompressedHeight(double pHeight) 277 public int ToCompressedHeight(double pHeight)
278 { 278 {
279 return (short)(pHeight * CompressionFactor); 279 return (int)(pHeight * CompressionFactor);
280 } 280 }
281 281
282 public float FromCompressedHeight(short pHeight) 282 public float FromCompressedHeight(int pHeight)
283 { 283 {
284 return ((float)pHeight) / CompressionFactor; 284 return ((float)pHeight) / CompressionFactor;
285 } 285 }
@@ -293,7 +293,7 @@ namespace OpenSim.Framework
293 SizeZ = (int)Constants.RegionHeight; 293 SizeZ = (int)Constants.RegionHeight;
294 m_compressionFactor = 100.0f; 294 m_compressionFactor = 100.0f;
295 295
296 m_heightmap = new short[SizeX, SizeY]; 296 m_heightmap = new int[SizeX, SizeY];
297 for (int ii = 0; ii < SizeX; ii++) 297 for (int ii = 0; ii < SizeX; ii++)
298 { 298 {
299 for (int jj = 0; jj < SizeY; jj++) 299 for (int jj = 0; jj < SizeY; jj++)
@@ -315,14 +315,14 @@ namespace OpenSim.Framework
315 SizeY = pY; 315 SizeY = pY;
316 SizeZ = pZ; 316 SizeZ = pZ;
317 m_compressionFactor = 100.0f; 317 m_compressionFactor = 100.0f;
318 m_heightmap = new short[SizeX, SizeY]; 318 m_heightmap = new int[SizeX, SizeY];
319 m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; 319 m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize];
320 // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); 320 // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ);
321 ClearTaint(); 321 ClearTaint();
322 ClearLand(0f); 322 ClearLand(0f);
323 } 323 }
324 324
325 public HeightmapTerrainData(short[] cmap, float pCompressionFactor, int pX, int pY, int pZ) : this(pX, pY, pZ) 325 public HeightmapTerrainData(int[] cmap, float pCompressionFactor, int pX, int pY, int pZ) : this(pX, pY, pZ)
326 { 326 {
327 m_compressionFactor = pCompressionFactor; 327 m_compressionFactor = pCompressionFactor;
328 int ind = 0; 328 int ind = 0;
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
index cc040a6..3d563a6 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
@@ -363,8 +363,8 @@ namespace OpenSim.Region.Framework.Scenes
363 public int SizeY; 363 public int SizeY;
364 public int SizeZ; 364 public int SizeZ;
365 public float CompressionFactor; 365 public float CompressionFactor;
366 public short[] Map; 366 public int[] Map;
367 public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, short[] pMap) 367 public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, int[] pMap)
368 { 368 {
369 Version = 1; 369 Version = 1;
370 SizeX = pX; 370 SizeX = pX;