diff options
author | UbitUmarov | 2019-11-13 19:53:15 +0000 |
---|---|---|
committer | UbitUmarov | 2019-11-13 19:53:15 +0000 |
commit | d9d78c342328bd3ffabc1f71d5ce88296654d15b (patch) | |
tree | 7228628469473d62b49b0975ec40bae4bdbe121c /OpenSim/Region/CoreModules/World/Terrain | |
parent | limit max number of attachments to 38. All can be on same point (diff) | |
download | opensim-SC-d9d78c342328bd3ffabc1f71d5ce88296654d15b.zip opensim-SC-d9d78c342328bd3ffabc1f71d5ce88296654d15b.tar.gz opensim-SC-d9d78c342328bd3ffabc1f71d5ce88296654d15b.tar.bz2 opensim-SC-d9d78c342328bd3ffabc1f71d5ce88296654d15b.tar.xz |
Terrain: more double to float
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Terrain')
10 files changed, 49 insertions, 43 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainModifier.cs index 0e0a0e4..5e3232d 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainModifier.cs | |||
@@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
70 | /// <param name='y'> | 70 | /// <param name='y'> |
71 | /// Y. | 71 | /// Y. |
72 | /// </param> | 72 | /// </param> |
73 | double operate(double[,] map, TerrainModifierData data, int x, int y); | 73 | float operate(float[,] map, TerrainModifierData data, int x, int y); |
74 | } | 74 | } |
75 | 75 | ||
76 | } | 76 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/FillModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/FillModifier.cs index 32f1de9..a56b4a7 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/FillModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/FillModifier.cs | |||
@@ -80,10 +80,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers | |||
80 | return val; | 80 | return val; |
81 | } | 81 | } |
82 | 82 | ||
83 | public override double operate(double[,] map, TerrainModifierData data, int x, int y) | 83 | public override float operate(float[,] map, TerrainModifierData data, int x, int y) |
84 | { | 84 | { |
85 | double factor = this.computeBevel(data, x, y); | 85 | float factor = this.computeBevel(data, x, y); |
86 | double result = data.elevation - (data.elevation - data.bevelevation) * factor; | 86 | float result = data.elevation - (data.elevation - data.bevelevation) * factor; |
87 | return result; | 87 | return result; |
88 | } | 88 | } |
89 | 89 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/LowerModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/LowerModifier.cs index 2ab4bcc..4fb08ce 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/LowerModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/LowerModifier.cs | |||
@@ -79,10 +79,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers | |||
79 | 79 | ||
80 | } | 80 | } |
81 | 81 | ||
82 | public override double operate(double[,] map, TerrainModifierData data, int x, int y) | 82 | public override float operate(float[,] map, TerrainModifierData data, int x, int y) |
83 | { | 83 | { |
84 | double factor = this.computeBevel(data, x, y); | 84 | float factor = this.computeBevel(data, x, y); |
85 | double result = map[x, y] - (data.elevation - (data.elevation - data.bevelevation) * factor); | 85 | float result = map[x, y] - (data.elevation - (data.elevation - data.bevelevation) * factor); |
86 | return result; | 86 | return result; |
87 | } | 87 | } |
88 | 88 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/MaxModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/MaxModifier.cs index 0939c0a..cf4bfab 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/MaxModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/MaxModifier.cs | |||
@@ -79,10 +79,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers | |||
79 | 79 | ||
80 | } | 80 | } |
81 | 81 | ||
82 | public override double operate(double[,] map, TerrainModifierData data, int x, int y) | 82 | public override float operate(float[,] map, TerrainModifierData data, int x, int y) |
83 | { | 83 | { |
84 | double factor = this.computeBevel(data, x, y); | 84 | float factor = this.computeBevel(data, x, y); |
85 | double result = Math.Min(data.elevation - (data.elevation - data.bevelevation) * factor, map[x, y]); | 85 | float result = Math.Min(data.elevation - (data.elevation - data.bevelevation) * factor, map[x, y]); |
86 | return result; | 86 | return result; |
87 | } | 87 | } |
88 | 88 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/MinModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/MinModifier.cs index cbbccc0..7e8f6c8 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/MinModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/MinModifier.cs | |||
@@ -79,10 +79,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers | |||
79 | 79 | ||
80 | } | 80 | } |
81 | 81 | ||
82 | public override double operate(double[,] map, TerrainModifierData data, int x, int y) | 82 | public override float operate(float[,] map, TerrainModifierData data, int x, int y) |
83 | { | 83 | { |
84 | double factor = this.computeBevel(data, x, y); | 84 | float factor = this.computeBevel(data, x, y); |
85 | double result = Math.Max(data.elevation - (data.elevation - data.bevelevation) * factor, map[x, y]); | 85 | float result = Math.Max(data.elevation - (data.elevation - data.bevelevation) * factor, map[x, y]); |
86 | return result; | 86 | return result; |
87 | } | 87 | } |
88 | 88 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/NoiseModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/NoiseModifier.cs index d6b95d0..ea11ab5 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/NoiseModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/NoiseModifier.cs | |||
@@ -96,11 +96,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers | |||
96 | return val; | 96 | return val; |
97 | } | 97 | } |
98 | 98 | ||
99 | public override double operate(double[,] map, TerrainModifierData data, int x, int y) | 99 | public override float operate(float[,] map, TerrainModifierData data, int x, int y) |
100 | { | 100 | { |
101 | double factor = this.computeBevel(data, x, y); | 101 | float factor = this.computeBevel(data, x, y); |
102 | double noise = TerrainUtil.PerlinNoise2D((double)x / map.GetLength(0), (double)y / map.GetLength(1), 8, 1.0); | 102 | float noise = (float)TerrainUtil.PerlinNoise2D((double)x / map.GetLength(0), (double)y / map.GetLength(1), 8, 1.0); |
103 | return map[x, y] + (data.elevation - (data.elevation - data.bevelevation) * factor) * (noise - .5); | 103 | return map[x, y] + (data.elevation - (data.elevation - data.bevelevation) * factor) * (noise - .5f); |
104 | } | 104 | } |
105 | 105 | ||
106 | } | 106 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/RaiseModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/RaiseModifier.cs index 35fb9d6..9f5f59a 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/RaiseModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/RaiseModifier.cs | |||
@@ -79,10 +79,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers | |||
79 | 79 | ||
80 | } | 80 | } |
81 | 81 | ||
82 | public override double operate(double[,] map, TerrainModifierData data, int x, int y) | 82 | public override float operate(float[,] map, TerrainModifierData data, int x, int y) |
83 | { | 83 | { |
84 | double factor = this.computeBevel(data, x, y); | 84 | float factor = this.computeBevel(data, x, y); |
85 | double result = map[x, y] + (data.elevation - (data.elevation - data.bevelevation) * factor); | 85 | float result = map[x, y] + (data.elevation - (data.elevation - data.bevelevation) * factor); |
86 | return result; | 86 | return result; |
87 | } | 87 | } |
88 | 88 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/SmoothModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/SmoothModifier.cs index 9f8d5b2..1a4bb61 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Modifiers/SmoothModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Modifiers/SmoothModifier.cs | |||
@@ -95,22 +95,22 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers | |||
95 | return val; | 95 | return val; |
96 | } | 96 | } |
97 | 97 | ||
98 | public override double operate(double[,] map, TerrainModifierData data, int x, int y) | 98 | public override float operate(float[,] map, TerrainModifierData data, int x, int y) |
99 | { | 99 | { |
100 | double[] scale = new double[3]; | 100 | float[] scale = new float[3]; |
101 | scale[0] = data.elevation; | 101 | scale[0] = data.elevation; |
102 | scale[1] = ((1.0 - scale[0]) * data.bevelevation) / 8.0; | 102 | scale[1] = ((1.0f - scale[0]) * data.bevelevation) / 8.0f; |
103 | scale[2] = ((1.0 - scale[0]) * (1.0 - data.bevelevation)) / 16.0; | 103 | scale[2] = ((1.0f - scale[0]) * (1.0f - data.bevelevation)) / 16.0f; |
104 | int xMax = map.GetLength(0); | 104 | int xMax = map.GetLength(0); |
105 | int yMax = map.GetLength(1); | 105 | int yMax = map.GetLength(1); |
106 | double result; | 106 | float result; |
107 | if ((x == 0) || (y == 0) || (x == (xMax - 1)) || (y == (yMax - 1))) | 107 | if ((x == 0) || (y == 0) || (x == (xMax - 1)) || (y == (yMax - 1))) |
108 | { | 108 | { |
109 | result = map[x, y]; | 109 | result = map[x, y]; |
110 | } | 110 | } |
111 | else | 111 | else |
112 | { | 112 | { |
113 | result = 0.0; | 113 | result = 0.0f; |
114 | for(int yPos = (y - 2); yPos < (y + 3); yPos++) | 114 | for(int yPos = (y - 2); yPos < (y + 3); yPos++) |
115 | { | 115 | { |
116 | int yVal = (yPos <= 0) ? 0 : ((yPos < yMax) ? yPos : yMax - 1); | 116 | int yVal = (yPos <= 0) ? 0 : ((yPos < yMax) ? yPos : yMax - 1); |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs index e977a75..e808d1c 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
46 | 46 | ||
47 | public abstract string GetUsage(); | 47 | public abstract string GetUsage(); |
48 | 48 | ||
49 | public abstract double operate(double[,] map, TerrainModifierData data, int x, int y); | 49 | public abstract float operate(float[,] map, TerrainModifierData data, int x, int y); |
50 | 50 | ||
51 | protected String parseParameters(string[] args, out TerrainModifierData data) | 51 | protected String parseParameters(string[] args, out TerrainModifierData data) |
52 | { | 52 | { |
@@ -153,8 +153,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
153 | protected string parseFloat(String s, out float f) | 153 | protected string parseFloat(String s, out float f) |
154 | { | 154 | { |
155 | string result; | 155 | string result; |
156 | double d; | 156 | float d; |
157 | if (Double.TryParse(s, out d)) | 157 | if (float.TryParse(s, out d)) |
158 | { | 158 | { |
159 | try | 159 | try |
160 | { | 160 | { |
@@ -213,7 +213,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
213 | yMid = 0; | 213 | yMid = 0; |
214 | } | 214 | } |
215 | // m_log.DebugFormat("Apply {0} mask {1}x{2} @ {3},{4}", data.shape, xMax, yMax, xMid, yMid); | 215 | // m_log.DebugFormat("Apply {0} mask {1}x{2} @ {3},{4}", data.shape, xMax, yMax, xMid, yMid); |
216 | double[,] buffer = map.GetDoubles(); | 216 | |
217 | float[,] buffer = new float[map.Width, map.Height]; | ||
218 | for (int x = data.x0; x < xMax; ++x) | ||
219 | for (int y = data.y0; y < yMax; ++y) | ||
220 | buffer[x,y] = map[x,y]; | ||
221 | |||
217 | int yDim = yMax; | 222 | int yDim = yMax; |
218 | while(--yDim >= 0) | 223 | while(--yDim >= 0) |
219 | { | 224 | { |
@@ -224,6 +229,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
224 | while(--xDim >= 0) | 229 | while(--xDim >= 0) |
225 | { | 230 | { |
226 | int xPos = data.x0 + xDim - xMid; | 231 | int xPos = data.x0 + xDim - xMid; |
232 | |||
227 | if ((xPos >= 0) && (xPos < map.Width) && (mask[xDim, yDim])) | 233 | if ((xPos >= 0) && (xPos < map.Width) && (mask[xDim, yDim])) |
228 | { | 234 | { |
229 | double endElevation = this.operate(buffer, data, xPos, yPos); | 235 | double endElevation = this.operate(buffer, data, xPos, yPos); |
@@ -234,13 +240,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
234 | } | 240 | } |
235 | } | 241 | } |
236 | 242 | ||
237 | protected double computeBevel(TerrainModifierData data, int x, int y) | 243 | protected float computeBevel(TerrainModifierData data, int x, int y) |
238 | { | 244 | { |
239 | int deltaX; | 245 | int deltaX; |
240 | int deltaY; | 246 | int deltaY; |
241 | int xMax; | 247 | int xMax; |
242 | int yMax; | 248 | int yMax; |
243 | double factor; | 249 | float factor; |
244 | if (data.bevel == "taper") | 250 | if (data.bevel == "taper") |
245 | { | 251 | { |
246 | if (data.shape == "ellipse") | 252 | if (data.shape == "ellipse") |
@@ -249,7 +255,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
249 | deltaY = y - data.y0; | 255 | deltaY = y - data.y0; |
250 | xMax = data.dx; | 256 | xMax = data.dx; |
251 | yMax = data.dy; | 257 | yMax = data.dy; |
252 | factor = (double)((deltaX * deltaX) + (deltaY * deltaY)); | 258 | factor = ((deltaX * deltaX) + (deltaY * deltaY)); |
253 | factor /= ((xMax * xMax) + (yMax * yMax)); | 259 | factor /= ((xMax * xMax) + (yMax * yMax)); |
254 | } | 260 | } |
255 | else | 261 | else |
@@ -259,12 +265,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
259 | yMax = data.dy / 2 + data.dy % 2; | 265 | yMax = data.dy / 2 + data.dy % 2; |
260 | deltaX = Math.Abs(data.x0 + xMax - x); | 266 | deltaX = Math.Abs(data.x0 + xMax - x); |
261 | deltaY = Math.Abs(data.y0 + yMax - y); | 267 | deltaY = Math.Abs(data.y0 + yMax - y); |
262 | factor = Math.Max(((double)(deltaY) / yMax), ((double)(deltaX) / xMax)); | 268 | factor = Math.Max(((float)(deltaY) / yMax), ((float)(deltaX) / xMax)); |
263 | } | 269 | } |
264 | } | 270 | } |
265 | else | 271 | else |
266 | { | 272 | { |
267 | factor = 0.0; | 273 | factor = 0.0f; |
268 | } | 274 | } |
269 | return factor; | 275 | return factor; |
270 | } | 276 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index d73c89f..8f60d2f 100755 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -1832,19 +1832,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1832 | Command fillRegionCommand = | 1832 | Command fillRegionCommand = |
1833 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); | 1833 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); |
1834 | fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.", | 1834 | fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.", |
1835 | "Double"); | 1835 | "Float"); |
1836 | 1836 | ||
1837 | Command elevateCommand = | 1837 | Command elevateCommand = |
1838 | new Command("elevate", CommandIntentions.COMMAND_HAZARDOUS, InterfaceElevateTerrain, "Raises the current heightmap by the specified amount."); | 1838 | new Command("elevate", CommandIntentions.COMMAND_HAZARDOUS, InterfaceElevateTerrain, "Raises the current heightmap by the specified amount."); |
1839 | elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double"); | 1839 | elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Float"); |
1840 | 1840 | ||
1841 | Command lowerCommand = | 1841 | Command lowerCommand = |
1842 | new Command("lower", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount."); | 1842 | new Command("lower", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount."); |
1843 | lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double"); | 1843 | lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Float"); |
1844 | 1844 | ||
1845 | Command multiplyCommand = | 1845 | Command multiplyCommand = |
1846 | new Command("multiply", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified."); | 1846 | new Command("multiply", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified."); |
1847 | multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double"); | 1847 | multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Float"); |
1848 | 1848 | ||
1849 | Command bakeRegionCommand = | 1849 | Command bakeRegionCommand = |
1850 | new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions baked map."); | 1850 | new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions baked map."); |
@@ -1857,14 +1857,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1857 | 1857 | ||
1858 | Command rescaleCommand = | 1858 | Command rescaleCommand = |
1859 | new Command("rescale", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRescaleTerrain, "Rescales the current terrain to fit between the given min and max heights"); | 1859 | new Command("rescale", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRescaleTerrain, "Rescales the current terrain to fit between the given min and max heights"); |
1860 | rescaleCommand.AddArgument("min", "min terrain height after rescaling", "Double"); | 1860 | rescaleCommand.AddArgument("min", "min terrain height after rescaling", "Float"); |
1861 | rescaleCommand.AddArgument("max", "max terrain height after rescaling", "Double"); | 1861 | rescaleCommand.AddArgument("max", "max terrain height after rescaling", "Float"); |
1862 | 1862 | ||
1863 | Command minCommand = new Command("min", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMinTerrain, "Sets the minimum terrain height to the specified value."); | 1863 | Command minCommand = new Command("min", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMinTerrain, "Sets the minimum terrain height to the specified value."); |
1864 | minCommand.AddArgument("min", "terrain height to use as minimum", "Double"); | 1864 | minCommand.AddArgument("min", "terrain height to use as minimum", "Float"); |
1865 | 1865 | ||
1866 | Command maxCommand = new Command("max", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMaxTerrain, "Sets the maximum terrain height to the specified value."); | 1866 | Command maxCommand = new Command("max", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMaxTerrain, "Sets the maximum terrain height to the specified value."); |
1867 | maxCommand.AddArgument("min", "terrain height to use as maximum", "Double"); | 1867 | maxCommand.AddArgument("min", "terrain height to use as maximum", "Float"); |
1868 | 1868 | ||
1869 | 1869 | ||
1870 | // Debug | 1870 | // Debug |