diff options
author | UbitUmarov | 2019-11-12 18:19:12 +0000 |
---|---|---|
committer | UbitUmarov | 2019-11-12 18:19:12 +0000 |
commit | d10f11d31064f8d6fd6bccaf907897e07cd63cef (patch) | |
tree | 3636457b544b77f56dd175925cc6382429b5087d /OpenSim | |
parent | more changes on terrain edit. Silent ignore comand if busy (large area smoot... (diff) | |
download | opensim-SC-d10f11d31064f8d6fd6bccaf907897e07cd63cef.zip opensim-SC-d10f11d31064f8d6fd6bccaf907897e07cd63cef.tar.gz opensim-SC-d10f11d31064f8d6fd6bccaf907897e07cd63cef.tar.bz2 opensim-SC-d10f11d31064f8d6fd6bccaf907897e07cd63cef.tar.xz |
terrain replace double by float
Diffstat (limited to 'OpenSim')
18 files changed, 77 insertions, 76 deletions
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs index 1a2d5d1..0e5e83e 100644 --- a/OpenSim/Framework/TerrainData.cs +++ b/OpenSim/Framework/TerrainData.cs | |||
@@ -194,9 +194,6 @@ namespace OpenSim.Framework | |||
194 | return ret; | 194 | return ret; |
195 | } | 195 | } |
196 | 196 | ||
197 | // This one dimensional version is ordered so height = map[y*sizeX+x]; | ||
198 | // DEPRECATED: don't use this function as it does not retain the dimensions of the terrain | ||
199 | // and the caller will probably do the wrong thing if the terrain is not the legacy 256x256. | ||
200 | public float[] GetFloatsSerialized() | 197 | public float[] GetFloatsSerialized() |
201 | { | 198 | { |
202 | int points = SizeX * SizeY; | 199 | int points = SizeX * SizeY; |
@@ -485,7 +482,8 @@ namespace OpenSim.Framework | |||
485 | for (int yy = 0; yy < SizeY; yy++) | 482 | for (int yy = 0; yy < SizeY; yy++) |
486 | for (int xx = 0; xx < SizeX; xx++) | 483 | for (int xx = 0; xx < SizeX; xx++) |
487 | { | 484 | { |
488 | bw.Write((float)m_heightmap[xx, yy]); | 485 | //bw.Write((float)m_heightmap[xx, yy]); |
486 | bw.Write((float)Math.Round(m_heightmap[xx, yy], 3, MidpointRounding.AwayFromZero)); | ||
489 | } | 487 | } |
490 | 488 | ||
491 | bw.Flush(); | 489 | bw.Flush(); |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs index 39d8d49..3354817 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs | |||
@@ -68,14 +68,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects | |||
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | private void FillMap(ITerrainChannel map, double val) | 71 | private void FillMap(ITerrainChannel map, float val) |
72 | { | 72 | { |
73 | for (int x = 0; x < map.Width; x++) | 73 | for (int x = 0; x < map.Width; x++) |
74 | for (int y = 0; y < map.Height; y++) | 74 | for (int y = 0; y < map.Height; y++) |
75 | map[x, y] = val; | 75 | map[x, y] = val; |
76 | } | 76 | } |
77 | 77 | ||
78 | private void BuildTiles(ITerrainChannel map, double height) | 78 | private void BuildTiles(ITerrainChannel map, float height) |
79 | { | 79 | { |
80 | int channelWidth = (int) Math.Floor((map.Width / num_w) * 0.8); | 80 | int channelWidth = (int) Math.Floor((map.Width / num_w) * 0.8); |
81 | int channelHeight = (int) Math.Floor((map.Height / num_h) * 0.8); | 81 | int channelHeight = (int) Math.Floor((map.Height / num_h) * 0.8); |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs index 68d6ed2..4f6576f 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs | |||
@@ -131,7 +131,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
131 | for (x = 0; x < sectionWidth; x++) | 131 | for (x = 0; x < sectionWidth; x++) |
132 | { | 132 | { |
133 | // Read a strip and continue | 133 | // Read a strip and continue |
134 | retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 128.0); | 134 | retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 128.0f); |
135 | bs.ReadBytes(11); | 135 | bs.ReadBytes(11); |
136 | } | 136 | } |
137 | // record that we wrote it | 137 | // record that we wrote it |
@@ -171,7 +171,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
171 | int x; | 171 | int x; |
172 | for (x = 0; x < retval.Width; x++) | 172 | for (x = 0; x < retval.Width; x++) |
173 | { | 173 | { |
174 | retval[x, (retval.Height - 1) - y] = bs.ReadByte() * (bs.ReadByte() / 128.0); | 174 | retval[x, (retval.Height - 1) - y] = bs.ReadByte() * (bs.ReadByte() / 128.0f); |
175 | bs.ReadBytes(11); // Advance the stream to next bytes. | 175 | bs.ReadBytes(11); // Advance the stream to next bytes. |
176 | } | 176 | } |
177 | } | 177 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs index 219011e..d61a09a 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -120,7 +120,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
120 | for (int x = 0; x < sectionWidth; x++) | 120 | for (int x = 0; x < sectionWidth; x++) |
121 | { | 121 | { |
122 | // Read a strip and continue | 122 | // Read a strip and continue |
123 | retval[x, y] = baseHeight + bs.ReadInt16() * (double)heightScale / 65536.0; | 123 | retval[x, y] = baseHeight + bs.ReadInt16() * (float)heightScale / 65536.0f; |
124 | } | 124 | } |
125 | // record that we wrote it | 125 | // record that we wrote it |
126 | currFileXOffset++; | 126 | currFileXOffset++; |
@@ -188,13 +188,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
188 | eof = true; | 188 | eof = true; |
189 | // create new channel of proper size (now that we know it) | 189 | // create new channel of proper size (now that we know it) |
190 | retval = new TerrainChannel(w, h); | 190 | retval = new TerrainChannel(w, h); |
191 | double heightScale = (double)bs.ReadInt16() / 65536.0; | 191 | float heightScale = bs.ReadInt16() / 65536.0f; |
192 | double baseHeight = (double)bs.ReadInt16(); | 192 | float baseHeight = bs.ReadInt16(); |
193 | for (int y = 0; y < h; y++) | 193 | for (int y = 0; y < h; y++) |
194 | { | 194 | { |
195 | for (int x = 0; x < w; x++) | 195 | for (int x = 0; x < w; x++) |
196 | { | 196 | { |
197 | retval[x, y] = baseHeight + (double)bs.ReadInt16() * heightScale; | 197 | retval[x, y] = baseHeight + bs.ReadInt16() * heightScale; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | break; | 200 | break; |
@@ -222,14 +222,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
222 | BinaryWriter bs = new BinaryWriter(stream); | 222 | BinaryWriter bs = new BinaryWriter(stream); |
223 | 223 | ||
224 | //find the max and min heights on the map | 224 | //find the max and min heights on the map |
225 | double heightMax = map[0,0]; | 225 | float heightMax = map[0,0]; |
226 | double heightMin = map[0,0]; | 226 | float heightMin = map[0,0]; |
227 | 227 | ||
228 | for (int y = 0; y < map.Height; y++) | 228 | for (int y = 0; y < map.Height; y++) |
229 | { | 229 | { |
230 | for (int x = 0; x < map.Width; x++) | 230 | for (int x = 0; x < map.Width; x++) |
231 | { | 231 | { |
232 | double current = map[x,y]; | 232 | float current = map[x,y]; |
233 | if (heightMax < current) | 233 | if (heightMax < current) |
234 | heightMax = current; | 234 | heightMax = current; |
235 | if (heightMin > current) | 235 | if (heightMin > current) |
@@ -237,13 +237,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | double baseHeight = Math.Floor( (heightMax + heightMin) / 2d ); | 240 | float baseHeight = (float)Math.Floor(0.5f * (heightMax + heightMin)); |
241 | 241 | ||
242 | double horizontalScale = Math.Ceiling((heightMax - heightMin)); | 242 | float horizontalScale = (float) Math.Ceiling((heightMax - heightMin)); |
243 | 243 | ||
244 | // if we are completely flat add 1cm range to avoid NaN divisions | 244 | // if we are completely flat add 1cm range to avoid NaN divisions |
245 | if (horizontalScale < 0.01d) | 245 | if (horizontalScale < 0.01f) |
246 | horizontalScale = 0.01d; | 246 | horizontalScale = 0.01f; |
247 | 247 | ||
248 | Encoding enc = Encoding.ASCII; | 248 | Encoding enc = Encoding.ASCII; |
249 | 249 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs index 9569d08..58bf9dc 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes | |||
46 | for (int y = startY; y <= endY; y++) | 46 | for (int y = startY; y <= endY; y++) |
47 | { | 47 | { |
48 | if (fillArea[x, y]) | 48 | if (fillArea[x, y]) |
49 | map[x, y] = (map[x, y] * (1.0 - strength)) + (height * strength); | 49 | map[x, y] = (map[x, y] * (1.0f - strength)) + (height * strength); |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } | 52 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs index 26d77ea..b881fa0 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes | |||
47 | { | 47 | { |
48 | if (fillArea[x, y]) | 48 | if (fillArea[x, y]) |
49 | { | 49 | { |
50 | double noise = TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0); | 50 | float noise = (float)TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0); |
51 | map[x, y] += noise * strength; | 51 | map[x, y] += noise * strength; |
52 | } | 52 | } |
53 | } | 53 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs index c302c08..0e13096 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes | |||
48 | if(strength > 1.0f) | 48 | if(strength > 1.0f) |
49 | strength = 1.0f; | 49 | strength = 1.0f; |
50 | 50 | ||
51 | double[,] tweak = new double[endX - startX + 1, endX - startX + 1]; | 51 | float[,] tweak = new float[endX - startX + 1, endY - startY + 1]; |
52 | 52 | ||
53 | for (int x = startX, i = 0; x <= endX; x++, i++) | 53 | for (int x = startX, i = 0; x <= endX; x++, i++) |
54 | { | 54 | { |
@@ -57,15 +57,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes | |||
57 | if (!fillArea[x, y]) | 57 | if (!fillArea[x, y]) |
58 | continue; | 58 | continue; |
59 | 59 | ||
60 | double average = 0.0; | 60 | float average = 0f; |
61 | int avgsteps = 0; | 61 | int avgsteps = 0; |
62 | 62 | ||
63 | for (int n = x - sx; n <= x + sx; ++n) | 63 | for (int n = x - sx; n <= x + sx; ++n) |
64 | { | 64 | { |
65 | for (int l = y - sy; l < y + sy; ++l) | 65 | if (n >= 0 && n < map.Width) |
66 | { | 66 | { |
67 | avgsteps++; | 67 | for (int l = y - sy; l < y + sy; ++l) |
68 | average += map[n, l]; | 68 | { |
69 | if (l >= 0 && l < map.Height) | ||
70 | { | ||
71 | avgsteps++; | ||
72 | average += map[n, l]; | ||
73 | } | ||
74 | } | ||
69 | } | 75 | } |
70 | } | 76 | } |
71 | 77 | ||
@@ -77,11 +83,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes | |||
77 | { | 83 | { |
78 | for (int y = startY, j = 0; y <= endY; y++, j++) | 84 | for (int y = startY, j = 0; y <= endY; y++, j++) |
79 | { | 85 | { |
80 | double ty = tweak[i, j]; | 86 | float ty = tweak[i, j]; |
81 | if (ty == 0.0) | 87 | if (ty == 0.0) |
82 | continue; | 88 | continue; |
83 | 89 | ||
84 | map[x, y] = (1.0 - strength) * map[x, y] + strength * ty; | 90 | map[x, y] = (1.0f - strength) * map[x, y] + strength * ty; |
85 | } | 91 | } |
86 | } | 92 | } |
87 | } | 93 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs index 4e1d0fc..f19043f 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs | |||
@@ -50,10 +50,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes | |||
50 | 50 | ||
51 | // Calculate a cos-sphere and add it to the heighmap | 51 | // Calculate a cos-sphere and add it to the heighmap |
52 | double r = Math.Sqrt(dx2 + (y - ry) * (y - ry)); | 52 | double r = Math.Sqrt(dx2 + (y - ry) * (y - ry)); |
53 | double distancefactor = Math.Cos(r * size); | 53 | float distancefactor = (float)Math.Cos(r * size); |
54 | if (distancefactor > 0.0) | 54 | if (distancefactor > 0.0) |
55 | { | 55 | { |
56 | double newz = map[x, y] - distancefactor * strength; | 56 | float newz = map[x, y] - distancefactor * strength; |
57 | if (newz <= 0f) | 57 | if (newz <= 0f) |
58 | map[x, y] = 0f; | 58 | map[x, y] = 0f; |
59 | else | 59 | else |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs index ac6d1af..ab9a18f 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes | |||
58 | continue; | 58 | continue; |
59 | 59 | ||
60 | distancefactor = strength * (1.0f - distancefactor); | 60 | distancefactor = strength * (1.0f - distancefactor); |
61 | double noise = TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0); | 61 | float noise = (float)TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0); |
62 | map[x, y] += noise * distancefactor; | 62 | map[x, y] += noise * distancefactor; |
63 | } | 63 | } |
64 | } | 64 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs index 1946f27..5d50b25 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes | |||
51 | 51 | ||
52 | // Calculate a cos-sphere and add it to the heighmap | 52 | // Calculate a cos-sphere and add it to the heighmap |
53 | double r = Math.Sqrt(dx2 + (y - ry) * (y - ry)); | 53 | double r = Math.Sqrt(dx2 + (y - ry) * (y - ry)); |
54 | double distancefactor = Math.Cos(r * size); | 54 | float distancefactor = (float)Math.Cos(r * size); |
55 | if (distancefactor > 0.0) | 55 | if (distancefactor > 0.0) |
56 | map[x, y] += distancefactor * strength; | 56 | map[x, y] += distancefactor * strength; |
57 | } | 57 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs index 4b7d9a1..8d06fc2 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes | |||
68 | continue; | 68 | continue; |
69 | 69 | ||
70 | distancefactor = strength * (1.0f - distancefactor); | 70 | distancefactor = strength * (1.0f - distancefactor); |
71 | map[x, y] = (map[x, y] * (1.0 - distancefactor)) + (m_revertmap[x, y] * distancefactor); | 71 | map[x, y] = (map[x, y] * (1.0f - distancefactor)) + (m_revertmap[x, y] * distancefactor); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | } | 74 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs index 69efdb9..fa609e0 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs | |||
@@ -40,7 +40,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes | |||
40 | float distancefactor; | 40 | float distancefactor; |
41 | float dx2; | 41 | float dx2; |
42 | 42 | ||
43 | double[,] tweak = new double[endX - startX + 1, endX - startX + 1]; | 43 | float[,] tweak = new float[endX - startX + 1, endY - startY + 1]; |
44 | int ssize = (int)(size + 0.5); | 44 | int ssize = (int)(size + 0.5); |
45 | if(ssize > 4) | 45 | if(ssize > 4) |
46 | ssize = 4; | 46 | ssize = 4; |
@@ -64,16 +64,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes | |||
64 | { | 64 | { |
65 | distancefactor = strength * (1.0f - distancefactor); | 65 | distancefactor = strength * (1.0f - distancefactor); |
66 | 66 | ||
67 | double average = 0.0; | 67 | float average = 0f; |
68 | int avgsteps = 0; | 68 | int avgsteps = 0; |
69 | 69 | ||
70 | for (int n = x - ssize; n <= x + ssize; ++n) | 70 | for (int n = x - ssize; n <= x + ssize; ++n) |
71 | { | 71 | { |
72 | if(n > 0 && n < map.Width) | 72 | if(n >= 0 && n < map.Width) |
73 | { | 73 | { |
74 | for (int l = y - ssize; l <= y + ssize; ++l) | 74 | for (int l = y - ssize; l <= y + ssize; ++l) |
75 | { | 75 | { |
76 | if (l > 0 && l < map.Height) | 76 | if (l >= 0 && l < map.Height) |
77 | { | 77 | { |
78 | avgsteps++; | 78 | avgsteps++; |
79 | average += map[n, l]; | 79 | average += map[n, l]; |
@@ -91,10 +91,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes | |||
91 | { | 91 | { |
92 | for (int y = startY, j = 0; y <= endY; y++, j++) | 92 | for (int y = startY, j = 0; y <= endY; y++, j++) |
93 | { | 93 | { |
94 | double tz = tweak[i, j]; | 94 | float tz = tweak[i, j]; |
95 | if(tz != 0.0) | 95 | if(tz != 0.0) |
96 | { | 96 | { |
97 | double newz = map[x, y] - tz; | 97 | float newz = map[x, y] - tz; |
98 | if (newz > 0.0) | 98 | if (newz > 0.0) |
99 | map[x, y] = newz; | 99 | map[x, y] = newz; |
100 | } | 100 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs index c6e992f..e977a75 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs | |||
@@ -227,7 +227,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
227 | if ((xPos >= 0) && (xPos < map.Width) && (mask[xDim, yDim])) | 227 | if ((xPos >= 0) && (xPos < map.Width) && (mask[xDim, yDim])) |
228 | { | 228 | { |
229 | double endElevation = this.operate(buffer, data, xPos, yPos); | 229 | double endElevation = this.operate(buffer, data, xPos, yPos); |
230 | map[xPos, yPos] = endElevation; | 230 | map[xPos, yPos] = (float)endElevation; |
231 | } | 231 | } |
232 | } | 232 | } |
233 | } | 233 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index b98bc9d..d73c89f 100755 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -1564,8 +1564,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1564 | { | 1564 | { |
1565 | for (int y = 0; y < m_channel.Height / 2; y++) | 1565 | for (int y = 0; y < m_channel.Height / 2; y++) |
1566 | { | 1566 | { |
1567 | double height = m_channel[x, y]; | 1567 | float height = m_channel[x, y]; |
1568 | double flippedHeight = m_channel[x, (int)m_channel.Height - 1 - y]; | 1568 | float flippedHeight = m_channel[x, (int)m_channel.Height - 1 - y]; |
1569 | m_channel[x, y] = flippedHeight; | 1569 | m_channel[x, y] = flippedHeight; |
1570 | m_channel[x, (int)m_channel.Height - 1 - y] = height; | 1570 | m_channel[x, (int)m_channel.Height - 1 - y] = height; |
1571 | 1571 | ||
@@ -1578,8 +1578,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1578 | { | 1578 | { |
1579 | for (int x = 0; x < m_channel.Width / 2; x++) | 1579 | for (int x = 0; x < m_channel.Width / 2; x++) |
1580 | { | 1580 | { |
1581 | double height = m_channel[x, y]; | 1581 | float height = m_channel[x, y]; |
1582 | double flippedHeight = m_channel[(int)m_channel.Width - 1 - x, y]; | 1582 | float flippedHeight = m_channel[(int)m_channel.Width - 1 - x, y]; |
1583 | m_channel[x, y] = flippedHeight; | 1583 | m_channel[x, y] = flippedHeight; |
1584 | m_channel[(int)m_channel.Width - 1 - x, y] = height; | 1584 | m_channel[(int)m_channel.Width - 1 - x, y] = height; |
1585 | 1585 | ||
@@ -1594,11 +1594,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1594 | 1594 | ||
1595 | private void InterfaceRescaleTerrain(Object[] args) | 1595 | private void InterfaceRescaleTerrain(Object[] args) |
1596 | { | 1596 | { |
1597 | double desiredMin = (double)args[0]; | 1597 | float desiredMin = (float)args[0]; |
1598 | double desiredMax = (double)args[1]; | 1598 | float desiredMax = (float)args[1]; |
1599 | 1599 | ||
1600 | // determine desired scaling factor | 1600 | // determine desired scaling factor |
1601 | double desiredRange = desiredMax - desiredMin; | 1601 | float desiredRange = desiredMax - desiredMin; |
1602 | //m_log.InfoFormat("Desired {0}, {1} = {2}", new Object[] { desiredMin, desiredMax, desiredRange }); | 1602 | //m_log.InfoFormat("Desired {0}, {1} = {2}", new Object[] { desiredMin, desiredMax, desiredRange }); |
1603 | 1603 | ||
1604 | if (desiredRange == 0d) | 1604 | if (desiredRange == 0d) |
@@ -1609,8 +1609,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1609 | else | 1609 | else |
1610 | { | 1610 | { |
1611 | //work out current heightmap range | 1611 | //work out current heightmap range |
1612 | double currMin = double.MaxValue; | 1612 | float currMin = float.MaxValue; |
1613 | double currMax = double.MinValue; | 1613 | float currMax = float.MinValue; |
1614 | 1614 | ||
1615 | int width = m_channel.Width; | 1615 | int width = m_channel.Width; |
1616 | int height = m_channel.Height; | 1616 | int height = m_channel.Height; |
@@ -1619,7 +1619,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1619 | { | 1619 | { |
1620 | for(int y = 0; y < height; y++) | 1620 | for(int y = 0; y < height; y++) |
1621 | { | 1621 | { |
1622 | double currHeight = m_channel[x, y]; | 1622 | float currHeight = m_channel[x, y]; |
1623 | if (currHeight < currMin) | 1623 | if (currHeight < currMin) |
1624 | { | 1624 | { |
1625 | currMin = currHeight; | 1625 | currMin = currHeight; |
@@ -1631,8 +1631,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1631 | } | 1631 | } |
1632 | } | 1632 | } |
1633 | 1633 | ||
1634 | double currRange = currMax - currMin; | 1634 | float currRange = currMax - currMin; |
1635 | double scale = desiredRange / currRange; | 1635 | float scale = desiredRange / currRange; |
1636 | 1636 | ||
1637 | //m_log.InfoFormat("Current {0}, {1} = {2}", new Object[] { currMin, currMax, currRange }); | 1637 | //m_log.InfoFormat("Current {0}, {1} = {2}", new Object[] { currMin, currMax, currRange }); |
1638 | //m_log.InfoFormat("Scale = {0}", scale); | 1638 | //m_log.InfoFormat("Scale = {0}", scale); |
@@ -1642,7 +1642,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1642 | { | 1642 | { |
1643 | for(int y = 0; y < height; y++) | 1643 | for(int y = 0; y < height; y++) |
1644 | { | 1644 | { |
1645 | double currHeight = m_channel[x, y] - currMin; | 1645 | float currHeight = m_channel[x, y] - currMin; |
1646 | m_channel[x, y] = desiredMin + (currHeight * scale); | 1646 | m_channel[x, y] = desiredMin + (currHeight * scale); |
1647 | } | 1647 | } |
1648 | } | 1648 | } |
@@ -1652,7 +1652,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1652 | 1652 | ||
1653 | private void InterfaceElevateTerrain(Object[] args) | 1653 | private void InterfaceElevateTerrain(Object[] args) |
1654 | { | 1654 | { |
1655 | double val = (double)args[0]; | 1655 | float val = (float)args[0]; |
1656 | 1656 | ||
1657 | int x, y; | 1657 | int x, y; |
1658 | for (x = 0; x < m_channel.Width; x++) | 1658 | for (x = 0; x < m_channel.Width; x++) |
@@ -1663,7 +1663,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1663 | private void InterfaceMultiplyTerrain(Object[] args) | 1663 | private void InterfaceMultiplyTerrain(Object[] args) |
1664 | { | 1664 | { |
1665 | int x, y; | 1665 | int x, y; |
1666 | double val = (double)args[0]; | 1666 | float val = (float)args[0]; |
1667 | 1667 | ||
1668 | for (x = 0; x < m_channel.Width; x++) | 1668 | for (x = 0; x < m_channel.Width; x++) |
1669 | for (y = 0; y < m_channel.Height; y++) | 1669 | for (y = 0; y < m_channel.Height; y++) |
@@ -1673,7 +1673,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1673 | private void InterfaceLowerTerrain(Object[] args) | 1673 | private void InterfaceLowerTerrain(Object[] args) |
1674 | { | 1674 | { |
1675 | int x, y; | 1675 | int x, y; |
1676 | double val = (double)args[0]; | 1676 | float val = (float)args[0]; |
1677 | 1677 | ||
1678 | for (x = 0; x < m_channel.Width; x++) | 1678 | for (x = 0; x < m_channel.Width; x++) |
1679 | for (y = 0; y < m_channel.Height; y++) | 1679 | for (y = 0; y < m_channel.Height; y++) |
@@ -1683,7 +1683,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1683 | public void InterfaceFillTerrain(Object[] args) | 1683 | public void InterfaceFillTerrain(Object[] args) |
1684 | { | 1684 | { |
1685 | int x, y; | 1685 | int x, y; |
1686 | double val = (double)args[0]; | 1686 | float val = (float)args[0]; |
1687 | 1687 | ||
1688 | for (x = 0; x < m_channel.Width; x++) | 1688 | for (x = 0; x < m_channel.Width; x++) |
1689 | for (y = 0; y < m_channel.Height; y++) | 1689 | for (y = 0; y < m_channel.Height; y++) |
@@ -1693,7 +1693,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1693 | private void InterfaceMinTerrain(Object[] args) | 1693 | private void InterfaceMinTerrain(Object[] args) |
1694 | { | 1694 | { |
1695 | int x, y; | 1695 | int x, y; |
1696 | double val = (double)args[0]; | 1696 | float val = (float)args[0]; |
1697 | for (x = 0; x < m_channel.Width; x++) | 1697 | for (x = 0; x < m_channel.Width; x++) |
1698 | { | 1698 | { |
1699 | for(y = 0; y < m_channel.Height; y++) | 1699 | for(y = 0; y < m_channel.Height; y++) |
@@ -1706,7 +1706,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1706 | private void InterfaceMaxTerrain(Object[] args) | 1706 | private void InterfaceMaxTerrain(Object[] args) |
1707 | { | 1707 | { |
1708 | int x, y; | 1708 | int x, y; |
1709 | double val = (double)args[0]; | 1709 | float val = (float)args[0]; |
1710 | for (x = 0; x < m_channel.Width; x++) | 1710 | for (x = 0; x < m_channel.Width; x++) |
1711 | { | 1711 | { |
1712 | for(y = 0; y < m_channel.Height; y++) | 1712 | for(y = 0; y < m_channel.Height; y++) |
@@ -1733,8 +1733,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1733 | 1733 | ||
1734 | private void InterfaceShowDebugStats(Object[] args) | 1734 | private void InterfaceShowDebugStats(Object[] args) |
1735 | { | 1735 | { |
1736 | double max = Double.MinValue; | 1736 | float max = float.MinValue; |
1737 | double min = double.MaxValue; | 1737 | float min = float.MaxValue; |
1738 | double sum = 0; | 1738 | double sum = 0; |
1739 | 1739 | ||
1740 | int x; | 1740 | int x; |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs index b39e0a2..af202b3 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests | |||
75 | { | 75 | { |
76 | for (y=0; y<map.Height; y++) | 76 | for (y=0; y<map.Height; y++) |
77 | { | 77 | { |
78 | map[x,y] = 1.0; | 78 | map[x,y] = 1.0f; |
79 | } | 79 | } |
80 | } | 80 | } |
81 | effect = new LowerSphere(); | 81 | effect = new LowerSphere(); |
@@ -96,19 +96,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests | |||
96 | TerrainChannel x = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); | 96 | TerrainChannel x = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); |
97 | Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly."); | 97 | Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly."); |
98 | 98 | ||
99 | x[0, 0] = 1.0; | 99 | x[0, 0] = 1.0f; |
100 | Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly."); | 100 | Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly."); |
101 | 101 | ||
102 | x[0, 0] = 0; | 102 | x[0, 0] = 0; |
103 | x[0, 0] += 5.0; | 103 | x[0, 0] += 5.0f; |
104 | x[0, 0] -= 1.0; | 104 | x[0, 0] -= 1.0f; |
105 | Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error."); | 105 | Assert.That(x[0, 0] == 4.0f, "Terrain addition/subtraction error."); |
106 | 106 | ||
107 | x[0, 0] = 1.0; | 107 | x[0, 0] = 1.0f; |
108 | float[] floatsExport = x.GetFloatsSerialised(); | 108 | float[] floatsExport = x.GetFloatsSerialised(); |
109 | Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly."); | 109 | Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly."); |
110 | 110 | ||
111 | x[0, 0] = 1.0; | 111 | x[0, 0] = 1.0f; |
112 | Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly."); | 112 | Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly."); |
113 | Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly."); | 113 | Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly."); |
114 | 114 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs index 78db02a..9e1fa5b 100644 --- a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs +++ b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs | |||
@@ -36,7 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
36 | int Height { get;} // Y dimension | 36 | int Height { get;} // Y dimension |
37 | int Altitude { get;} // Z dimension | 37 | int Altitude { get;} // Z dimension |
38 | 38 | ||
39 | double this[int x, int y] { get; set; } | 39 | float this[int x, int y] { get; set; } |
40 | 40 | ||
41 | float GetHeightAtXYZ(float x, float y, float z); | 41 | float GetHeightAtXYZ(float x, float y, float z); |
42 | 42 | ||
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 28bbdda..2d959cc 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs | |||
@@ -119,10 +119,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
119 | return m_terrainData; | 119 | return m_terrainData; |
120 | } | 120 | } |
121 | 121 | ||
122 | // ITerrainChannel.GetFloatsSerialized() | ||
123 | // This one dimensional version is ordered so height = map[y*sizeX+x]; | 122 | // This one dimensional version is ordered so height = map[y*sizeX+x]; |
124 | // DEPRECATED: don't use this function as it does not retain the dimensions of the terrain | ||
125 | // and the caller will probably do the wrong thing if the terrain is not the legacy 256x256. | ||
126 | public float[] GetFloatsSerialised() | 123 | public float[] GetFloatsSerialised() |
127 | { | 124 | { |
128 | return m_terrainData.GetFloatsSerialized(); | 125 | return m_terrainData.GetFloatsSerialized(); |
@@ -147,12 +144,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
147 | } | 144 | } |
148 | 145 | ||
149 | // ITerrainChannel.this[x,y] | 146 | // ITerrainChannel.this[x,y] |
150 | public double this[int x, int y] | 147 | public float this[int x, int y] |
151 | { | 148 | { |
152 | get { | 149 | get { |
153 | if (x < 0 || x >= Width || y < 0 || y >= Height) | 150 | if (x < 0 || x >= Width || y < 0 || y >= Height) |
154 | return 0; | 151 | return 0; |
155 | return (double)m_terrainData[x, y]; | 152 | return m_terrainData[x, y]; |
156 | } | 153 | } |
157 | set | 154 | set |
158 | { | 155 | { |
@@ -492,7 +489,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
492 | float value; | 489 | float value; |
493 | value = BitConverter.ToSingle(dataArray, index); | 490 | value = BitConverter.ToSingle(dataArray, index); |
494 | index += 4; | 491 | index += 4; |
495 | this[x, y] = (double)value; | 492 | this[x, y] = value; |
496 | } | 493 | } |
497 | } | 494 | } |
498 | } | 495 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index ac6abb0..3cb0fe7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -599,7 +599,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
599 | 599 | ||
600 | if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0))) | 600 | if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0))) |
601 | { | 601 | { |
602 | World.Heightmap[x, y] = val; | 602 | World.Heightmap[x, y] = (float)val; |
603 | return 1; | 603 | return 1; |
604 | } | 604 | } |
605 | else | 605 | else |