diff options
author | Jeff Ames | 2008-05-01 14:31:30 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-01 14:31:30 +0000 |
commit | d51ce47b2d7635b17f3dd429158e8f59b78b83aa (patch) | |
tree | d3595bd5194199184059aa398b91a51dc6c799cf /OpenSim/Region/Environment/Modules/World/Terrain | |
parent | * Looks like I had the bamboo build right in the first place - it was just th... (diff) | |
download | opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.zip opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.gz opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.bz2 opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.xz |
Update svn properties. Minor formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain')
37 files changed, 4119 insertions, 4119 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs index 731326e..a2e0c40 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs | |||
@@ -1,124 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; | 29 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; |
30 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; | 30 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects | 32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects |
33 | { | 33 | { |
34 | internal class CookieCutter : ITerrainEffect | 34 | internal class CookieCutter : ITerrainEffect |
35 | { | 35 | { |
36 | #region ITerrainEffect Members | 36 | #region ITerrainEffect Members |
37 | 37 | ||
38 | public void RunEffect(ITerrainChannel map) | 38 | public void RunEffect(ITerrainChannel map) |
39 | { | 39 | { |
40 | SmoothArea smooth = new SmoothArea(); | 40 | SmoothArea smooth = new SmoothArea(); |
41 | ITerrainPaintableEffect eroder = new WeatherSphere(); | 41 | ITerrainPaintableEffect eroder = new WeatherSphere(); |
42 | 42 | ||
43 | bool[,] cliffMask = new bool[map.Width,map.Height]; | 43 | bool[,] cliffMask = new bool[map.Width,map.Height]; |
44 | bool[,] channelMask = new bool[map.Width,map.Height]; | 44 | bool[,] channelMask = new bool[map.Width,map.Height]; |
45 | bool[,] smoothMask = new bool[map.Width,map.Height]; | 45 | bool[,] smoothMask = new bool[map.Width,map.Height]; |
46 | 46 | ||
47 | Console.WriteLine("S1"); | 47 | Console.WriteLine("S1"); |
48 | 48 | ||
49 | // Step one, generate rough mask | 49 | // Step one, generate rough mask |
50 | int x, y; | 50 | int x, y; |
51 | for (x = 0; x < map.Width; x++) | 51 | for (x = 0; x < map.Width; x++) |
52 | { | 52 | { |
53 | for (y = 0; y < map.Height; y++) | 53 | for (y = 0; y < map.Height; y++) |
54 | { | 54 | { |
55 | Console.Write("."); | 55 | Console.Write("."); |
56 | smoothMask[x, y] = true; | 56 | smoothMask[x, y] = true; |
57 | 57 | ||
58 | // Start underwater | 58 | // Start underwater |
59 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5; | 59 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5; |
60 | // Add a little height. (terrain should now be above water, mostly.) | 60 | // Add a little height. (terrain should now be above water, mostly.) |
61 | map[x, y] += 20; | 61 | map[x, y] += 20; |
62 | 62 | ||
63 | int channelsX = 4; | 63 | int channelsX = 4; |
64 | int channelWidth = (map.Width / channelsX / 4); | 64 | int channelWidth = (map.Width / channelsX / 4); |
65 | int channelsY = 4; | 65 | int channelsY = 4; |
66 | int channelHeight = (map.Height / channelsY / 4); | 66 | int channelHeight = (map.Height / channelsY / 4); |
67 | 67 | ||
68 | SetLowerChannel(map, cliffMask, channelMask, x, y, channelsX, channelWidth, map.Width, x); | 68 | SetLowerChannel(map, cliffMask, channelMask, x, y, channelsX, channelWidth, map.Width, x); |
69 | SetLowerChannel(map, cliffMask, channelMask, x, y, channelsY, channelHeight, map.Height, y); | 69 | SetLowerChannel(map, cliffMask, channelMask, x, y, channelsY, channelHeight, map.Height, y); |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | Console.WriteLine("S2"); | 73 | Console.WriteLine("S2"); |
74 | //smooth.FloodEffect(map, smoothMask, 4.0); | 74 | //smooth.FloodEffect(map, smoothMask, 4.0); |
75 | 75 | ||
76 | Console.WriteLine("S3"); | 76 | Console.WriteLine("S3"); |
77 | for (x = 0; x < map.Width; x++) | 77 | for (x = 0; x < map.Width; x++) |
78 | { | 78 | { |
79 | for (y = 0; y < map.Height; y++) | 79 | for (y = 0; y < map.Height; y++) |
80 | { | 80 | { |
81 | if (cliffMask[x, y] == true) | 81 | if (cliffMask[x, y] == true) |
82 | eroder.PaintEffect(map, x, y, 4, 0.1); | 82 | eroder.PaintEffect(map, x, y, 4, 0.1); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | for (x = 0; x < map.Width; x += 2) | 86 | for (x = 0; x < map.Width; x += 2) |
87 | { | 87 | { |
88 | for (y = 0; y < map.Height; y += 2) | 88 | for (y = 0; y < map.Height; y += 2) |
89 | { | 89 | { |
90 | if (map[x, y] < 0.1) | 90 | if (map[x, y] < 0.1) |
91 | map[x, y] = 0.1; | 91 | map[x, y] = 0.1; |
92 | if (map[x, y] > 256) | 92 | if (map[x, y] > 256) |
93 | map[x, y] = 256; | 93 | map[x, y] = 256; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | //smooth.FloodEffect(map, smoothMask, 4.0); | 96 | //smooth.FloodEffect(map, smoothMask, 4.0); |
97 | } | 97 | } |
98 | 98 | ||
99 | #endregion | 99 | #endregion |
100 | 100 | ||
101 | private static void SetLowerChannel(ITerrainChannel map, bool[,] cliffMask, bool[,] channelMask, int x, int y, int numChannels, int channelWidth, | 101 | private static void SetLowerChannel(ITerrainChannel map, bool[,] cliffMask, bool[,] channelMask, int x, int y, int numChannels, int channelWidth, |
102 | int mapSize, int rp) | 102 | int mapSize, int rp) |
103 | { | 103 | { |
104 | for (int i = 0; i < numChannels; i++) | 104 | for (int i = 0; i < numChannels; i++) |
105 | { | 105 | { |
106 | double distanceToLine = Math.Abs(rp - ((mapSize / numChannels) * i)); | 106 | double distanceToLine = Math.Abs(rp - ((mapSize / numChannels) * i)); |
107 | 107 | ||
108 | if (distanceToLine < channelWidth) | 108 | if (distanceToLine < channelWidth) |
109 | { | 109 | { |
110 | if (channelMask[x, y]) | 110 | if (channelMask[x, y]) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Remove channels | 113 | // Remove channels |
114 | map[x, y] -= 10; | 114 | map[x, y] -= 10; |
115 | channelMask[x, y] = true; | 115 | channelMask[x, y] = true; |
116 | } | 116 | } |
117 | if (distanceToLine < 1) | 117 | if (distanceToLine < 1) |
118 | { | 118 | { |
119 | cliffMask[x, y] = true; | 119 | cliffMask[x, y] = true; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | } | 122 | } |
123 | } | 123 | } |
124 | } \ No newline at end of file | 124 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs index 9c35d4e..5bc6799 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs | |||
@@ -1,55 +1,55 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using OpenSim.Framework; | 27 | using OpenSim.Framework; |
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects |
31 | { | 31 | { |
32 | internal class DefaultTerrainGenerator : ITerrainEffect | 32 | internal class DefaultTerrainGenerator : ITerrainEffect |
33 | { | 33 | { |
34 | #region ITerrainEffect Members | 34 | #region ITerrainEffect Members |
35 | 35 | ||
36 | public void RunEffect(ITerrainChannel map) | 36 | public void RunEffect(ITerrainChannel map) |
37 | { | 37 | { |
38 | int x, y; | 38 | int x, y; |
39 | for (x = 0; x < map.Width; x++) | 39 | for (x = 0; x < map.Width; x++) |
40 | { | 40 | { |
41 | for (y = 0; y < map.Height; y++) | 41 | for (y = 0; y < map.Height; y++) |
42 | { | 42 | { |
43 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; | 43 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; |
44 | double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; | 44 | double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; |
45 | if (map[x, y] < spherFac) | 45 | if (map[x, y] < spherFac) |
46 | { | 46 | { |
47 | map[x, y] = spherFac; | 47 | map[x, y] = spherFac; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | #endregion | 53 | #endregion |
54 | } | 54 | } |
55 | } \ No newline at end of file | 55 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs index 4705dad..eb981d9 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs | |||
@@ -1,62 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// A generic windows bitmap loader. | 34 | /// A generic windows bitmap loader. |
35 | /// Should be capable of handling 24-bit RGB images. | 35 | /// Should be capable of handling 24-bit RGB images. |
36 | /// | 36 | /// |
37 | /// Uses the System.Drawing filesystem loader. | 37 | /// Uses the System.Drawing filesystem loader. |
38 | /// </summary> | 38 | /// </summary> |
39 | internal class BMP : GenericSystemDrawing | 39 | internal class BMP : GenericSystemDrawing |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Exports a file to a image on the disk using a System.Drawing exporter. | 42 | /// Exports a file to a image on the disk using a System.Drawing exporter. |
43 | /// </summary> | 43 | /// </summary> |
44 | /// <param name="filename">The target filename</param> | 44 | /// <param name="filename">The target filename</param> |
45 | /// <param name="map">The terrain channel being saved</param> | 45 | /// <param name="map">The terrain channel being saved</param> |
46 | public override void SaveFile(string filename, ITerrainChannel map) | 46 | public override void SaveFile(string filename, ITerrainChannel map) |
47 | { | 47 | { |
48 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 48 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
49 | 49 | ||
50 | colours.Save(filename, ImageFormat.Bmp); | 50 | colours.Save(filename, ImageFormat.Bmp); |
51 | } | 51 | } |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// The human readable version of the file format(s) this loader handles | 54 | /// The human readable version of the file format(s) this loader handles |
55 | /// </summary> | 55 | /// </summary> |
56 | /// <returns></returns> | 56 | /// <returns></returns> |
57 | public override string ToString() | 57 | public override string ToString() |
58 | { | 58 | { |
59 | return "BMP"; | 59 | return "BMP"; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } \ No newline at end of file | 62 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs index 9c2fedc..9bfe851 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | internal class GIF : GenericSystemDrawing | 33 | internal class GIF : GenericSystemDrawing |
34 | { | 34 | { |
35 | public override void SaveFile(string filename, ITerrainChannel map) | 35 | public override void SaveFile(string filename, ITerrainChannel map) |
36 | { | 36 | { |
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
38 | 38 | ||
39 | colours.Save(filename, ImageFormat.Gif); | 39 | colours.Save(filename, ImageFormat.Gif); |
40 | } | 40 | } |
41 | 41 | ||
42 | public override string ToString() | 42 | public override string ToString() |
43 | { | 43 | { |
44 | return "GIF"; | 44 | return "GIF"; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } \ No newline at end of file | 47 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index b5e6bd9..9730b16 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -1,172 +1,172 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using System.Drawing.Imaging; | 30 | using System.Drawing.Imaging; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// A virtual class designed to have methods overloaded, | 36 | /// A virtual class designed to have methods overloaded, |
37 | /// this class provides an interface for a generic image | 37 | /// this class provides an interface for a generic image |
38 | /// saving and loading mechanism, but does not specify the | 38 | /// saving and loading mechanism, but does not specify the |
39 | /// format. It should not be insubstantiated directly. | 39 | /// format. It should not be insubstantiated directly. |
40 | /// </summary> | 40 | /// </summary> |
41 | public class GenericSystemDrawing : ITerrainLoader | 41 | public class GenericSystemDrawing : ITerrainLoader |
42 | { | 42 | { |
43 | #region ITerrainLoader Members | 43 | #region ITerrainLoader Members |
44 | 44 | ||
45 | public string FileExtension | 45 | public string FileExtension |
46 | { | 46 | { |
47 | get { return ".gsd"; } | 47 | get { return ".gsd"; } |
48 | } | 48 | } |
49 | 49 | ||
50 | /// <summary> | 50 | /// <summary> |
51 | /// Loads a file from a specified filename on the disk, | 51 | /// Loads a file from a specified filename on the disk, |
52 | /// parses the image using the System.Drawing parsers | 52 | /// parses the image using the System.Drawing parsers |
53 | /// then returns a terrain channel. Values are | 53 | /// then returns a terrain channel. Values are |
54 | /// returned based on HSL brightness between 0m and 128m | 54 | /// returned based on HSL brightness between 0m and 128m |
55 | /// </summary> | 55 | /// </summary> |
56 | /// <param name="filename">The target image to load</param> | 56 | /// <param name="filename">The target image to load</param> |
57 | /// <returns>A terrain channel generated from the image.</returns> | 57 | /// <returns>A terrain channel generated from the image.</returns> |
58 | public virtual ITerrainChannel LoadFile(string filename) | 58 | public virtual ITerrainChannel LoadFile(string filename) |
59 | { | 59 | { |
60 | Bitmap file = new Bitmap(filename); | 60 | Bitmap file = new Bitmap(filename); |
61 | 61 | ||
62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); | 62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); |
63 | 63 | ||
64 | int x, y; | 64 | int x, y; |
65 | for (x = 0; x < file.Width; x++) | 65 | for (x = 0; x < file.Width; x++) |
66 | { | 66 | { |
67 | for (y = 0; y < file.Height; y++) | 67 | for (y = 0; y < file.Height; y++) |
68 | { | 68 | { |
69 | retval[x, y] = file.GetPixel(x, y).GetBrightness() * 128; | 69 | retval[x, y] = file.GetPixel(x, y).GetBrightness() * 128; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | return retval; | 73 | return retval; |
74 | } | 74 | } |
75 | 75 | ||
76 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 76 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
77 | { | 77 | { |
78 | throw new NotImplementedException(); | 78 | throw new NotImplementedException(); |
79 | } | 79 | } |
80 | 80 | ||
81 | /// <summary> | 81 | /// <summary> |
82 | /// Exports a file to a image on the disk using a System.Drawing exporter. | 82 | /// Exports a file to a image on the disk using a System.Drawing exporter. |
83 | /// </summary> | 83 | /// </summary> |
84 | /// <param name="filename">The target filename</param> | 84 | /// <param name="filename">The target filename</param> |
85 | /// <param name="map">The terrain channel being saved</param> | 85 | /// <param name="map">The terrain channel being saved</param> |
86 | public virtual void SaveFile(string filename, ITerrainChannel map) | 86 | public virtual void SaveFile(string filename, ITerrainChannel map) |
87 | { | 87 | { |
88 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 88 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
89 | 89 | ||
90 | colours.Save(filename, ImageFormat.Png); | 90 | colours.Save(filename, ImageFormat.Png); |
91 | } | 91 | } |
92 | 92 | ||
93 | #endregion | 93 | #endregion |
94 | 94 | ||
95 | public override string ToString() | 95 | public override string ToString() |
96 | { | 96 | { |
97 | return "SYS.DRAWING"; | 97 | return "SYS.DRAWING"; |
98 | } | 98 | } |
99 | 99 | ||
100 | /// <summary> | 100 | /// <summary> |
101 | /// Protected method, generates a grayscale bitmap | 101 | /// Protected method, generates a grayscale bitmap |
102 | /// image from a specified terrain channel. | 102 | /// image from a specified terrain channel. |
103 | /// </summary> | 103 | /// </summary> |
104 | /// <param name="map">The terrain channel to export to bitmap</param> | 104 | /// <param name="map">The terrain channel to export to bitmap</param> |
105 | /// <returns>A System.Drawing.Bitmap containing a grayscale image</returns> | 105 | /// <returns>A System.Drawing.Bitmap containing a grayscale image</returns> |
106 | protected Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map) | 106 | protected Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map) |
107 | { | 107 | { |
108 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 108 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
109 | 109 | ||
110 | int pallete = 256; | 110 | int pallete = 256; |
111 | 111 | ||
112 | Color[] grays = new Color[pallete]; | 112 | Color[] grays = new Color[pallete]; |
113 | for (int i = 0; i < grays.Length; i++) | 113 | for (int i = 0; i < grays.Length; i++) |
114 | { | 114 | { |
115 | grays[i] = Color.FromArgb(i, i, i); | 115 | grays[i] = Color.FromArgb(i, i, i); |
116 | } | 116 | } |
117 | 117 | ||
118 | for (int y = 0; y < map.Height; y++) | 118 | for (int y = 0; y < map.Height; y++) |
119 | { | 119 | { |
120 | for (int x = 0; x < map.Width; x++) | 120 | for (int x = 0; x < map.Width; x++) |
121 | { | 121 | { |
122 | // 512 is the largest possible height before colours clamp | 122 | // 512 is the largest possible height before colours clamp |
123 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1)); | 123 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1)); |
124 | 124 | ||
125 | // Handle error conditions | 125 | // Handle error conditions |
126 | if (colorindex > pallete - 1 || colorindex < 0) | 126 | if (colorindex > pallete - 1 || colorindex < 0) |
127 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); | 127 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); |
128 | else | 128 | else |
129 | bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]); | 129 | bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | return bmp; | 132 | return bmp; |
133 | } | 133 | } |
134 | 134 | ||
135 | /// <summary> | 135 | /// <summary> |
136 | /// Protected method, generates a coloured bitmap | 136 | /// Protected method, generates a coloured bitmap |
137 | /// image from a specified terrain channel. | 137 | /// image from a specified terrain channel. |
138 | /// </summary> | 138 | /// </summary> |
139 | /// <param name="map">The terrain channel to export to bitmap</param> | 139 | /// <param name="map">The terrain channel to export to bitmap</param> |
140 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> | 140 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> |
141 | protected Bitmap CreateBitmapFromMap(ITerrainChannel map) | 141 | protected Bitmap CreateBitmapFromMap(ITerrainChannel map) |
142 | { | 142 | { |
143 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 143 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); |
144 | 144 | ||
145 | int pallete = gradientmapLd.Height; | 145 | int pallete = gradientmapLd.Height; |
146 | 146 | ||
147 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 147 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
148 | Color[] colours = new Color[pallete]; | 148 | Color[] colours = new Color[pallete]; |
149 | 149 | ||
150 | for (int i = 0; i < pallete; i++) | 150 | for (int i = 0; i < pallete; i++) |
151 | { | 151 | { |
152 | colours[i] = gradientmapLd.GetPixel(0, i); | 152 | colours[i] = gradientmapLd.GetPixel(0, i); |
153 | } | 153 | } |
154 | 154 | ||
155 | for (int y = 0; y < map.Height; y++) | 155 | for (int y = 0; y < map.Height; y++) |
156 | { | 156 | { |
157 | for (int x = 0; x < map.Width; x++) | 157 | for (int x = 0; x < map.Width; x++) |
158 | { | 158 | { |
159 | // 512 is the largest possible height before colours clamp | 159 | // 512 is the largest possible height before colours clamp |
160 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); | 160 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); |
161 | 161 | ||
162 | // Handle error conditions | 162 | // Handle error conditions |
163 | if (colorindex > pallete - 1 || colorindex < 0) | 163 | if (colorindex > pallete - 1 || colorindex < 0) |
164 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); | 164 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); |
165 | else | 165 | else |
166 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); | 166 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | return bmp; | 169 | return bmp; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | } \ No newline at end of file | 172 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs index 39ade10..d58926e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs | |||
@@ -1,94 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using System.Drawing.Imaging; | 30 | using System.Drawing.Imaging; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
34 | { | 34 | { |
35 | public class JPEG : ITerrainLoader | 35 | public class JPEG : ITerrainLoader |
36 | { | 36 | { |
37 | #region ITerrainLoader Members | 37 | #region ITerrainLoader Members |
38 | 38 | ||
39 | public string FileExtension | 39 | public string FileExtension |
40 | { | 40 | { |
41 | get { return ".jpg"; } | 41 | get { return ".jpg"; } |
42 | } | 42 | } |
43 | 43 | ||
44 | public ITerrainChannel LoadFile(string filename) | 44 | public ITerrainChannel LoadFile(string filename) |
45 | { | 45 | { |
46 | throw new NotImplementedException(); | 46 | throw new NotImplementedException(); |
47 | } | 47 | } |
48 | 48 | ||
49 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 49 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
50 | { | 50 | { |
51 | throw new NotImplementedException(); | 51 | throw new NotImplementedException(); |
52 | } | 52 | } |
53 | 53 | ||
54 | public void SaveFile(string filename, ITerrainChannel map) | 54 | public void SaveFile(string filename, ITerrainChannel map) |
55 | { | 55 | { |
56 | Bitmap colours = CreateBitmapFromMap(map); | 56 | Bitmap colours = CreateBitmapFromMap(map); |
57 | 57 | ||
58 | colours.Save(filename, ImageFormat.Jpeg); | 58 | colours.Save(filename, ImageFormat.Jpeg); |
59 | } | 59 | } |
60 | 60 | ||
61 | #endregion | 61 | #endregion |
62 | 62 | ||
63 | public override string ToString() | 63 | public override string ToString() |
64 | { | 64 | { |
65 | return "JPEG"; | 65 | return "JPEG"; |
66 | } | 66 | } |
67 | 67 | ||
68 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) | 68 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) |
69 | { | 69 | { |
70 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 70 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); |
71 | 71 | ||
72 | int pallete = gradientmapLd.Height; | 72 | int pallete = gradientmapLd.Height; |
73 | 73 | ||
74 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 74 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
75 | Color[] colours = new Color[pallete]; | 75 | Color[] colours = new Color[pallete]; |
76 | 76 | ||
77 | for (int i = 0; i < pallete; i++) | 77 | for (int i = 0; i < pallete; i++) |
78 | { | 78 | { |
79 | colours[i] = gradientmapLd.GetPixel(0, i); | 79 | colours[i] = gradientmapLd.GetPixel(0, i); |
80 | } | 80 | } |
81 | 81 | ||
82 | for (int y = 0; y < map.Height; y++) | 82 | for (int y = 0; y < map.Height; y++) |
83 | { | 83 | { |
84 | for (int x = 0; x < map.Width; x++) | 84 | for (int x = 0; x < map.Width; x++) |
85 | { | 85 | { |
86 | // 512 is the largest possible height before colours clamp | 86 | // 512 is the largest possible height before colours clamp |
87 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); | 87 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); |
88 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); | 88 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | return bmp; | 91 | return bmp; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } \ No newline at end of file | 94 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs index 468ecc9..5d6723f 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs | |||
@@ -1,148 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
33 | { | 33 | { |
34 | public class LLRAW : ITerrainLoader | 34 | public class LLRAW : ITerrainLoader |
35 | { | 35 | { |
36 | #region ITerrainLoader Members | 36 | #region ITerrainLoader Members |
37 | 37 | ||
38 | public ITerrainChannel LoadFile(string filename) | 38 | public ITerrainChannel LoadFile(string filename) |
39 | { | 39 | { |
40 | TerrainChannel retval = new TerrainChannel(); | 40 | TerrainChannel retval = new TerrainChannel(); |
41 | 41 | ||
42 | FileInfo file = new FileInfo(filename); | 42 | FileInfo file = new FileInfo(filename); |
43 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 43 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
44 | BinaryReader bs = new BinaryReader(s); | 44 | BinaryReader bs = new BinaryReader(s); |
45 | int x, y; | 45 | int x, y; |
46 | for (y = 0; y < retval.Height; y++) | 46 | for (y = 0; y < retval.Height; y++) |
47 | { | 47 | { |
48 | for (x = 0; x < retval.Width; x++) | 48 | for (x = 0; x < retval.Width; x++) |
49 | { | 49 | { |
50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); | 50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); |
51 | bs.ReadBytes(11); // Advance the stream to next bytes. | 51 | bs.ReadBytes(11); // Advance the stream to next bytes. |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | bs.Close(); | 55 | bs.Close(); |
56 | s.Close(); | 56 | s.Close(); |
57 | 57 | ||
58 | return retval; | 58 | return retval; |
59 | } | 59 | } |
60 | 60 | ||
61 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 61 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
62 | { | 62 | { |
63 | throw new NotImplementedException(); | 63 | throw new NotImplementedException(); |
64 | } | 64 | } |
65 | 65 | ||
66 | public void SaveFile(string filename, ITerrainChannel map) | 66 | public void SaveFile(string filename, ITerrainChannel map) |
67 | { | 67 | { |
68 | FileInfo file = new FileInfo(filename); | 68 | FileInfo file = new FileInfo(filename); |
69 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | 69 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); |
70 | BinaryWriter binStream = new BinaryWriter(s); | 70 | BinaryWriter binStream = new BinaryWriter(s); |
71 | 71 | ||
72 | // Generate a smegging big lookup table to speed the operation up (it needs it) | 72 | // Generate a smegging big lookup table to speed the operation up (it needs it) |
73 | double[] lookupHeightTable = new double[65536]; | 73 | double[] lookupHeightTable = new double[65536]; |
74 | int i, j, x, y; | 74 | int i, j, x, y; |
75 | for (i = 0; i < 256; i++) | 75 | for (i = 0; i < 256; i++) |
76 | { | 76 | { |
77 | for (j = 0; j < 256; j++) | 77 | for (j = 0; j < 256; j++) |
78 | { | 78 | { |
79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); | 79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | // Output the calculated raw | 83 | // Output the calculated raw |
84 | for (y = 0; y < map.Height; y++) | 84 | for (y = 0; y < map.Height; y++) |
85 | { | 85 | { |
86 | for (x = 0; x < map.Width; x++) | 86 | for (x = 0; x < map.Width; x++) |
87 | { | 87 | { |
88 | double t = map[x, y]; | 88 | double t = map[x, y]; |
89 | double min = double.MaxValue; | 89 | double min = double.MaxValue; |
90 | int index = 0; | 90 | int index = 0; |
91 | 91 | ||
92 | for (i = 0; i < 65536; i++) | 92 | for (i = 0; i < 65536; i++) |
93 | { | 93 | { |
94 | if (Math.Abs(t - lookupHeightTable[i]) < min) | 94 | if (Math.Abs(t - lookupHeightTable[i]) < min) |
95 | { | 95 | { |
96 | min = Math.Abs(t - lookupHeightTable[i]); | 96 | min = Math.Abs(t - lookupHeightTable[i]); |
97 | index = i; | 97 | index = i; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | byte red = (byte) (index & 0xFF); | 101 | byte red = (byte) (index & 0xFF); |
102 | byte green = (byte) ((index >> 8) & 0xFF); | 102 | byte green = (byte) ((index >> 8) & 0xFF); |
103 | byte blue = 20; | 103 | byte blue = 20; |
104 | byte alpha1 = 0; // Land Parcels | 104 | byte alpha1 = 0; // Land Parcels |
105 | byte alpha2 = 0; // For Sale Land | 105 | byte alpha2 = 0; // For Sale Land |
106 | byte alpha3 = 0; // Public Edit Object | 106 | byte alpha3 = 0; // Public Edit Object |
107 | byte alpha4 = 0; // Public Edit Land | 107 | byte alpha4 = 0; // Public Edit Land |
108 | byte alpha5 = 255; // Safe Land | 108 | byte alpha5 = 255; // Safe Land |
109 | byte alpha6 = 255; // Flying Allowed | 109 | byte alpha6 = 255; // Flying Allowed |
110 | byte alpha7 = 255; // Create Landmark | 110 | byte alpha7 = 255; // Create Landmark |
111 | byte alpha8 = 255; // Outside Scripts | 111 | byte alpha8 = 255; // Outside Scripts |
112 | byte alpha9 = red; | 112 | byte alpha9 = red; |
113 | byte alpha10 = green; | 113 | byte alpha10 = green; |
114 | 114 | ||
115 | binStream.Write(red); | 115 | binStream.Write(red); |
116 | binStream.Write(green); | 116 | binStream.Write(green); |
117 | binStream.Write(blue); | 117 | binStream.Write(blue); |
118 | binStream.Write(alpha1); | 118 | binStream.Write(alpha1); |
119 | binStream.Write(alpha2); | 119 | binStream.Write(alpha2); |
120 | binStream.Write(alpha3); | 120 | binStream.Write(alpha3); |
121 | binStream.Write(alpha4); | 121 | binStream.Write(alpha4); |
122 | binStream.Write(alpha5); | 122 | binStream.Write(alpha5); |
123 | binStream.Write(alpha6); | 123 | binStream.Write(alpha6); |
124 | binStream.Write(alpha7); | 124 | binStream.Write(alpha7); |
125 | binStream.Write(alpha8); | 125 | binStream.Write(alpha8); |
126 | binStream.Write(alpha9); | 126 | binStream.Write(alpha9); |
127 | binStream.Write(alpha10); | 127 | binStream.Write(alpha10); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | binStream.Close(); | 131 | binStream.Close(); |
132 | s.Close(); | 132 | s.Close(); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | public string FileExtension | 136 | public string FileExtension |
137 | { | 137 | { |
138 | get { return ".raw"; } | 138 | get { return ".raw"; } |
139 | } | 139 | } |
140 | 140 | ||
141 | #endregion | 141 | #endregion |
142 | 142 | ||
143 | public override string ToString() | 143 | public override string ToString() |
144 | { | 144 | { |
145 | return "LL/SL RAW"; | 145 | return "LL/SL RAW"; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | } \ No newline at end of file | 148 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs index 2925c7d..b893f70 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | internal class PNG : GenericSystemDrawing | 33 | internal class PNG : GenericSystemDrawing |
34 | { | 34 | { |
35 | public override void SaveFile(string filename, ITerrainChannel map) | 35 | public override void SaveFile(string filename, ITerrainChannel map) |
36 | { | 36 | { |
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
38 | 38 | ||
39 | colours.Save(filename, ImageFormat.Png); | 39 | colours.Save(filename, ImageFormat.Png); |
40 | } | 40 | } |
41 | 41 | ||
42 | public override string ToString() | 42 | public override string ToString() |
43 | { | 43 | { |
44 | return "PNG"; | 44 | return "PNG"; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } \ No newline at end of file | 47 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs index 71f56c5..fd2136c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs | |||
@@ -1,153 +1,153 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.IO; | 28 | using System.IO; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | public class RAW32 : ITerrainLoader | 33 | public class RAW32 : ITerrainLoader |
34 | { | 34 | { |
35 | #region ITerrainLoader Members | 35 | #region ITerrainLoader Members |
36 | 36 | ||
37 | public string FileExtension | 37 | public string FileExtension |
38 | { | 38 | { |
39 | get { return ".r32"; } | 39 | get { return ".r32"; } |
40 | } | 40 | } |
41 | 41 | ||
42 | public ITerrainChannel LoadFile(string filename) | 42 | public ITerrainChannel LoadFile(string filename) |
43 | { | 43 | { |
44 | TerrainChannel retval = new TerrainChannel(); | 44 | TerrainChannel retval = new TerrainChannel(); |
45 | 45 | ||
46 | FileInfo file = new FileInfo(filename); | 46 | FileInfo file = new FileInfo(filename); |
47 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 47 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
48 | BinaryReader bs = new BinaryReader(s); | 48 | BinaryReader bs = new BinaryReader(s); |
49 | int x, y; | 49 | int x, y; |
50 | for (y = 0; y < retval.Height; y++) | 50 | for (y = 0; y < retval.Height; y++) |
51 | { | 51 | { |
52 | for (x = 0; x < retval.Width; x++) | 52 | for (x = 0; x < retval.Width; x++) |
53 | { | 53 | { |
54 | retval[x, y] = bs.ReadSingle(); | 54 | retval[x, y] = bs.ReadSingle(); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | bs.Close(); | 58 | bs.Close(); |
59 | s.Close(); | 59 | s.Close(); |
60 | 60 | ||
61 | return retval; | 61 | return retval; |
62 | } | 62 | } |
63 | 63 | ||
64 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) | 64 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) |
65 | { | 65 | { |
66 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); | 66 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); |
67 | 67 | ||
68 | FileInfo file = new FileInfo(filename); | 68 | FileInfo file = new FileInfo(filename); |
69 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 69 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
70 | BinaryReader bs = new BinaryReader(s); | 70 | BinaryReader bs = new BinaryReader(s); |
71 | 71 | ||
72 | int currFileXOffset = 0; | 72 | int currFileXOffset = 0; |
73 | int currFileYOffset = 0; | 73 | int currFileYOffset = 0; |
74 | 74 | ||
75 | // if our region isn't on the first Y section of the areas to be landscaped, then | 75 | // if our region isn't on the first Y section of the areas to be landscaped, then |
76 | // advance to our section of the file | 76 | // advance to our section of the file |
77 | while (currFileYOffset < offsetY) | 77 | while (currFileYOffset < offsetY) |
78 | { | 78 | { |
79 | // read a whole strip of regions | 79 | // read a whole strip of regions |
80 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); | 80 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); |
81 | bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file | 81 | bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file |
82 | currFileYOffset++; | 82 | currFileYOffset++; |
83 | } | 83 | } |
84 | 84 | ||
85 | // got to the Y start offset within the file of our region | 85 | // got to the Y start offset within the file of our region |
86 | // so read the file bits associated with our region | 86 | // so read the file bits associated with our region |
87 | int x, y; | 87 | int x, y; |
88 | // for each Y within our Y offset | 88 | // for each Y within our Y offset |
89 | for (y = 0; y < sectionHeight; y++) | 89 | for (y = 0; y < sectionHeight; y++) |
90 | { | 90 | { |
91 | currFileXOffset = 0; | 91 | currFileXOffset = 0; |
92 | 92 | ||
93 | // if our region isn't the first X section of the areas to be landscaped, then | 93 | // if our region isn't the first X section of the areas to be landscaped, then |
94 | // advance the stream to the X start pos of our section in the file | 94 | // advance the stream to the X start pos of our section in the file |
95 | // i.e. eat X upto where we start | 95 | // i.e. eat X upto where we start |
96 | while (currFileXOffset < offsetX) | 96 | while (currFileXOffset < offsetX) |
97 | { | 97 | { |
98 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | 98 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single |
99 | currFileXOffset++; | 99 | currFileXOffset++; |
100 | } | 100 | } |
101 | 101 | ||
102 | // got to our X offset, so write our regions X line | 102 | // got to our X offset, so write our regions X line |
103 | for (x = 0; x < sectionWidth; x++) | 103 | for (x = 0; x < sectionWidth; x++) |
104 | { | 104 | { |
105 | // Read a strip and continue | 105 | // Read a strip and continue |
106 | retval[x, y] = bs.ReadSingle(); | 106 | retval[x, y] = bs.ReadSingle(); |
107 | } | 107 | } |
108 | // record that we wrote it | 108 | // record that we wrote it |
109 | currFileXOffset++; | 109 | currFileXOffset++; |
110 | 110 | ||
111 | // if our region isn't the last X section of the areas to be landscaped, then | 111 | // if our region isn't the last X section of the areas to be landscaped, then |
112 | // advance the stream to the end of this Y column | 112 | // advance the stream to the end of this Y column |
113 | while (currFileXOffset < fileWidth) | 113 | while (currFileXOffset < fileWidth) |
114 | { | 114 | { |
115 | // eat the next regions x line | 115 | // eat the next regions x line |
116 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | 116 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single |
117 | currFileXOffset++; | 117 | currFileXOffset++; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | bs.Close(); | 121 | bs.Close(); |
122 | s.Close(); | 122 | s.Close(); |
123 | 123 | ||
124 | return retval; | 124 | return retval; |
125 | } | 125 | } |
126 | 126 | ||
127 | public void SaveFile(string filename, ITerrainChannel map) | 127 | public void SaveFile(string filename, ITerrainChannel map) |
128 | { | 128 | { |
129 | FileInfo file = new FileInfo(filename); | 129 | FileInfo file = new FileInfo(filename); |
130 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); | 130 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); |
131 | BinaryWriter bs = new BinaryWriter(s); | 131 | BinaryWriter bs = new BinaryWriter(s); |
132 | 132 | ||
133 | int x, y; | 133 | int x, y; |
134 | for (y = 0; y < map.Height; y++) | 134 | for (y = 0; y < map.Height; y++) |
135 | { | 135 | { |
136 | for (x = 0; x < map.Width; x++) | 136 | for (x = 0; x < map.Width; x++) |
137 | { | 137 | { |
138 | bs.Write((float) map[x, y]); | 138 | bs.Write((float) map[x, y]); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | bs.Close(); | 142 | bs.Close(); |
143 | s.Close(); | 143 | s.Close(); |
144 | } | 144 | } |
145 | 145 | ||
146 | #endregion | 146 | #endregion |
147 | 147 | ||
148 | public override string ToString() | 148 | public override string ToString() |
149 | { | 149 | { |
150 | return "RAW32"; | 150 | return "RAW32"; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } \ No newline at end of file | 153 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs index 3a137ae..c081aea 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
32 | { | 32 | { |
33 | internal class TIFF : GenericSystemDrawing | 33 | internal class TIFF : GenericSystemDrawing |
34 | { | 34 | { |
35 | public override void SaveFile(string filename, ITerrainChannel map) | 35 | public override void SaveFile(string filename, ITerrainChannel map) |
36 | { | 36 | { |
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | 37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); |
38 | 38 | ||
39 | colours.Save(filename, ImageFormat.Tiff); | 39 | colours.Save(filename, ImageFormat.Tiff); |
40 | } | 40 | } |
41 | 41 | ||
42 | public override string ToString() | 42 | public override string ToString() |
43 | { | 43 | { |
44 | return "TIFF"; | 44 | return "TIFF"; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } \ No newline at end of file | 47 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs index f2672ad..7cb4b00 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -1,127 +1,127 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// Terragen File Format Loader | 36 | /// Terragen File Format Loader |
37 | /// Built from specification at | 37 | /// Built from specification at |
38 | /// http://www.planetside.co.uk/terragen/dev/tgterrain.html | 38 | /// http://www.planetside.co.uk/terragen/dev/tgterrain.html |
39 | /// </summary> | 39 | /// </summary> |
40 | internal class Terragen : ITerrainLoader | 40 | internal class Terragen : ITerrainLoader |
41 | { | 41 | { |
42 | #region ITerrainLoader Members | 42 | #region ITerrainLoader Members |
43 | 43 | ||
44 | public ITerrainChannel LoadFile(string filename) | 44 | public ITerrainChannel LoadFile(string filename) |
45 | { | 45 | { |
46 | TerrainChannel retval = new TerrainChannel(); | 46 | TerrainChannel retval = new TerrainChannel(); |
47 | 47 | ||
48 | FileInfo file = new FileInfo(filename); | 48 | FileInfo file = new FileInfo(filename); |
49 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 49 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
50 | BinaryReader bs = new BinaryReader(s); | 50 | BinaryReader bs = new BinaryReader(s); |
51 | 51 | ||
52 | bool eof = false; | 52 | bool eof = false; |
53 | if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") | 53 | if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") |
54 | { | 54 | { |
55 | // Terragen file | 55 | // Terragen file |
56 | while (eof == false) | 56 | while (eof == false) |
57 | { | 57 | { |
58 | int w = 256; | 58 | int w = 256; |
59 | int h = 256; | 59 | int h = 256; |
60 | string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); | 60 | string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); |
61 | switch (tmp) | 61 | switch (tmp) |
62 | { | 62 | { |
63 | case "SIZE": | 63 | case "SIZE": |
64 | int sztmp = bs.ReadInt16() + 1; | 64 | int sztmp = bs.ReadInt16() + 1; |
65 | w = sztmp; | 65 | w = sztmp; |
66 | h = sztmp; | 66 | h = sztmp; |
67 | bs.ReadInt16(); | 67 | bs.ReadInt16(); |
68 | break; | 68 | break; |
69 | case "XPTS": | 69 | case "XPTS": |
70 | w = bs.ReadInt16(); | 70 | w = bs.ReadInt16(); |
71 | bs.ReadInt16(); | 71 | bs.ReadInt16(); |
72 | break; | 72 | break; |
73 | case "YPTS": | 73 | case "YPTS": |
74 | h = bs.ReadInt16(); | 74 | h = bs.ReadInt16(); |
75 | bs.ReadInt16(); | 75 | bs.ReadInt16(); |
76 | break; | 76 | break; |
77 | case "ALTW": | 77 | case "ALTW": |
78 | eof = true; | 78 | eof = true; |
79 | Int16 heightScale = bs.ReadInt16(); | 79 | Int16 heightScale = bs.ReadInt16(); |
80 | Int16 baseHeight = bs.ReadInt16(); | 80 | Int16 baseHeight = bs.ReadInt16(); |
81 | retval = new TerrainChannel(w, h); | 81 | retval = new TerrainChannel(w, h); |
82 | int x, y; | 82 | int x, y; |
83 | for (x = 0; x < w; x++) | 83 | for (x = 0; x < w; x++) |
84 | { | 84 | { |
85 | for (y = 0; y < h; y++) | 85 | for (y = 0; y < h; y++) |
86 | { | 86 | { |
87 | retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; | 87 | retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | break; | 90 | break; |
91 | default: | 91 | default: |
92 | bs.ReadInt32(); | 92 | bs.ReadInt32(); |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | bs.Close(); | 98 | bs.Close(); |
99 | s.Close(); | 99 | s.Close(); |
100 | 100 | ||
101 | return retval; | 101 | return retval; |
102 | } | 102 | } |
103 | 103 | ||
104 | public void SaveFile(string filename, ITerrainChannel map) | 104 | public void SaveFile(string filename, ITerrainChannel map) |
105 | { | 105 | { |
106 | char[] header = "TERRAGENTERRAIN".ToCharArray(); | 106 | char[] header = "TERRAGENTERRAIN".ToCharArray(); |
107 | throw new NotImplementedException(); | 107 | throw new NotImplementedException(); |
108 | } | 108 | } |
109 | 109 | ||
110 | public string FileExtension | 110 | public string FileExtension |
111 | { | 111 | { |
112 | get { return ".ter"; } | 112 | get { return ".ter"; } |
113 | } | 113 | } |
114 | 114 | ||
115 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 115 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
116 | { | 116 | { |
117 | throw new NotImplementedException(); | 117 | throw new NotImplementedException(); |
118 | } | 118 | } |
119 | 119 | ||
120 | #endregion | 120 | #endregion |
121 | 121 | ||
122 | public override string ToString() | 122 | public override string ToString() |
123 | { | 123 | { |
124 | return "Terragen"; | 124 | return "Terragen"; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | } \ No newline at end of file | 127 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs index 7bf81d3..496da63 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs | |||
@@ -1,71 +1,71 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class FlattenArea : ITerrainFloodEffect | 32 | public class FlattenArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | #region ITerrainFloodEffect Members | 34 | #region ITerrainFloodEffect Members |
35 | 35 | ||
36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
37 | { | 37 | { |
38 | double sum = 0.0; | 38 | double sum = 0.0; |
39 | double steps = 0.0; | 39 | double steps = 0.0; |
40 | double avg; | 40 | double avg; |
41 | 41 | ||
42 | int x, y; | 42 | int x, y; |
43 | for (x = 0; x < map.Width; x++) | 43 | for (x = 0; x < map.Width; x++) |
44 | { | 44 | { |
45 | for (y = 0; y < map.Height; y++) | 45 | for (y = 0; y < map.Height; y++) |
46 | { | 46 | { |
47 | if (fillArea[x, y]) | 47 | if (fillArea[x, y]) |
48 | { | 48 | { |
49 | sum += map[x, y]; | 49 | sum += map[x, y]; |
50 | steps += 1.0; | 50 | steps += 1.0; |
51 | } | 51 | } |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | avg = sum / steps; | 55 | avg = sum / steps; |
56 | 56 | ||
57 | double str = 0.1 * strength; // == 0.2 in the default client | 57 | double str = 0.1 * strength; // == 0.2 in the default client |
58 | 58 | ||
59 | for (x = 0; x < map.Width; x++) | 59 | for (x = 0; x < map.Width; x++) |
60 | { | 60 | { |
61 | for (y = 0; y < map.Height; y++) | 61 | for (y = 0; y < map.Height; y++) |
62 | { | 62 | { |
63 | if (fillArea[x, y]) | 63 | if (fillArea[x, y]) |
64 | map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str); | 64 | map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | #endregion | 69 | #endregion |
70 | } | 70 | } |
71 | } \ No newline at end of file | 71 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs index a7a4431..3646d61 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs | |||
@@ -1,54 +1,54 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class LowerArea : ITerrainFloodEffect | 32 | public class LowerArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | #region ITerrainFloodEffect Members | 34 | #region ITerrainFloodEffect Members |
35 | 35 | ||
36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
37 | { | 37 | { |
38 | int x; | 38 | int x; |
39 | for (x = 0; x < map.Width; x++) | 39 | for (x = 0; x < map.Width; x++) |
40 | { | 40 | { |
41 | int y; | 41 | int y; |
42 | for (y = 0; y < map.Height; y++) | 42 | for (y = 0; y < map.Height; y++) |
43 | { | 43 | { |
44 | if (fillArea[x, y]) | 44 | if (fillArea[x, y]) |
45 | { | 45 | { |
46 | map[x, y] -= strength; | 46 | map[x, y] -= strength; |
47 | } | 47 | } |
48 | } | 48 | } |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | #endregion | 52 | #endregion |
53 | } | 53 | } |
54 | } \ No newline at end of file | 54 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs index 3da3826..6c8e76e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs | |||
@@ -1,56 +1,56 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework; | 28 | using OpenSim.Framework; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
32 | { | 32 | { |
33 | public class NoiseArea : ITerrainFloodEffect | 33 | public class NoiseArea : ITerrainFloodEffect |
34 | { | 34 | { |
35 | #region ITerrainFloodEffect Members | 35 | #region ITerrainFloodEffect Members |
36 | 36 | ||
37 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 37 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
38 | { | 38 | { |
39 | int x, y; | 39 | int x, y; |
40 | for (x = 0; x < map.Width; x++) | 40 | for (x = 0; x < map.Width; x++) |
41 | { | 41 | { |
42 | for (y = 0; y < map.Height; y++) | 42 | for (y = 0; y < map.Height; y++) |
43 | { | 43 | { |
44 | if (fillArea[x, y]) | 44 | if (fillArea[x, y]) |
45 | { | 45 | { |
46 | double noise = TerrainUtil.PerlinNoise2D((double) x / Constants.RegionSize, (double) y / Constants.RegionSize, 8, 1.0); | 46 | double noise = TerrainUtil.PerlinNoise2D((double) x / Constants.RegionSize, (double) y / Constants.RegionSize, 8, 1.0); |
47 | 47 | ||
48 | map[x, y] += noise * strength; | 48 | map[x, y] += noise * strength; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | #endregion | 54 | #endregion |
55 | } | 55 | } |
56 | } \ No newline at end of file | 56 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs index b57caed..5cb236c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs | |||
@@ -1,53 +1,53 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class RaiseArea : ITerrainFloodEffect | 32 | public class RaiseArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | #region ITerrainFloodEffect Members | 34 | #region ITerrainFloodEffect Members |
35 | 35 | ||
36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
37 | { | 37 | { |
38 | int x, y; | 38 | int x, y; |
39 | for (x = 0; x < map.Width; x++) | 39 | for (x = 0; x < map.Width; x++) |
40 | { | 40 | { |
41 | for (y = 0; y < map.Height; y++) | 41 | for (y = 0; y < map.Height; y++) |
42 | { | 42 | { |
43 | if (fillArea[x, y]) | 43 | if (fillArea[x, y]) |
44 | { | 44 | { |
45 | map[x, y] += strength; | 45 | map[x, y] += strength; |
46 | } | 46 | } |
47 | } | 47 | } |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | #endregion | 51 | #endregion |
52 | } | 52 | } |
53 | } \ No newline at end of file | 53 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs index 76a2cae..f1d9ce6 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs | |||
@@ -1,60 +1,60 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class RevertArea : ITerrainFloodEffect | 32 | public class RevertArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | private readonly ITerrainChannel m_revertmap; | 34 | private readonly ITerrainChannel m_revertmap; |
35 | 35 | ||
36 | public RevertArea(ITerrainChannel revertmap) | 36 | public RevertArea(ITerrainChannel revertmap) |
37 | { | 37 | { |
38 | m_revertmap = revertmap; | 38 | m_revertmap = revertmap; |
39 | } | 39 | } |
40 | 40 | ||
41 | #region ITerrainFloodEffect Members | 41 | #region ITerrainFloodEffect Members |
42 | 42 | ||
43 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 43 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
44 | { | 44 | { |
45 | int x, y; | 45 | int x, y; |
46 | for (x = 0; x < map.Width; x++) | 46 | for (x = 0; x < map.Width; x++) |
47 | { | 47 | { |
48 | for (y = 0; y < map.Height; y++) | 48 | for (y = 0; y < map.Height; y++) |
49 | { | 49 | { |
50 | if (fillArea[x, y]) | 50 | if (fillArea[x, y]) |
51 | { | 51 | { |
52 | map[x, y] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength); | 52 | map[x, y] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | #endregion | 58 | #endregion |
59 | } | 59 | } |
60 | } \ No newline at end of file | 60 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs index bdd9f18..d17d9cb 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs | |||
@@ -1,114 +1,114 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class SmoothArea : ITerrainFloodEffect | 32 | public class SmoothArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | #region ITerrainFloodEffect Members | 34 | #region ITerrainFloodEffect Members |
35 | 35 | ||
36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 36 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
37 | { | 37 | { |
38 | double area = strength; | 38 | double area = strength; |
39 | double step = strength / 4.0; | 39 | double step = strength / 4.0; |
40 | 40 | ||
41 | double[,] manipulate = new double[map.Width,map.Height]; | 41 | double[,] manipulate = new double[map.Width,map.Height]; |
42 | int x, y; | 42 | int x, y; |
43 | for (x = 0; x < map.Width; x++) | 43 | for (x = 0; x < map.Width; x++) |
44 | { | 44 | { |
45 | for (y = 0; y < map.Height; y++) | 45 | for (y = 0; y < map.Height; y++) |
46 | { | 46 | { |
47 | if (!fillArea[x, y]) | 47 | if (!fillArea[x, y]) |
48 | continue; | 48 | continue; |
49 | 49 | ||
50 | double average = 0.0; | 50 | double average = 0.0; |
51 | int avgsteps = 0; | 51 | int avgsteps = 0; |
52 | 52 | ||
53 | double n; | 53 | double n; |
54 | for (n = 0.0 - area; n < area; n += step) | 54 | for (n = 0.0 - area; n < area; n += step) |
55 | { | 55 | { |
56 | double l; | 56 | double l; |
57 | for (l = 0.0 - area; l < area; l += step) | 57 | for (l = 0.0 - area; l < area; l += step) |
58 | { | 58 | { |
59 | avgsteps++; | 59 | avgsteps++; |
60 | average += GetBilinearInterpolate(x + n, y + l, map); | 60 | average += GetBilinearInterpolate(x + n, y + l, map); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | manipulate[x, y] = average / avgsteps; | 64 | manipulate[x, y] = average / avgsteps; |
65 | } | 65 | } |
66 | } | 66 | } |
67 | for (x = 0; x < map.Width; x++) | 67 | for (x = 0; x < map.Width; x++) |
68 | { | 68 | { |
69 | for (y = 0; y < map.Height; y++) | 69 | for (y = 0; y < map.Height; y++) |
70 | { | 70 | { |
71 | if (!fillArea[x, y]) | 71 | if (!fillArea[x, y]) |
72 | continue; | 72 | continue; |
73 | 73 | ||
74 | map[x, y] = manipulate[x, y]; | 74 | map[x, y] = manipulate[x, y]; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | #endregion | 79 | #endregion |
80 | 80 | ||
81 | private static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | 81 | private static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) |
82 | { | 82 | { |
83 | int w = map.Width; | 83 | int w = map.Width; |
84 | int h = map.Height; | 84 | int h = map.Height; |
85 | 85 | ||
86 | if (x > w - 2.0) | 86 | if (x > w - 2.0) |
87 | x = w - 2.0; | 87 | x = w - 2.0; |
88 | if (y > h - 2.0) | 88 | if (y > h - 2.0) |
89 | y = h - 2.0; | 89 | y = h - 2.0; |
90 | if (x < 0.0) | 90 | if (x < 0.0) |
91 | x = 0.0; | 91 | x = 0.0; |
92 | if (y < 0.0) | 92 | if (y < 0.0) |
93 | y = 0.0; | 93 | y = 0.0; |
94 | 94 | ||
95 | int stepSize = 1; | 95 | int stepSize = 1; |
96 | double h00 = map[(int) x, (int) y]; | 96 | double h00 = map[(int) x, (int) y]; |
97 | double h10 = map[(int) x + stepSize, (int) y]; | 97 | double h10 = map[(int) x + stepSize, (int) y]; |
98 | double h01 = map[(int) x, (int) y + stepSize]; | 98 | double h01 = map[(int) x, (int) y + stepSize]; |
99 | double h11 = map[(int) x + stepSize, (int) y + stepSize]; | 99 | double h11 = map[(int) x + stepSize, (int) y + stepSize]; |
100 | double h1 = h00; | 100 | double h1 = h00; |
101 | double h2 = h10; | 101 | double h2 = h10; |
102 | double h3 = h01; | 102 | double h3 = h01; |
103 | double h4 = h11; | 103 | double h4 = h11; |
104 | double a00 = h1; | 104 | double a00 = h1; |
105 | double a10 = h2 - h1; | 105 | double a10 = h2 - h1; |
106 | double a01 = h3 - h1; | 106 | double a01 = h3 - h1; |
107 | double a11 = h1 - h2 - h3 + h4; | 107 | double a11 = h1 - h2 - h3 + h4; |
108 | double partialx = x - (int) x; | 108 | double partialx = x - (int) x; |
109 | double partialz = y - (int) y; | 109 | double partialz = y - (int) y; |
110 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | 110 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); |
111 | return hi; | 111 | return hi; |
112 | } | 112 | } |
113 | } | 113 | } |
114 | } \ No newline at end of file | 114 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs index 821fc4b..bbbe2a3 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs | |||
@@ -1,36 +1,36 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
31 | { | 31 | { |
32 | public interface ITerrainEffect | 32 | public interface ITerrainEffect |
33 | { | 33 | { |
34 | void RunEffect(ITerrainChannel map); | 34 | void RunEffect(ITerrainChannel map); |
35 | } | 35 | } |
36 | } \ No newline at end of file | 36 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs index 6b0d7f9..9fe93a2 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs | |||
@@ -1,37 +1,37 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
32 | { | 32 | { |
33 | public interface ITerrainFloodEffect | 33 | public interface ITerrainFloodEffect |
34 | { | 34 | { |
35 | void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength); | 35 | void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength); |
36 | } | 36 | } |
37 | } \ No newline at end of file | 37 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs index 6211892..4c16c1c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs | |||
@@ -1,39 +1,39 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
31 | { | 31 | { |
32 | public interface ITerrainLoader | 32 | public interface ITerrainLoader |
33 | { | 33 | { |
34 | string FileExtension { get; } | 34 | string FileExtension { get; } |
35 | ITerrainChannel LoadFile(string filename); | 35 | ITerrainChannel LoadFile(string filename); |
36 | ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight); | 36 | ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight); |
37 | void SaveFile(string filename, ITerrainChannel map); | 37 | void SaveFile(string filename, ITerrainChannel map); |
38 | } | 38 | } |
39 | } \ No newline at end of file | 39 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs index 756354a..224cc3a 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs | |||
@@ -1,8 +1,8 @@ | |||
1 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 1 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
2 | { | 2 | { |
3 | public interface ITerrainModule | 3 | public interface ITerrainModule |
4 | { | 4 | { |
5 | void LoadFromFile(string filename); | 5 | void LoadFromFile(string filename); |
6 | void SaveToFile(string filename); | 6 | void SaveToFile(string filename); |
7 | } | 7 | } |
8 | } \ No newline at end of file | 8 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs index d73f44d..cf2e58a 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs | |||
@@ -1,36 +1,36 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
31 | { | 31 | { |
32 | public interface ITerrainPaintableEffect | 32 | public interface ITerrainPaintableEffect |
33 | { | 33 | { |
34 | void PaintEffect(ITerrainChannel map, double x, double y, double strength, double duration); | 34 | void PaintEffect(ITerrainChannel map, double x, double y, double strength, double duration); |
35 | } | 35 | } |
36 | } \ No newline at end of file | 36 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/MapImageModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/MapImageModule.cs index dbaec0f..fe26902 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/MapImageModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/MapImageModule.cs | |||
@@ -1,168 +1,168 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Drawing; | 29 | using System.Drawing; |
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | using OpenJPEGNet; | 31 | using OpenJPEGNet; |
32 | using OpenSim.Region.Environment.Interfaces; | 32 | using OpenSim.Region.Environment.Interfaces; |
33 | using OpenSim.Region.Environment.Scenes; | 33 | using OpenSim.Region.Environment.Scenes; |
34 | 34 | ||
35 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 35 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
36 | { | 36 | { |
37 | internal class MapImageModule : IMapImageGenerator, IRegionModule | 37 | internal class MapImageModule : IMapImageGenerator, IRegionModule |
38 | { | 38 | { |
39 | private Scene m_scene; | 39 | private Scene m_scene; |
40 | 40 | ||
41 | #region IMapImageGenerator Members | 41 | #region IMapImageGenerator Members |
42 | 42 | ||
43 | public byte[] WriteJpeg2000Image(string gradientmap) | 43 | public byte[] WriteJpeg2000Image(string gradientmap) |
44 | { | 44 | { |
45 | byte[] imageData = null; | 45 | byte[] imageData = null; |
46 | 46 | ||
47 | Bitmap bmp = TerrainToBitmap(gradientmap); | 47 | Bitmap bmp = TerrainToBitmap(gradientmap); |
48 | 48 | ||
49 | try | 49 | try |
50 | { | 50 | { |
51 | imageData = OpenJPEG.EncodeFromImage(bmp, true); | 51 | imageData = OpenJPEG.EncodeFromImage(bmp, true); |
52 | } | 52 | } |
53 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke | 53 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke |
54 | { | 54 | { |
55 | Console.WriteLine("Failed generating terrain map: " + e); | 55 | Console.WriteLine("Failed generating terrain map: " + e); |
56 | } | 56 | } |
57 | 57 | ||
58 | return imageData; | 58 | return imageData; |
59 | } | 59 | } |
60 | 60 | ||
61 | #endregion | 61 | #endregion |
62 | 62 | ||
63 | #region IRegionModule Members | 63 | #region IRegionModule Members |
64 | 64 | ||
65 | public void Initialise(Scene scene, IConfigSource source) | 65 | public void Initialise(Scene scene, IConfigSource source) |
66 | { | 66 | { |
67 | m_scene = scene; | 67 | m_scene = scene; |
68 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); | 68 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); |
69 | } | 69 | } |
70 | 70 | ||
71 | public void PostInitialise() | 71 | public void PostInitialise() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | public void Close() | 75 | public void Close() |
76 | { | 76 | { |
77 | } | 77 | } |
78 | 78 | ||
79 | public string Name | 79 | public string Name |
80 | { | 80 | { |
81 | get { return "MapImageModule"; } | 81 | get { return "MapImageModule"; } |
82 | } | 82 | } |
83 | 83 | ||
84 | public bool IsSharedModule | 84 | public bool IsSharedModule |
85 | { | 85 | { |
86 | get { return false; } | 86 | get { return false; } |
87 | } | 87 | } |
88 | 88 | ||
89 | #endregion | 89 | #endregion |
90 | 90 | ||
91 | private void ShadeBuildings(ref Bitmap map) | 91 | private void ShadeBuildings(ref Bitmap map) |
92 | { | 92 | { |
93 | lock (map) | 93 | lock (map) |
94 | { | 94 | { |
95 | lock (m_scene.Entities) | 95 | lock (m_scene.Entities) |
96 | { | 96 | { |
97 | foreach (EntityBase entity in m_scene.Entities.Values) | 97 | foreach (EntityBase entity in m_scene.Entities.Values) |
98 | { | 98 | { |
99 | if (entity is SceneObjectGroup) | 99 | if (entity is SceneObjectGroup) |
100 | { | 100 | { |
101 | SceneObjectGroup sog = (SceneObjectGroup) entity; | 101 | SceneObjectGroup sog = (SceneObjectGroup) entity; |
102 | 102 | ||
103 | foreach (SceneObjectPart primitive in sog.Children.Values) | 103 | foreach (SceneObjectPart primitive in sog.Children.Values) |
104 | { | 104 | { |
105 | int x, y, w, h; | 105 | int x, y, w, h; |
106 | x = (int) (primitive.AbsolutePosition.X - (primitive.Scale.X / 2)); | 106 | x = (int) (primitive.AbsolutePosition.X - (primitive.Scale.X / 2)); |
107 | y = (int) (primitive.AbsolutePosition.Y - (primitive.Scale.Y / 2)); | 107 | y = (int) (primitive.AbsolutePosition.Y - (primitive.Scale.Y / 2)); |
108 | w = (int) primitive.Scale.X; | 108 | w = (int) primitive.Scale.X; |
109 | h = (int) primitive.Scale.Y; | 109 | h = (int) primitive.Scale.Y; |
110 | 110 | ||
111 | int dx; | 111 | int dx; |
112 | for (dx = x; dx < x + w; dx++) | 112 | for (dx = x; dx < x + w; dx++) |
113 | { | 113 | { |
114 | int dy; | 114 | int dy; |
115 | for (dy = y; dy < y + h; dy++) | 115 | for (dy = y; dy < y + h; dy++) |
116 | { | 116 | { |
117 | if (x < 0 || y < 0) | 117 | if (x < 0 || y < 0) |
118 | continue; | 118 | continue; |
119 | if (x >= map.Width || y >= map.Height) | 119 | if (x >= map.Width || y >= map.Height) |
120 | continue; | 120 | continue; |
121 | 121 | ||
122 | map.SetPixel(dx, dy, Color.DarkGray); | 122 | map.SetPixel(dx, dy, Color.DarkGray); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | private Bitmap TerrainToBitmap(string gradientmap) | 132 | private Bitmap TerrainToBitmap(string gradientmap) |
133 | { | 133 | { |
134 | Bitmap gradientmapLd = new Bitmap(gradientmap); | 134 | Bitmap gradientmapLd = new Bitmap(gradientmap); |
135 | 135 | ||
136 | int pallete = gradientmapLd.Height; | 136 | int pallete = gradientmapLd.Height; |
137 | 137 | ||
138 | Bitmap bmp = new Bitmap(m_scene.Heightmap.Width, m_scene.Heightmap.Height); | 138 | Bitmap bmp = new Bitmap(m_scene.Heightmap.Width, m_scene.Heightmap.Height); |
139 | Color[] colours = new Color[pallete]; | 139 | Color[] colours = new Color[pallete]; |
140 | 140 | ||
141 | for (int i = 0; i < pallete; i++) | 141 | for (int i = 0; i < pallete; i++) |
142 | { | 142 | { |
143 | colours[i] = gradientmapLd.GetPixel(0, i); | 143 | colours[i] = gradientmapLd.GetPixel(0, i); |
144 | } | 144 | } |
145 | 145 | ||
146 | lock (m_scene.Heightmap) | 146 | lock (m_scene.Heightmap) |
147 | { | 147 | { |
148 | ITerrainChannel copy = m_scene.Heightmap; | 148 | ITerrainChannel copy = m_scene.Heightmap; |
149 | for (int y = 0; y < copy.Height; y++) | 149 | for (int y = 0; y < copy.Height; y++) |
150 | { | 150 | { |
151 | for (int x = 0; x < copy.Width; x++) | 151 | for (int x = 0; x < copy.Width; x++) |
152 | { | 152 | { |
153 | // 512 is the largest possible height before colours clamp | 153 | // 512 is the largest possible height before colours clamp |
154 | int colorindex = (int) (Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1)); | 154 | int colorindex = (int) (Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1)); |
155 | 155 | ||
156 | // Handle error conditions | 156 | // Handle error conditions |
157 | if (colorindex > pallete - 1 || colorindex < 0) | 157 | if (colorindex > pallete - 1 || colorindex < 0) |
158 | bmp.SetPixel(x, copy.Height - y - 1, Color.Red); | 158 | bmp.SetPixel(x, copy.Height - y - 1, Color.Red); |
159 | else | 159 | else |
160 | bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]); | 160 | bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | ShadeBuildings(ref bmp); | 163 | ShadeBuildings(ref bmp); |
164 | return bmp; | 164 | return bmp; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | } \ No newline at end of file | 168 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs index 29448aa..e036988 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs | |||
@@ -1,312 +1,312 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// Hydraulic Erosion Brush | 34 | /// Hydraulic Erosion Brush |
35 | /// </summary> | 35 | /// </summary> |
36 | public class ErodeSphere : ITerrainPaintableEffect | 36 | public class ErodeSphere : ITerrainPaintableEffect |
37 | { | 37 | { |
38 | private double rainHeight = 0.2; | 38 | private double rainHeight = 0.2; |
39 | private int rounds = 10; | 39 | private int rounds = 10; |
40 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter | 40 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter |
41 | private double waterSaturation = 0.30; // Can carry 1% of water in height | 41 | private double waterSaturation = 0.30; // Can carry 1% of water in height |
42 | 42 | ||
43 | #region Supporting Functions | 43 | #region Supporting Functions |
44 | 44 | ||
45 | private int[] Neighbours(NeighbourSystem type, int index) | 45 | private int[] Neighbours(NeighbourSystem type, int index) |
46 | { | 46 | { |
47 | int[] coord = new int[2]; | 47 | int[] coord = new int[2]; |
48 | 48 | ||
49 | index++; | 49 | index++; |
50 | 50 | ||
51 | switch (type) | 51 | switch (type) |
52 | { | 52 | { |
53 | case NeighbourSystem.Moore: | 53 | case NeighbourSystem.Moore: |
54 | switch (index) | 54 | switch (index) |
55 | { | 55 | { |
56 | case 1: | 56 | case 1: |
57 | coord[0] = -1; | 57 | coord[0] = -1; |
58 | coord[1] = -1; | 58 | coord[1] = -1; |
59 | break; | 59 | break; |
60 | 60 | ||
61 | case 2: | 61 | case 2: |
62 | coord[0] = -0; | 62 | coord[0] = -0; |
63 | coord[1] = -1; | 63 | coord[1] = -1; |
64 | break; | 64 | break; |
65 | 65 | ||
66 | case 3: | 66 | case 3: |
67 | coord[0] = +1; | 67 | coord[0] = +1; |
68 | coord[1] = -1; | 68 | coord[1] = -1; |
69 | break; | 69 | break; |
70 | 70 | ||
71 | case 4: | 71 | case 4: |
72 | coord[0] = -1; | 72 | coord[0] = -1; |
73 | coord[1] = -0; | 73 | coord[1] = -0; |
74 | break; | 74 | break; |
75 | 75 | ||
76 | case 5: | 76 | case 5: |
77 | coord[0] = -0; | 77 | coord[0] = -0; |
78 | coord[1] = -0; | 78 | coord[1] = -0; |
79 | break; | 79 | break; |
80 | 80 | ||
81 | case 6: | 81 | case 6: |
82 | coord[0] = +1; | 82 | coord[0] = +1; |
83 | coord[1] = -0; | 83 | coord[1] = -0; |
84 | break; | 84 | break; |
85 | 85 | ||
86 | case 7: | 86 | case 7: |
87 | coord[0] = -1; | 87 | coord[0] = -1; |
88 | coord[1] = +1; | 88 | coord[1] = +1; |
89 | break; | 89 | break; |
90 | 90 | ||
91 | case 8: | 91 | case 8: |
92 | coord[0] = -0; | 92 | coord[0] = -0; |
93 | coord[1] = +1; | 93 | coord[1] = +1; |
94 | break; | 94 | break; |
95 | 95 | ||
96 | case 9: | 96 | case 9: |
97 | coord[0] = +1; | 97 | coord[0] = +1; |
98 | coord[1] = +1; | 98 | coord[1] = +1; |
99 | break; | 99 | break; |
100 | 100 | ||
101 | default: | 101 | default: |
102 | break; | 102 | break; |
103 | } | 103 | } |
104 | break; | 104 | break; |
105 | 105 | ||
106 | case NeighbourSystem.VonNeumann: | 106 | case NeighbourSystem.VonNeumann: |
107 | switch (index) | 107 | switch (index) |
108 | { | 108 | { |
109 | case 1: | 109 | case 1: |
110 | coord[0] = 0; | 110 | coord[0] = 0; |
111 | coord[1] = -1; | 111 | coord[1] = -1; |
112 | break; | 112 | break; |
113 | 113 | ||
114 | case 2: | 114 | case 2: |
115 | coord[0] = -1; | 115 | coord[0] = -1; |
116 | coord[1] = 0; | 116 | coord[1] = 0; |
117 | break; | 117 | break; |
118 | 118 | ||
119 | case 3: | 119 | case 3: |
120 | coord[0] = +1; | 120 | coord[0] = +1; |
121 | coord[1] = 0; | 121 | coord[1] = 0; |
122 | break; | 122 | break; |
123 | 123 | ||
124 | case 4: | 124 | case 4: |
125 | coord[0] = 0; | 125 | coord[0] = 0; |
126 | coord[1] = +1; | 126 | coord[1] = +1; |
127 | break; | 127 | break; |
128 | 128 | ||
129 | case 5: | 129 | case 5: |
130 | coord[0] = -0; | 130 | coord[0] = -0; |
131 | coord[1] = -0; | 131 | coord[1] = -0; |
132 | break; | 132 | break; |
133 | 133 | ||
134 | default: | 134 | default: |
135 | break; | 135 | break; |
136 | } | 136 | } |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | 139 | ||
140 | return coord; | 140 | return coord; |
141 | } | 141 | } |
142 | 142 | ||
143 | private enum NeighbourSystem | 143 | private enum NeighbourSystem |
144 | { | 144 | { |
145 | Moore, | 145 | Moore, |
146 | VonNeumann | 146 | VonNeumann |
147 | } ; | 147 | } ; |
148 | 148 | ||
149 | #endregion | 149 | #endregion |
150 | 150 | ||
151 | #region ITerrainPaintableEffect Members | 151 | #region ITerrainPaintableEffect Members |
152 | 152 | ||
153 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 153 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
154 | { | 154 | { |
155 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 155 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
156 | 156 | ||
157 | int x, y; | 157 | int x, y; |
158 | // Using one 'rain' round for this, so skipping a useless loop | 158 | // Using one 'rain' round for this, so skipping a useless loop |
159 | // Will need to adapt back in for the Flood brush | 159 | // Will need to adapt back in for the Flood brush |
160 | 160 | ||
161 | ITerrainChannel water = new TerrainChannel(map.Width, map.Height); | 161 | ITerrainChannel water = new TerrainChannel(map.Width, map.Height); |
162 | ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height); | 162 | ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height); |
163 | 163 | ||
164 | // Fill with rain | 164 | // Fill with rain |
165 | for (x = 0; x < water.Width; x++) | 165 | for (x = 0; x < water.Width; x++) |
166 | for (y = 0; y < water.Height; y++) | 166 | for (y = 0; y < water.Height; y++) |
167 | water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration); | 167 | water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration); |
168 | 168 | ||
169 | for (int i = 0; i < rounds; i++) | 169 | for (int i = 0; i < rounds; i++) |
170 | { | 170 | { |
171 | // Erode underlying terrain | 171 | // Erode underlying terrain |
172 | for (x = 0; x < water.Width; x++) | 172 | for (x = 0; x < water.Width; x++) |
173 | { | 173 | { |
174 | for (y = 0; y < water.Height; y++) | 174 | for (y = 0; y < water.Height; y++) |
175 | { | 175 | { |
176 | double solConst = (1.0 / rounds); | 176 | double solConst = (1.0 / rounds); |
177 | double sedDelta = water[x, y] * solConst; | 177 | double sedDelta = water[x, y] * solConst; |
178 | map[x, y] -= sedDelta; | 178 | map[x, y] -= sedDelta; |
179 | sediment[x, y] += sedDelta; | 179 | sediment[x, y] += sedDelta; |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | // Move water | 183 | // Move water |
184 | for (x = 0; x < water.Width; x++) | 184 | for (x = 0; x < water.Width; x++) |
185 | { | 185 | { |
186 | for (y = 0; y < water.Height; y++) | 186 | for (y = 0; y < water.Height; y++) |
187 | { | 187 | { |
188 | if (water[x, y] <= 0) | 188 | if (water[x, y] <= 0) |
189 | continue; | 189 | continue; |
190 | 190 | ||
191 | // Step 1. Calculate average of neighbours | 191 | // Step 1. Calculate average of neighbours |
192 | 192 | ||
193 | int neighbours = 0; | 193 | int neighbours = 0; |
194 | double altitudeTotal = 0.0; | 194 | double altitudeTotal = 0.0; |
195 | double altitudeMe = map[x, y] + water[x, y]; | 195 | double altitudeMe = map[x, y] + water[x, y]; |
196 | 196 | ||
197 | int NEIGHBOUR_ME = 4; | 197 | int NEIGHBOUR_ME = 4; |
198 | 198 | ||
199 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; | 199 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; |
200 | 200 | ||
201 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 201 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
202 | { | 202 | { |
203 | if (j != NEIGHBOUR_ME) | 203 | if (j != NEIGHBOUR_ME) |
204 | { | 204 | { |
205 | int[] coords = Neighbours(type, j); | 205 | int[] coords = Neighbours(type, j); |
206 | 206 | ||
207 | coords[0] += x; | 207 | coords[0] += x; |
208 | coords[1] += y; | 208 | coords[1] += y; |
209 | 209 | ||
210 | if (coords[0] > map.Width - 1) | 210 | if (coords[0] > map.Width - 1) |
211 | continue; | 211 | continue; |
212 | if (coords[1] > map.Height - 1) | 212 | if (coords[1] > map.Height - 1) |
213 | continue; | 213 | continue; |
214 | if (coords[0] < 0) | 214 | if (coords[0] < 0) |
215 | continue; | 215 | continue; |
216 | if (coords[1] < 0) | 216 | if (coords[1] < 0) |
217 | continue; | 217 | continue; |
218 | 218 | ||
219 | // Calculate total height of this neighbour | 219 | // Calculate total height of this neighbour |
220 | double altitudeNeighbour = water[coords[0], coords[1]] + map[coords[0], coords[1]]; | 220 | double altitudeNeighbour = water[coords[0], coords[1]] + map[coords[0], coords[1]]; |
221 | 221 | ||
222 | // If it's greater than me... | 222 | // If it's greater than me... |
223 | if (altitudeNeighbour - altitudeMe < 0) | 223 | if (altitudeNeighbour - altitudeMe < 0) |
224 | { | 224 | { |
225 | // Add it to our calculations | 225 | // Add it to our calculations |
226 | neighbours++; | 226 | neighbours++; |
227 | altitudeTotal += altitudeNeighbour; | 227 | altitudeTotal += altitudeNeighbour; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | 231 | ||
232 | if (neighbours == 0) | 232 | if (neighbours == 0) |
233 | continue; | 233 | continue; |
234 | 234 | ||
235 | double altitudeAvg = altitudeTotal / neighbours; | 235 | double altitudeAvg = altitudeTotal / neighbours; |
236 | 236 | ||
237 | // Step 2. Allocate water to neighbours. | 237 | // Step 2. Allocate water to neighbours. |
238 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 238 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
239 | { | 239 | { |
240 | if (j != NEIGHBOUR_ME) | 240 | if (j != NEIGHBOUR_ME) |
241 | { | 241 | { |
242 | int[] coords = Neighbours(type, j); | 242 | int[] coords = Neighbours(type, j); |
243 | 243 | ||
244 | coords[0] += x; | 244 | coords[0] += x; |
245 | coords[1] += y; | 245 | coords[1] += y; |
246 | 246 | ||
247 | if (coords[0] > map.Width - 1) | 247 | if (coords[0] > map.Width - 1) |
248 | continue; | 248 | continue; |
249 | if (coords[1] > map.Height - 1) | 249 | if (coords[1] > map.Height - 1) |
250 | continue; | 250 | continue; |
251 | if (coords[0] < 0) | 251 | if (coords[0] < 0) |
252 | continue; | 252 | continue; |
253 | if (coords[1] < 0) | 253 | if (coords[1] < 0) |
254 | continue; | 254 | continue; |
255 | 255 | ||
256 | // Skip if we dont have water to begin with. | 256 | // Skip if we dont have water to begin with. |
257 | if (water[x, y] < 0) | 257 | if (water[x, y] < 0) |
258 | continue; | 258 | continue; |
259 | 259 | ||
260 | // Calculate our delta average | 260 | // Calculate our delta average |
261 | double altitudeDelta = altitudeMe - altitudeAvg; | 261 | double altitudeDelta = altitudeMe - altitudeAvg; |
262 | 262 | ||
263 | if (altitudeDelta < 0) | 263 | if (altitudeDelta < 0) |
264 | continue; | 264 | continue; |
265 | 265 | ||
266 | // Calculate how much water we can move | 266 | // Calculate how much water we can move |
267 | double waterMin = Math.Min(water[x, y], altitudeDelta); | 267 | double waterMin = Math.Min(water[x, y], altitudeDelta); |
268 | double waterDelta = waterMin * ((water[coords[0], coords[1]] + map[coords[0], coords[1]]) | 268 | double waterDelta = waterMin * ((water[coords[0], coords[1]] + map[coords[0], coords[1]]) |
269 | / altitudeTotal); | 269 | / altitudeTotal); |
270 | 270 | ||
271 | double sedimentDelta = sediment[x, y] * (waterDelta / water[x, y]); | 271 | double sedimentDelta = sediment[x, y] * (waterDelta / water[x, y]); |
272 | 272 | ||
273 | if (sedimentDelta > 0) | 273 | if (sedimentDelta > 0) |
274 | { | 274 | { |
275 | sediment[x, y] -= sedimentDelta; | 275 | sediment[x, y] -= sedimentDelta; |
276 | sediment[coords[0], coords[1]] += sedimentDelta; | 276 | sediment[coords[0], coords[1]] += sedimentDelta; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | // Evaporate | 283 | // Evaporate |
284 | 284 | ||
285 | for (x = 0; x < water.Width; x++) | 285 | for (x = 0; x < water.Width; x++) |
286 | { | 286 | { |
287 | for (y = 0; y < water.Height; y++) | 287 | for (y = 0; y < water.Height; y++) |
288 | { | 288 | { |
289 | water[x, y] *= 1.0 - (rainHeight / rounds); | 289 | water[x, y] *= 1.0 - (rainHeight / rounds); |
290 | 290 | ||
291 | double waterCapacity = waterSaturation * water[x, y]; | 291 | double waterCapacity = waterSaturation * water[x, y]; |
292 | 292 | ||
293 | double sedimentDeposit = sediment[x, y] - waterCapacity; | 293 | double sedimentDeposit = sediment[x, y] - waterCapacity; |
294 | if (sedimentDeposit > 0) | 294 | if (sedimentDeposit > 0) |
295 | { | 295 | { |
296 | sediment[x, y] -= sedimentDeposit; | 296 | sediment[x, y] -= sedimentDeposit; |
297 | map[x, y] += sedimentDeposit; | 297 | map[x, y] += sedimentDeposit; |
298 | } | 298 | } |
299 | } | 299 | } |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | // Deposit any remainder (should be minimal) | 303 | // Deposit any remainder (should be minimal) |
304 | for (x = 0; x < water.Width; x++) | 304 | for (x = 0; x < water.Width; x++) |
305 | for (y = 0; y < water.Height; y++) | 305 | for (y = 0; y < water.Height; y++) |
306 | if (sediment[x, y] > 0) | 306 | if (sediment[x, y] > 0) |
307 | map[x, y] += sediment[x, y]; | 307 | map[x, y] += sediment[x, y]; |
308 | } | 308 | } |
309 | 309 | ||
310 | #endregion | 310 | #endregion |
311 | } | 311 | } |
312 | } \ No newline at end of file | 312 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs index d4f3b9f..dee455f 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs | |||
@@ -1,94 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
31 | { | 31 | { |
32 | public class FlattenSphere : ITerrainPaintableEffect | 32 | public class FlattenSphere : ITerrainPaintableEffect |
33 | { | 33 | { |
34 | 34 | ||
35 | #region ITerrainPaintableEffect Members | 35 | #region ITerrainPaintableEffect Members |
36 | 36 | ||
37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
38 | { | 38 | { |
39 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 39 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
40 | 40 | ||
41 | int x, y; | 41 | int x, y; |
42 | double[,] tweak = new double[map.Width,map.Height]; | 42 | double[,] tweak = new double[map.Width,map.Height]; |
43 | 43 | ||
44 | double area = strength; | 44 | double area = strength; |
45 | double step = strength / 4.0; | 45 | double step = strength / 4.0; |
46 | 46 | ||
47 | double sum = 0.0; | 47 | double sum = 0.0; |
48 | double step2 = 0.0; | 48 | double step2 = 0.0; |
49 | double avg = 0.0; | 49 | double avg = 0.0; |
50 | 50 | ||
51 | // compute delta map | 51 | // compute delta map |
52 | for (x = 0; x < map.Width; x++) | 52 | for (x = 0; x < map.Width; x++) |
53 | { | 53 | { |
54 | for (y = 0; y < map.Height; y++) | 54 | for (y = 0; y < map.Height; y++) |
55 | { | 55 | { |
56 | double z = SphericalFactor(x, y, rx, ry, strength); | 56 | double z = SphericalFactor(x, y, rx, ry, strength); |
57 | 57 | ||
58 | if (z > 0) // add in non-zero amount | 58 | if (z > 0) // add in non-zero amount |
59 | { | 59 | { |
60 | sum += map[x, y] * z; | 60 | sum += map[x, y] * z; |
61 | step2 += z; | 61 | step2 += z; |
62 | } | 62 | } |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | avg = sum / step2; | 66 | avg = sum / step2; |
67 | 67 | ||
68 | // blend in map | 68 | // blend in map |
69 | for (x = 0; x < map.Width; x++) | 69 | for (x = 0; x < map.Width; x++) |
70 | { | 70 | { |
71 | for (y = 0; y < map.Height; y++) | 71 | for (y = 0; y < map.Height; y++) |
72 | { | 72 | { |
73 | double z = SphericalFactor(x, y, rx, ry, strength) * duration; | 73 | double z = SphericalFactor(x, y, rx, ry, strength) * duration; |
74 | 74 | ||
75 | if (z > 0) // add in non-zero amount | 75 | if (z > 0) // add in non-zero amount |
76 | { | 76 | { |
77 | if (z > 1.0) | 77 | if (z > 1.0) |
78 | z = 1.0; | 78 | z = 1.0; |
79 | 79 | ||
80 | map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); | 80 | map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | #endregion | 86 | #endregion |
87 | 87 | ||
88 | private double SphericalFactor(double x, double y, double rx, double ry, double size) | 88 | private double SphericalFactor(double x, double y, double rx, double ry, double size) |
89 | { | 89 | { |
90 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 90 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
91 | return z; | 91 | return z; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } \ No newline at end of file | 94 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs index 0b80407..092bd29 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs | |||
@@ -1,67 +1,67 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | public class LowerSphere : ITerrainPaintableEffect | 33 | public class LowerSphere : ITerrainPaintableEffect |
34 | { | 34 | { |
35 | #region ITerrainPaintableEffect Members | 35 | #region ITerrainPaintableEffect Members |
36 | 36 | ||
37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
38 | { | 38 | { |
39 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 39 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
40 | 40 | ||
41 | int x, y; | 41 | int x, y; |
42 | for (x = 0; x < map.Width; x++) | 42 | for (x = 0; x < map.Width; x++) |
43 | { | 43 | { |
44 | // Skip everything unlikely to be affected | 44 | // Skip everything unlikely to be affected |
45 | if (Math.Abs(x - rx) > strength * 1.1) | 45 | if (Math.Abs(x - rx) > strength * 1.1) |
46 | continue; | 46 | continue; |
47 | 47 | ||
48 | for (y = 0; y < map.Height; y++) | 48 | for (y = 0; y < map.Height; y++) |
49 | { | 49 | { |
50 | // Skip everything unlikely to be affected | 50 | // Skip everything unlikely to be affected |
51 | if (Math.Abs(y - ry) > strength * 1.1) | 51 | if (Math.Abs(y - ry) > strength * 1.1) |
52 | continue; | 52 | continue; |
53 | 53 | ||
54 | // Calculate a sphere and add it to the heighmap | 54 | // Calculate a sphere and add it to the heighmap |
55 | double z = strength; | 55 | double z = strength; |
56 | z *= z; | 56 | z *= z; |
57 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 57 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
58 | 58 | ||
59 | if (z > 0.0) | 59 | if (z > 0.0) |
60 | map[x, y] -= z * duration; | 60 | map[x, y] -= z * duration; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | #endregion | 65 | #endregion |
66 | } | 66 | } |
67 | } \ No newline at end of file | 67 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs index a188e9f..8ae583e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs | |||
@@ -1,70 +1,70 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
33 | { | 33 | { |
34 | public class NoiseSphere : ITerrainPaintableEffect | 34 | public class NoiseSphere : ITerrainPaintableEffect |
35 | { | 35 | { |
36 | #region ITerrainPaintableEffect Members | 36 | #region ITerrainPaintableEffect Members |
37 | 37 | ||
38 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 38 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
39 | { | 39 | { |
40 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 40 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
41 | 41 | ||
42 | int x, y; | 42 | int x, y; |
43 | for (x = 0; x < map.Width; x++) | 43 | for (x = 0; x < map.Width; x++) |
44 | { | 44 | { |
45 | // Skip everything unlikely to be affected | 45 | // Skip everything unlikely to be affected |
46 | if (Math.Abs(x - rx) > strength * 1.1) | 46 | if (Math.Abs(x - rx) > strength * 1.1) |
47 | continue; | 47 | continue; |
48 | 48 | ||
49 | for (y = 0; y < map.Height; y++) | 49 | for (y = 0; y < map.Height; y++) |
50 | { | 50 | { |
51 | // Skip everything unlikely to be affected | 51 | // Skip everything unlikely to be affected |
52 | if (Math.Abs(y - ry) > strength * 1.1) | 52 | if (Math.Abs(y - ry) > strength * 1.1) |
53 | continue; | 53 | continue; |
54 | 54 | ||
55 | // Calculate a sphere and add it to the heighmap | 55 | // Calculate a sphere and add it to the heighmap |
56 | double z = strength; | 56 | double z = strength; |
57 | z *= z; | 57 | z *= z; |
58 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 58 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
59 | 59 | ||
60 | double noise = TerrainUtil.PerlinNoise2D((double) x / (double) Constants.RegionSize, (double) y / (double) Constants.RegionSize, 8, 1.0); | 60 | double noise = TerrainUtil.PerlinNoise2D((double) x / (double) Constants.RegionSize, (double) y / (double) Constants.RegionSize, 8, 1.0); |
61 | 61 | ||
62 | if (z > 0.0) | 62 | if (z > 0.0) |
63 | map[x, y] += noise * z * duration; | 63 | map[x, y] += noise * z * duration; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | #endregion | 68 | #endregion |
69 | } | 69 | } |
70 | } \ No newline at end of file | 70 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs index dc56cf1..ba01a01 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs | |||
@@ -1,225 +1,225 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// Speed-Optimised Hybrid Erosion Brush | 34 | /// Speed-Optimised Hybrid Erosion Brush |
35 | /// | 35 | /// |
36 | /// As per Jacob Olsen's Paper | 36 | /// As per Jacob Olsen's Paper |
37 | /// http://www.oddlabs.com/download/terrain_generation.pdf | 37 | /// http://www.oddlabs.com/download/terrain_generation.pdf |
38 | /// </summary> | 38 | /// </summary> |
39 | public class OlsenSphere : ITerrainPaintableEffect | 39 | public class OlsenSphere : ITerrainPaintableEffect |
40 | { | 40 | { |
41 | private double nConst = 1024.0; | 41 | private double nConst = 1024.0; |
42 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter | 42 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter |
43 | 43 | ||
44 | #region Supporting Functions | 44 | #region Supporting Functions |
45 | 45 | ||
46 | private int[] Neighbours(NeighbourSystem type, int index) | 46 | private int[] Neighbours(NeighbourSystem type, int index) |
47 | { | 47 | { |
48 | int[] coord = new int[2]; | 48 | int[] coord = new int[2]; |
49 | 49 | ||
50 | index++; | 50 | index++; |
51 | 51 | ||
52 | switch (type) | 52 | switch (type) |
53 | { | 53 | { |
54 | case NeighbourSystem.Moore: | 54 | case NeighbourSystem.Moore: |
55 | switch (index) | 55 | switch (index) |
56 | { | 56 | { |
57 | case 1: | 57 | case 1: |
58 | coord[0] = -1; | 58 | coord[0] = -1; |
59 | coord[1] = -1; | 59 | coord[1] = -1; |
60 | break; | 60 | break; |
61 | 61 | ||
62 | case 2: | 62 | case 2: |
63 | coord[0] = -0; | 63 | coord[0] = -0; |
64 | coord[1] = -1; | 64 | coord[1] = -1; |
65 | break; | 65 | break; |
66 | 66 | ||
67 | case 3: | 67 | case 3: |
68 | coord[0] = +1; | 68 | coord[0] = +1; |
69 | coord[1] = -1; | 69 | coord[1] = -1; |
70 | break; | 70 | break; |
71 | 71 | ||
72 | case 4: | 72 | case 4: |
73 | coord[0] = -1; | 73 | coord[0] = -1; |
74 | coord[1] = -0; | 74 | coord[1] = -0; |
75 | break; | 75 | break; |
76 | 76 | ||
77 | case 5: | 77 | case 5: |
78 | coord[0] = -0; | 78 | coord[0] = -0; |
79 | coord[1] = -0; | 79 | coord[1] = -0; |
80 | break; | 80 | break; |
81 | 81 | ||
82 | case 6: | 82 | case 6: |
83 | coord[0] = +1; | 83 | coord[0] = +1; |
84 | coord[1] = -0; | 84 | coord[1] = -0; |
85 | break; | 85 | break; |
86 | 86 | ||
87 | case 7: | 87 | case 7: |
88 | coord[0] = -1; | 88 | coord[0] = -1; |
89 | coord[1] = +1; | 89 | coord[1] = +1; |
90 | break; | 90 | break; |
91 | 91 | ||
92 | case 8: | 92 | case 8: |
93 | coord[0] = -0; | 93 | coord[0] = -0; |
94 | coord[1] = +1; | 94 | coord[1] = +1; |
95 | break; | 95 | break; |
96 | 96 | ||
97 | case 9: | 97 | case 9: |
98 | coord[0] = +1; | 98 | coord[0] = +1; |
99 | coord[1] = +1; | 99 | coord[1] = +1; |
100 | break; | 100 | break; |
101 | 101 | ||
102 | default: | 102 | default: |
103 | break; | 103 | break; |
104 | } | 104 | } |
105 | break; | 105 | break; |
106 | 106 | ||
107 | case NeighbourSystem.VonNeumann: | 107 | case NeighbourSystem.VonNeumann: |
108 | switch (index) | 108 | switch (index) |
109 | { | 109 | { |
110 | case 1: | 110 | case 1: |
111 | coord[0] = 0; | 111 | coord[0] = 0; |
112 | coord[1] = -1; | 112 | coord[1] = -1; |
113 | break; | 113 | break; |
114 | 114 | ||
115 | case 2: | 115 | case 2: |
116 | coord[0] = -1; | 116 | coord[0] = -1; |
117 | coord[1] = 0; | 117 | coord[1] = 0; |
118 | break; | 118 | break; |
119 | 119 | ||
120 | case 3: | 120 | case 3: |
121 | coord[0] = +1; | 121 | coord[0] = +1; |
122 | coord[1] = 0; | 122 | coord[1] = 0; |
123 | break; | 123 | break; |
124 | 124 | ||
125 | case 4: | 125 | case 4: |
126 | coord[0] = 0; | 126 | coord[0] = 0; |
127 | coord[1] = +1; | 127 | coord[1] = +1; |
128 | break; | 128 | break; |
129 | 129 | ||
130 | case 5: | 130 | case 5: |
131 | coord[0] = -0; | 131 | coord[0] = -0; |
132 | coord[1] = -0; | 132 | coord[1] = -0; |
133 | break; | 133 | break; |
134 | 134 | ||
135 | default: | 135 | default: |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | break; | 138 | break; |
139 | } | 139 | } |
140 | 140 | ||
141 | return coord; | 141 | return coord; |
142 | } | 142 | } |
143 | 143 | ||
144 | private double SphericalFactor(double x, double y, double rx, double ry, double size) | 144 | private double SphericalFactor(double x, double y, double rx, double ry, double size) |
145 | { | 145 | { |
146 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 146 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
147 | return z; | 147 | return z; |
148 | } | 148 | } |
149 | 149 | ||
150 | private enum NeighbourSystem | 150 | private enum NeighbourSystem |
151 | { | 151 | { |
152 | Moore, | 152 | Moore, |
153 | VonNeumann | 153 | VonNeumann |
154 | } ; | 154 | } ; |
155 | 155 | ||
156 | #endregion | 156 | #endregion |
157 | 157 | ||
158 | #region ITerrainPaintableEffect Members | 158 | #region ITerrainPaintableEffect Members |
159 | 159 | ||
160 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 160 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
161 | { | 161 | { |
162 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 162 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
163 | 163 | ||
164 | int x, y; | 164 | int x, y; |
165 | 165 | ||
166 | for (x = 0; x < map.Width; x++) | 166 | for (x = 0; x < map.Width; x++) |
167 | { | 167 | { |
168 | for (y = 0; y < map.Height; y++) | 168 | for (y = 0; y < map.Height; y++) |
169 | { | 169 | { |
170 | double z = SphericalFactor(x, y, rx, ry, strength); | 170 | double z = SphericalFactor(x, y, rx, ry, strength); |
171 | 171 | ||
172 | if (z > 0) // add in non-zero amount | 172 | if (z > 0) // add in non-zero amount |
173 | { | 173 | { |
174 | int NEIGHBOUR_ME = 4; | 174 | int NEIGHBOUR_ME = 4; |
175 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; | 175 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; |
176 | 176 | ||
177 | double max = Double.MinValue; | 177 | double max = Double.MinValue; |
178 | int loc = 0; | 178 | int loc = 0; |
179 | double cellmax = 0; | 179 | double cellmax = 0; |
180 | 180 | ||
181 | 181 | ||
182 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 182 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
183 | { | 183 | { |
184 | if (j != NEIGHBOUR_ME) | 184 | if (j != NEIGHBOUR_ME) |
185 | { | 185 | { |
186 | int[] coords = Neighbours(type, j); | 186 | int[] coords = Neighbours(type, j); |
187 | 187 | ||
188 | coords[0] += x; | 188 | coords[0] += x; |
189 | coords[1] += y; | 189 | coords[1] += y; |
190 | 190 | ||
191 | if (coords[0] > map.Width - 1) | 191 | if (coords[0] > map.Width - 1) |
192 | continue; | 192 | continue; |
193 | if (coords[1] > map.Height - 1) | 193 | if (coords[1] > map.Height - 1) |
194 | continue; | 194 | continue; |
195 | if (coords[0] < 0) | 195 | if (coords[0] < 0) |
196 | continue; | 196 | continue; |
197 | if (coords[1] < 0) | 197 | if (coords[1] < 0) |
198 | continue; | 198 | continue; |
199 | 199 | ||
200 | cellmax = map[x, y] - map[coords[0], coords[1]]; | 200 | cellmax = map[x, y] - map[coords[0], coords[1]]; |
201 | if (cellmax > max) | 201 | if (cellmax > max) |
202 | { | 202 | { |
203 | max = cellmax; | 203 | max = cellmax; |
204 | loc = j; | 204 | loc = j; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | double T = nConst / ((map.Width + map.Height) / 2); | 209 | double T = nConst / ((map.Width + map.Height) / 2); |
210 | // Apply results | 210 | // Apply results |
211 | if (0 < max && max <= T) | 211 | if (0 < max && max <= T) |
212 | { | 212 | { |
213 | int[] maxCoords = Neighbours(type, loc); | 213 | int[] maxCoords = Neighbours(type, loc); |
214 | double heightDelta = 0.5 * max * z * duration; | 214 | double heightDelta = 0.5 * max * z * duration; |
215 | map[x, y] -= heightDelta; | 215 | map[x, y] -= heightDelta; |
216 | map[x + maxCoords[0], y + maxCoords[1]] += heightDelta; | 216 | map[x + maxCoords[0], y + maxCoords[1]] += heightDelta; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | #endregion | 223 | #endregion |
224 | } | 224 | } |
225 | } \ No newline at end of file | 225 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs index cd5a22b..5d6f093 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs | |||
@@ -1,67 +1,67 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | public class RaiseSphere : ITerrainPaintableEffect | 33 | public class RaiseSphere : ITerrainPaintableEffect |
34 | { | 34 | { |
35 | #region ITerrainPaintableEffect Members | 35 | #region ITerrainPaintableEffect Members |
36 | 36 | ||
37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
38 | { | 38 | { |
39 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 39 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
40 | 40 | ||
41 | int x, y; | 41 | int x, y; |
42 | for (x = 0; x < map.Width; x++) | 42 | for (x = 0; x < map.Width; x++) |
43 | { | 43 | { |
44 | // Skip everything unlikely to be affected | 44 | // Skip everything unlikely to be affected |
45 | if (Math.Abs(x - rx) > strength * 1.1) | 45 | if (Math.Abs(x - rx) > strength * 1.1) |
46 | continue; | 46 | continue; |
47 | 47 | ||
48 | for (y = 0; y < map.Height; y++) | 48 | for (y = 0; y < map.Height; y++) |
49 | { | 49 | { |
50 | // Skip everything unlikely to be affected | 50 | // Skip everything unlikely to be affected |
51 | if (Math.Abs(y - ry) > strength * 1.1) | 51 | if (Math.Abs(y - ry) > strength * 1.1) |
52 | continue; | 52 | continue; |
53 | 53 | ||
54 | // Calculate a sphere and add it to the heighmap | 54 | // Calculate a sphere and add it to the heighmap |
55 | double z = strength; | 55 | double z = strength; |
56 | z *= z; | 56 | z *= z; |
57 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 57 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
58 | 58 | ||
59 | if (z > 0.0) | 59 | if (z > 0.0) |
60 | map[x, y] += z * duration; | 60 | map[x, y] += z * duration; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | #endregion | 65 | #endregion |
66 | } | 66 | } |
67 | } \ No newline at end of file | 67 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs index 5b92cb5..b47e041 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs | |||
@@ -1,82 +1,82 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | public class RevertSphere : ITerrainPaintableEffect | 33 | public class RevertSphere : ITerrainPaintableEffect |
34 | { | 34 | { |
35 | private ITerrainChannel m_revertmap; | 35 | private ITerrainChannel m_revertmap; |
36 | 36 | ||
37 | public RevertSphere(ITerrainChannel revertmap) | 37 | public RevertSphere(ITerrainChannel revertmap) |
38 | { | 38 | { |
39 | m_revertmap = revertmap; | 39 | m_revertmap = revertmap; |
40 | } | 40 | } |
41 | 41 | ||
42 | #region ITerrainPaintableEffect Members | 42 | #region ITerrainPaintableEffect Members |
43 | 43 | ||
44 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 44 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
45 | { | 45 | { |
46 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 46 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
47 | 47 | ||
48 | if (duration > 1.0) | 48 | if (duration > 1.0) |
49 | duration = 1.0; | 49 | duration = 1.0; |
50 | if (duration < 0) | 50 | if (duration < 0) |
51 | return; | 51 | return; |
52 | 52 | ||
53 | int x, y; | 53 | int x, y; |
54 | for (x = 0; x < map.Width; x++) | 54 | for (x = 0; x < map.Width; x++) |
55 | { | 55 | { |
56 | // Skip everything unlikely to be affected | 56 | // Skip everything unlikely to be affected |
57 | if (Math.Abs(x - rx) > strength * 1.1) | 57 | if (Math.Abs(x - rx) > strength * 1.1) |
58 | continue; | 58 | continue; |
59 | 59 | ||
60 | for (y = 0; y < map.Height; y++) | 60 | for (y = 0; y < map.Height; y++) |
61 | { | 61 | { |
62 | // Skip everything unlikely to be affected | 62 | // Skip everything unlikely to be affected |
63 | if (Math.Abs(y - ry) > strength * 1.1) | 63 | if (Math.Abs(y - ry) > strength * 1.1) |
64 | continue; | 64 | continue; |
65 | 65 | ||
66 | // Calculate a sphere and add it to the heighmap | 66 | // Calculate a sphere and add it to the heighmap |
67 | double z = strength; | 67 | double z = strength; |
68 | z *= z; | 68 | z *= z; |
69 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 69 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
70 | 70 | ||
71 | if (z > 0.0) | 71 | if (z > 0.0) |
72 | { | 72 | { |
73 | z *= duration; | 73 | z *= duration; |
74 | map[x, y] += (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z); | 74 | map[x, y] += (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | #endregion | 80 | #endregion |
81 | } | 81 | } |
82 | } \ No newline at end of file | 82 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs index 305a875..51d5f0e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs | |||
@@ -1,93 +1,93 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
31 | { | 31 | { |
32 | public class SmoothSphere : ITerrainPaintableEffect | 32 | public class SmoothSphere : ITerrainPaintableEffect |
33 | { | 33 | { |
34 | #region ITerrainPaintableEffect Members | 34 | #region ITerrainPaintableEffect Members |
35 | 35 | ||
36 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 36 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
37 | { | 37 | { |
38 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 38 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
39 | 39 | ||
40 | int x, y; | 40 | int x, y; |
41 | double[,] tweak = new double[map.Width,map.Height]; | 41 | double[,] tweak = new double[map.Width,map.Height]; |
42 | 42 | ||
43 | double n, l; | 43 | double n, l; |
44 | double area = strength; | 44 | double area = strength; |
45 | double step = strength / 4.0; | 45 | double step = strength / 4.0; |
46 | 46 | ||
47 | // compute delta map | 47 | // compute delta map |
48 | for (x = 0; x < map.Width; x++) | 48 | for (x = 0; x < map.Width; x++) |
49 | { | 49 | { |
50 | for (y = 0; y < map.Height; y++) | 50 | for (y = 0; y < map.Height; y++) |
51 | { | 51 | { |
52 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); | 52 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); |
53 | 53 | ||
54 | if (z > 0) // add in non-zero amount | 54 | if (z > 0) // add in non-zero amount |
55 | { | 55 | { |
56 | double average = 0.0; | 56 | double average = 0.0; |
57 | int avgsteps = 0; | 57 | int avgsteps = 0; |
58 | 58 | ||
59 | for (n = 0.0 - area; n < area; n += step) | 59 | for (n = 0.0 - area; n < area; n += step) |
60 | { | 60 | { |
61 | for (l = 0.0 - area; l < area; l += step) | 61 | for (l = 0.0 - area; l < area; l += step) |
62 | { | 62 | { |
63 | avgsteps++; | 63 | avgsteps++; |
64 | average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map); | 64 | average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | tweak[x, y] = average / avgsteps; | 67 | tweak[x, y] = average / avgsteps; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } | 70 | } |
71 | // blend in map | 71 | // blend in map |
72 | for (x = 0; x < map.Width; x++) | 72 | for (x = 0; x < map.Width; x++) |
73 | { | 73 | { |
74 | for (y = 0; y < map.Height; y++) | 74 | for (y = 0; y < map.Height; y++) |
75 | { | 75 | { |
76 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); | 76 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); |
77 | 77 | ||
78 | if (z > 0) // add in non-zero amount | 78 | if (z > 0) // add in non-zero amount |
79 | { | 79 | { |
80 | double da = z; | 80 | double da = z; |
81 | double a = (map[x, y] - tweak[x, y]) * da; | 81 | double a = (map[x, y] - tweak[x, y]) * da; |
82 | double newz = map[x, y] - (a * duration); | 82 | double newz = map[x, y] - (a * duration); |
83 | 83 | ||
84 | if (newz > 0.0) | 84 | if (newz > 0.0) |
85 | map[x, y] = newz; | 85 | map[x, y] = newz; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | #endregion | 91 | #endregion |
92 | } | 92 | } |
93 | } \ No newline at end of file | 93 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs index 2d81054..b48beb8 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs | |||
@@ -1,207 +1,207 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
31 | { | 31 | { |
32 | /// <summary> | 32 | /// <summary> |
33 | /// Thermal Weathering Paint Brush | 33 | /// Thermal Weathering Paint Brush |
34 | /// </summary> | 34 | /// </summary> |
35 | public class WeatherSphere : ITerrainPaintableEffect | 35 | public class WeatherSphere : ITerrainPaintableEffect |
36 | { | 36 | { |
37 | private double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. | 37 | private double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. |
38 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter | 38 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter |
39 | 39 | ||
40 | #region Supporting Functions | 40 | #region Supporting Functions |
41 | 41 | ||
42 | private int[] Neighbours(NeighbourSystem type, int index) | 42 | private int[] Neighbours(NeighbourSystem type, int index) |
43 | { | 43 | { |
44 | int[] coord = new int[2]; | 44 | int[] coord = new int[2]; |
45 | 45 | ||
46 | index++; | 46 | index++; |
47 | 47 | ||
48 | switch (type) | 48 | switch (type) |
49 | { | 49 | { |
50 | case NeighbourSystem.Moore: | 50 | case NeighbourSystem.Moore: |
51 | switch (index) | 51 | switch (index) |
52 | { | 52 | { |
53 | case 1: | 53 | case 1: |
54 | coord[0] = -1; | 54 | coord[0] = -1; |
55 | coord[1] = -1; | 55 | coord[1] = -1; |
56 | break; | 56 | break; |
57 | 57 | ||
58 | case 2: | 58 | case 2: |
59 | coord[0] = -0; | 59 | coord[0] = -0; |
60 | coord[1] = -1; | 60 | coord[1] = -1; |
61 | break; | 61 | break; |
62 | 62 | ||
63 | case 3: | 63 | case 3: |
64 | coord[0] = +1; | 64 | coord[0] = +1; |
65 | coord[1] = -1; | 65 | coord[1] = -1; |
66 | break; | 66 | break; |
67 | 67 | ||
68 | case 4: | 68 | case 4: |
69 | coord[0] = -1; | 69 | coord[0] = -1; |
70 | coord[1] = -0; | 70 | coord[1] = -0; |
71 | break; | 71 | break; |
72 | 72 | ||
73 | case 5: | 73 | case 5: |
74 | coord[0] = -0; | 74 | coord[0] = -0; |
75 | coord[1] = -0; | 75 | coord[1] = -0; |
76 | break; | 76 | break; |
77 | 77 | ||
78 | case 6: | 78 | case 6: |
79 | coord[0] = +1; | 79 | coord[0] = +1; |
80 | coord[1] = -0; | 80 | coord[1] = -0; |
81 | break; | 81 | break; |
82 | 82 | ||
83 | case 7: | 83 | case 7: |
84 | coord[0] = -1; | 84 | coord[0] = -1; |
85 | coord[1] = +1; | 85 | coord[1] = +1; |
86 | break; | 86 | break; |
87 | 87 | ||
88 | case 8: | 88 | case 8: |
89 | coord[0] = -0; | 89 | coord[0] = -0; |
90 | coord[1] = +1; | 90 | coord[1] = +1; |
91 | break; | 91 | break; |
92 | 92 | ||
93 | case 9: | 93 | case 9: |
94 | coord[0] = +1; | 94 | coord[0] = +1; |
95 | coord[1] = +1; | 95 | coord[1] = +1; |
96 | break; | 96 | break; |
97 | 97 | ||
98 | default: | 98 | default: |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | break; | 101 | break; |
102 | 102 | ||
103 | case NeighbourSystem.VonNeumann: | 103 | case NeighbourSystem.VonNeumann: |
104 | switch (index) | 104 | switch (index) |
105 | { | 105 | { |
106 | case 1: | 106 | case 1: |
107 | coord[0] = 0; | 107 | coord[0] = 0; |
108 | coord[1] = -1; | 108 | coord[1] = -1; |
109 | break; | 109 | break; |
110 | 110 | ||
111 | case 2: | 111 | case 2: |
112 | coord[0] = -1; | 112 | coord[0] = -1; |
113 | coord[1] = 0; | 113 | coord[1] = 0; |
114 | break; | 114 | break; |
115 | 115 | ||
116 | case 3: | 116 | case 3: |
117 | coord[0] = +1; | 117 | coord[0] = +1; |
118 | coord[1] = 0; | 118 | coord[1] = 0; |
119 | break; | 119 | break; |
120 | 120 | ||
121 | case 4: | 121 | case 4: |
122 | coord[0] = 0; | 122 | coord[0] = 0; |
123 | coord[1] = +1; | 123 | coord[1] = +1; |
124 | break; | 124 | break; |
125 | 125 | ||
126 | case 5: | 126 | case 5: |
127 | coord[0] = -0; | 127 | coord[0] = -0; |
128 | coord[1] = -0; | 128 | coord[1] = -0; |
129 | break; | 129 | break; |
130 | 130 | ||
131 | default: | 131 | default: |
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | 136 | ||
137 | return coord; | 137 | return coord; |
138 | } | 138 | } |
139 | 139 | ||
140 | private enum NeighbourSystem | 140 | private enum NeighbourSystem |
141 | { | 141 | { |
142 | Moore, | 142 | Moore, |
143 | VonNeumann | 143 | VonNeumann |
144 | } ; | 144 | } ; |
145 | 145 | ||
146 | #endregion | 146 | #endregion |
147 | 147 | ||
148 | #region ITerrainPaintableEffect Members | 148 | #region ITerrainPaintableEffect Members |
149 | 149 | ||
150 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 150 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
151 | { | 151 | { |
152 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 152 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
153 | 153 | ||
154 | int x, y; | 154 | int x, y; |
155 | 155 | ||
156 | for (x = 0; x < map.Width; x++) | 156 | for (x = 0; x < map.Width; x++) |
157 | { | 157 | { |
158 | for (y = 0; y < map.Height; y++) | 158 | for (y = 0; y < map.Height; y++) |
159 | { | 159 | { |
160 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); | 160 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); |
161 | 161 | ||
162 | if (z > 0) // add in non-zero amount | 162 | if (z > 0) // add in non-zero amount |
163 | { | 163 | { |
164 | int NEIGHBOUR_ME = 4; | 164 | int NEIGHBOUR_ME = 4; |
165 | 165 | ||
166 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; | 166 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; |
167 | 167 | ||
168 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 168 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
169 | { | 169 | { |
170 | if (j != NEIGHBOUR_ME) | 170 | if (j != NEIGHBOUR_ME) |
171 | { | 171 | { |
172 | int[] coords = Neighbours(type, j); | 172 | int[] coords = Neighbours(type, j); |
173 | 173 | ||
174 | coords[0] += x; | 174 | coords[0] += x; |
175 | coords[1] += y; | 175 | coords[1] += y; |
176 | 176 | ||
177 | if (coords[0] > map.Width - 1) | 177 | if (coords[0] > map.Width - 1) |
178 | continue; | 178 | continue; |
179 | if (coords[1] > map.Height - 1) | 179 | if (coords[1] > map.Height - 1) |
180 | continue; | 180 | continue; |
181 | if (coords[0] < 0) | 181 | if (coords[0] < 0) |
182 | continue; | 182 | continue; |
183 | if (coords[1] < 0) | 183 | if (coords[1] < 0) |
184 | continue; | 184 | continue; |
185 | 185 | ||
186 | double heightF = map[x, y]; | 186 | double heightF = map[x, y]; |
187 | double target = map[coords[0], coords[1]]; | 187 | double target = map[coords[0], coords[1]]; |
188 | 188 | ||
189 | if (target > heightF + talus) | 189 | if (target > heightF + talus) |
190 | { | 190 | { |
191 | double calc = duration * ((target - heightF) - talus) * z; | 191 | double calc = duration * ((target - heightF) - talus) * z; |
192 | heightF += calc; | 192 | heightF += calc; |
193 | target -= calc; | 193 | target -= calc; |
194 | } | 194 | } |
195 | 195 | ||
196 | map[x, y] = heightF; | 196 | map[x, y] = heightF; |
197 | map[coords[0], coords[1]] = target; | 197 | map[coords[0], coords[1]] = target; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | #endregion | 205 | #endregion |
206 | } | 206 | } |
207 | } \ No newline at end of file | 207 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs index e2df885..4f7d20c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs | |||
@@ -1,157 +1,157 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework; | 28 | using OpenSim.Framework; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// A new version of the old Channel class, simplified | 34 | /// A new version of the old Channel class, simplified |
35 | /// </summary> | 35 | /// </summary> |
36 | public class TerrainChannel : ITerrainChannel | 36 | public class TerrainChannel : ITerrainChannel |
37 | { | 37 | { |
38 | private readonly bool[,] taint; | 38 | private readonly bool[,] taint; |
39 | private double[,] map; | 39 | private double[,] map; |
40 | 40 | ||
41 | public TerrainChannel() | 41 | public TerrainChannel() |
42 | { | 42 | { |
43 | map = new double[Constants.RegionSize,Constants.RegionSize]; | 43 | map = new double[Constants.RegionSize,Constants.RegionSize]; |
44 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; | 44 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; |
45 | 45 | ||
46 | int x; | 46 | int x; |
47 | for (x = 0; x < Constants.RegionSize; x++) | 47 | for (x = 0; x < Constants.RegionSize; x++) |
48 | { | 48 | { |
49 | int y; | 49 | int y; |
50 | for (y = 0; y < Constants.RegionSize; y++) | 50 | for (y = 0; y < Constants.RegionSize; y++) |
51 | { | 51 | { |
52 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; | 52 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; |
53 | double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; | 53 | double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; |
54 | if (map[x, y] < spherFac) | 54 | if (map[x, y] < spherFac) |
55 | { | 55 | { |
56 | map[x, y] = spherFac; | 56 | map[x, y] = spherFac; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | public TerrainChannel(double[,] import) | 62 | public TerrainChannel(double[,] import) |
63 | { | 63 | { |
64 | map = import; | 64 | map = import; |
65 | taint = new bool[import.GetLength(0),import.GetLength(1)]; | 65 | taint = new bool[import.GetLength(0),import.GetLength(1)]; |
66 | } | 66 | } |
67 | 67 | ||
68 | public TerrainChannel(bool createMap) | 68 | public TerrainChannel(bool createMap) |
69 | { | 69 | { |
70 | if (createMap) | 70 | if (createMap) |
71 | { | 71 | { |
72 | map = new double[Constants.RegionSize,Constants.RegionSize]; | 72 | map = new double[Constants.RegionSize,Constants.RegionSize]; |
73 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; | 73 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | public TerrainChannel(int w, int h) | 77 | public TerrainChannel(int w, int h) |
78 | { | 78 | { |
79 | map = new double[w,h]; | 79 | map = new double[w,h]; |
80 | taint = new bool[w / 16,h / 16]; | 80 | taint = new bool[w / 16,h / 16]; |
81 | } | 81 | } |
82 | 82 | ||
83 | #region ITerrainChannel Members | 83 | #region ITerrainChannel Members |
84 | 84 | ||
85 | public int Width | 85 | public int Width |
86 | { | 86 | { |
87 | get { return map.GetLength(0); } | 87 | get { return map.GetLength(0); } |
88 | } | 88 | } |
89 | 89 | ||
90 | public int Height | 90 | public int Height |
91 | { | 91 | { |
92 | get { return map.GetLength(1); } | 92 | get { return map.GetLength(1); } |
93 | } | 93 | } |
94 | 94 | ||
95 | public ITerrainChannel MakeCopy() | 95 | public ITerrainChannel MakeCopy() |
96 | { | 96 | { |
97 | TerrainChannel copy = new TerrainChannel(false); | 97 | TerrainChannel copy = new TerrainChannel(false); |
98 | copy.map = (double[,]) map.Clone(); | 98 | copy.map = (double[,]) map.Clone(); |
99 | 99 | ||
100 | return copy; | 100 | return copy; |
101 | } | 101 | } |
102 | 102 | ||
103 | public float[] GetFloatsSerialised() | 103 | public float[] GetFloatsSerialised() |
104 | { | 104 | { |
105 | float[] heights = new float[Width * Height]; | 105 | float[] heights = new float[Width * Height]; |
106 | int i; | 106 | int i; |
107 | 107 | ||
108 | for (i = 0; i < Width * Height; i++) | 108 | for (i = 0; i < Width * Height; i++) |
109 | { | 109 | { |
110 | heights[i] = (float) map[i % Width, i / Width]; | 110 | heights[i] = (float) map[i % Width, i / Width]; |
111 | } | 111 | } |
112 | 112 | ||
113 | return heights; | 113 | return heights; |
114 | } | 114 | } |
115 | 115 | ||
116 | public double[,] GetDoubles() | 116 | public double[,] GetDoubles() |
117 | { | 117 | { |
118 | return map; | 118 | return map; |
119 | } | 119 | } |
120 | 120 | ||
121 | public double this[int x, int y] | 121 | public double this[int x, int y] |
122 | { | 122 | { |
123 | get { return map[x, y]; } | 123 | get { return map[x, y]; } |
124 | set | 124 | set |
125 | { | 125 | { |
126 | if (map[x, y] != value) | 126 | if (map[x, y] != value) |
127 | { | 127 | { |
128 | taint[x / 16, y / 16] = true; | 128 | taint[x / 16, y / 16] = true; |
129 | map[x, y] = value; | 129 | map[x, y] = value; |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | public bool Tainted(int x, int y) | 134 | public bool Tainted(int x, int y) |
135 | { | 135 | { |
136 | if (taint[x / 16, y / 16]) | 136 | if (taint[x / 16, y / 16]) |
137 | { | 137 | { |
138 | taint[x / 16, y / 16] = false; | 138 | taint[x / 16, y / 16] = false; |
139 | return true; | 139 | return true; |
140 | } | 140 | } |
141 | else | 141 | else |
142 | { | 142 | { |
143 | return false; | 143 | return false; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | #endregion | 147 | #endregion |
148 | 148 | ||
149 | public TerrainChannel Copy() | 149 | public TerrainChannel Copy() |
150 | { | 150 | { |
151 | TerrainChannel copy = new TerrainChannel(false); | 151 | TerrainChannel copy = new TerrainChannel(false); |
152 | copy.map = (double[,]) map.Clone(); | 152 | copy.map = (double[,]) map.Clone(); |
153 | 153 | ||
154 | return copy; | 154 | return copy; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } \ No newline at end of file | 157 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs index 1095cb9..f5c0fe4 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs | |||
@@ -1,46 +1,46 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
31 | { | 31 | { |
32 | public class TerrainException : Exception | 32 | public class TerrainException : Exception |
33 | { | 33 | { |
34 | public TerrainException() : base() | 34 | public TerrainException() : base() |
35 | { | 35 | { |
36 | } | 36 | } |
37 | 37 | ||
38 | public TerrainException(string msg) : base(msg) | 38 | public TerrainException(string msg) : base(msg) |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | public TerrainException(string msg, Exception e) : base(msg, e) | 42 | public TerrainException(string msg, Exception e) : base(msg, e) |
43 | { | 43 | { |
44 | } | 44 | } |
45 | } | 45 | } |
46 | } \ No newline at end of file | 46 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs index 09c3117..eff6159 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs | |||
@@ -1,736 +1,736 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using libsecondlife; | 32 | using libsecondlife; |
33 | using log4net; | 33 | using log4net; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.Environment.Interfaces; | 36 | using OpenSim.Region.Environment.Interfaces; |
37 | using OpenSim.Region.Environment.Modules.Framework; | 37 | using OpenSim.Region.Environment.Modules.Framework; |
38 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; | 38 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; |
39 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; | 39 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; |
40 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; | 40 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; |
41 | using OpenSim.Region.Environment.Scenes; | 41 | using OpenSim.Region.Environment.Scenes; |
42 | 42 | ||
43 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 43 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
44 | { | 44 | { |
45 | public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule | 45 | public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule |
46 | { | 46 | { |
47 | #region StandardTerrainEffects enum | 47 | #region StandardTerrainEffects enum |
48 | 48 | ||
49 | /// <summary> | 49 | /// <summary> |
50 | /// A standard set of terrain brushes and effects recognised by viewers | 50 | /// A standard set of terrain brushes and effects recognised by viewers |
51 | /// </summary> | 51 | /// </summary> |
52 | public enum StandardTerrainEffects : byte | 52 | public enum StandardTerrainEffects : byte |
53 | { | 53 | { |
54 | Flatten = 0, | 54 | Flatten = 0, |
55 | Raise = 1, | 55 | Raise = 1, |
56 | Lower = 2, | 56 | Lower = 2, |
57 | Smooth = 3, | 57 | Smooth = 3, |
58 | Noise = 4, | 58 | Noise = 4, |
59 | Revert = 5, | 59 | Revert = 5, |
60 | 60 | ||
61 | // Extended brushes | 61 | // Extended brushes |
62 | Erode = 255, | 62 | Erode = 255, |
63 | Weather = 254, | 63 | Weather = 254, |
64 | Olsen = 253 | 64 | Olsen = 253 |
65 | } | 65 | } |
66 | 66 | ||
67 | #endregion | 67 | #endregion |
68 | 68 | ||
69 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 69 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
70 | 70 | ||
71 | private readonly Commander m_commander = new Commander("Terrain"); | 71 | private readonly Commander m_commander = new Commander("Terrain"); |
72 | 72 | ||
73 | private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects = | 73 | private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects = |
74 | new Dictionary<StandardTerrainEffects, ITerrainFloodEffect>(); | 74 | new Dictionary<StandardTerrainEffects, ITerrainFloodEffect>(); |
75 | 75 | ||
76 | private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>(); | 76 | private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>(); |
77 | 77 | ||
78 | private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = | 78 | private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = |
79 | new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); | 79 | new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); |
80 | 80 | ||
81 | private ITerrainChannel m_channel; | 81 | private ITerrainChannel m_channel; |
82 | private Dictionary<Location, ITerrainChannel> m_channels; | 82 | private Dictionary<Location, ITerrainChannel> m_channels; |
83 | private Dictionary<string, ITerrainEffect> m_plugineffects; | 83 | private Dictionary<string, ITerrainEffect> m_plugineffects; |
84 | private ITerrainChannel m_revert; | 84 | private ITerrainChannel m_revert; |
85 | private Scene m_scene; | 85 | private Scene m_scene; |
86 | private bool m_tainted = false; | 86 | private bool m_tainted = false; |
87 | 87 | ||
88 | #region ICommandableModule Members | 88 | #region ICommandableModule Members |
89 | 89 | ||
90 | public ICommander CommandInterface | 90 | public ICommander CommandInterface |
91 | { | 91 | { |
92 | get { return m_commander; } | 92 | get { return m_commander; } |
93 | } | 93 | } |
94 | 94 | ||
95 | #endregion | 95 | #endregion |
96 | 96 | ||
97 | #region IRegionModule Members | 97 | #region IRegionModule Members |
98 | 98 | ||
99 | /// <summary> | 99 | /// <summary> |
100 | /// Creates and initialises a terrain module for a region | 100 | /// Creates and initialises a terrain module for a region |
101 | /// </summary> | 101 | /// </summary> |
102 | /// <param name="scene">Region initialising</param> | 102 | /// <param name="scene">Region initialising</param> |
103 | /// <param name="config">Config for the region</param> | 103 | /// <param name="config">Config for the region</param> |
104 | public void Initialise(Scene scene, IConfigSource config) | 104 | public void Initialise(Scene scene, IConfigSource config) |
105 | { | 105 | { |
106 | m_scene = scene; | 106 | m_scene = scene; |
107 | 107 | ||
108 | // Install terrain module in the simulator | 108 | // Install terrain module in the simulator |
109 | if (m_scene.Heightmap == null) | 109 | if (m_scene.Heightmap == null) |
110 | { | 110 | { |
111 | lock (m_scene) | 111 | lock (m_scene) |
112 | { | 112 | { |
113 | m_channel = new TerrainChannel(); | 113 | m_channel = new TerrainChannel(); |
114 | m_scene.Heightmap = m_channel; | 114 | m_scene.Heightmap = m_channel; |
115 | m_revert = new TerrainChannel(); | 115 | m_revert = new TerrainChannel(); |
116 | UpdateRevertMap(); | 116 | UpdateRevertMap(); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | else | 119 | else |
120 | { | 120 | { |
121 | m_channel = m_scene.Heightmap; | 121 | m_channel = m_scene.Heightmap; |
122 | m_revert = new TerrainChannel(); | 122 | m_revert = new TerrainChannel(); |
123 | UpdateRevertMap(); | 123 | UpdateRevertMap(); |
124 | } | 124 | } |
125 | 125 | ||
126 | m_scene.RegisterModuleInterface<ITerrainModule>(this); | 126 | m_scene.RegisterModuleInterface<ITerrainModule>(this); |
127 | m_scene.EventManager.OnNewClient += EventManager_OnNewClient; | 127 | m_scene.EventManager.OnNewClient += EventManager_OnNewClient; |
128 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | 128 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; |
129 | m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; | 129 | m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; |
130 | } | 130 | } |
131 | 131 | ||
132 | /// <summary> | 132 | /// <summary> |
133 | /// Enables terrain module when called | 133 | /// Enables terrain module when called |
134 | /// </summary> | 134 | /// </summary> |
135 | public void PostInitialise() | 135 | public void PostInitialise() |
136 | { | 136 | { |
137 | InstallDefaultEffects(); | 137 | InstallDefaultEffects(); |
138 | InstallInterfaces(); | 138 | InstallInterfaces(); |
139 | LoadPlugins(); | 139 | LoadPlugins(); |
140 | } | 140 | } |
141 | 141 | ||
142 | public void Close() | 142 | public void Close() |
143 | { | 143 | { |
144 | } | 144 | } |
145 | 145 | ||
146 | public string Name | 146 | public string Name |
147 | { | 147 | { |
148 | get { return "TerrainModule"; } | 148 | get { return "TerrainModule"; } |
149 | } | 149 | } |
150 | 150 | ||
151 | public bool IsSharedModule | 151 | public bool IsSharedModule |
152 | { | 152 | { |
153 | get { return false; } | 153 | get { return false; } |
154 | } | 154 | } |
155 | 155 | ||
156 | #endregion | 156 | #endregion |
157 | 157 | ||
158 | #region ITerrainModule Members | 158 | #region ITerrainModule Members |
159 | 159 | ||
160 | /// <summary> | 160 | /// <summary> |
161 | /// Loads a terrain file from disk and installs it in the scene. | 161 | /// Loads a terrain file from disk and installs it in the scene. |
162 | /// </summary> | 162 | /// </summary> |
163 | /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> | 163 | /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> |
164 | public void LoadFromFile(string filename) | 164 | public void LoadFromFile(string filename) |
165 | { | 165 | { |
166 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 166 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
167 | { | 167 | { |
168 | if (filename.EndsWith(loader.Key)) | 168 | if (filename.EndsWith(loader.Key)) |
169 | { | 169 | { |
170 | lock (m_scene) | 170 | lock (m_scene) |
171 | { | 171 | { |
172 | try | 172 | try |
173 | { | 173 | { |
174 | ITerrainChannel channel = loader.Value.LoadFile(filename); | 174 | ITerrainChannel channel = loader.Value.LoadFile(filename); |
175 | m_scene.Heightmap = channel; | 175 | m_scene.Heightmap = channel; |
176 | m_channel = channel; | 176 | m_channel = channel; |
177 | UpdateRevertMap(); | 177 | UpdateRevertMap(); |
178 | } | 178 | } |
179 | catch (NotImplementedException) | 179 | catch (NotImplementedException) |
180 | { | 180 | { |
181 | m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value + | 181 | m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value + |
182 | " parser does not support file loading. (May be save only)"); | 182 | " parser does not support file loading. (May be save only)"); |
183 | throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value)); | 183 | throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value)); |
184 | } | 184 | } |
185 | catch (FileNotFoundException) | 185 | catch (FileNotFoundException) |
186 | { | 186 | { |
187 | m_log.Error( | 187 | m_log.Error( |
188 | "[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)"); | 188 | "[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)"); |
189 | throw new TerrainException( | 189 | throw new TerrainException( |
190 | String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access", filename)); | 190 | String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access", filename)); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | CheckForTerrainUpdates(); | 193 | CheckForTerrainUpdates(); |
194 | m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully"); | 194 | m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully"); |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format."); | 198 | m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format."); |
199 | throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); | 199 | throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); |
200 | } | 200 | } |
201 | 201 | ||
202 | /// <summary> | 202 | /// <summary> |
203 | /// Saves the current heightmap to a specified file. | 203 | /// Saves the current heightmap to a specified file. |
204 | /// </summary> | 204 | /// </summary> |
205 | /// <param name="filename">The destination filename</param> | 205 | /// <param name="filename">The destination filename</param> |
206 | public void SaveToFile(string filename) | 206 | public void SaveToFile(string filename) |
207 | { | 207 | { |
208 | try | 208 | try |
209 | { | 209 | { |
210 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 210 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
211 | { | 211 | { |
212 | if (filename.EndsWith(loader.Key)) | 212 | if (filename.EndsWith(loader.Key)) |
213 | { | 213 | { |
214 | loader.Value.SaveFile(filename, m_channel); | 214 | loader.Value.SaveFile(filename, m_channel); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | catch (NotImplementedException) | 219 | catch (NotImplementedException) |
220 | { | 220 | { |
221 | m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented."); | 221 | m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented."); |
222 | throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented")); | 222 | throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented")); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | #region Plugin Loading Methods | 226 | #region Plugin Loading Methods |
227 | 227 | ||
228 | private void LoadPlugins() | 228 | private void LoadPlugins() |
229 | { | 229 | { |
230 | m_plugineffects = new Dictionary<string, ITerrainEffect>(); | 230 | m_plugineffects = new Dictionary<string, ITerrainEffect>(); |
231 | // Load the files in the Terrain/ dir | 231 | // Load the files in the Terrain/ dir |
232 | string[] files = Directory.GetFiles("Terrain"); | 232 | string[] files = Directory.GetFiles("Terrain"); |
233 | foreach (string file in files) | 233 | foreach (string file in files) |
234 | { | 234 | { |
235 | m_log.Info("Loading effects in " + file); | 235 | m_log.Info("Loading effects in " + file); |
236 | try | 236 | try |
237 | { | 237 | { |
238 | Assembly library = Assembly.LoadFrom(file); | 238 | Assembly library = Assembly.LoadFrom(file); |
239 | foreach (Type pluginType in library.GetTypes()) | 239 | foreach (Type pluginType in library.GetTypes()) |
240 | { | 240 | { |
241 | try | 241 | try |
242 | { | 242 | { |
243 | if (pluginType.IsAbstract || pluginType.IsNotPublic) | 243 | if (pluginType.IsAbstract || pluginType.IsNotPublic) |
244 | continue; | 244 | continue; |
245 | 245 | ||
246 | if (pluginType.GetInterface("ITerrainEffect", false) != null) | 246 | if (pluginType.GetInterface("ITerrainEffect", false) != null) |
247 | { | 247 | { |
248 | ITerrainEffect terEffect = (ITerrainEffect) Activator.CreateInstance(library.GetType(pluginType.ToString())); | 248 | ITerrainEffect terEffect = (ITerrainEffect) Activator.CreateInstance(library.GetType(pluginType.ToString())); |
249 | if (!m_plugineffects.ContainsKey(pluginType.Name)) | 249 | if (!m_plugineffects.ContainsKey(pluginType.Name)) |
250 | { | 250 | { |
251 | m_plugineffects.Add(pluginType.Name, terEffect); | 251 | m_plugineffects.Add(pluginType.Name, terEffect); |
252 | m_log.Info("E ... " + pluginType.Name); | 252 | m_log.Info("E ... " + pluginType.Name); |
253 | } | 253 | } |
254 | else | 254 | else |
255 | { | 255 | { |
256 | m_log.Warn("E ... " + pluginType.Name + " (Already added)"); | 256 | m_log.Warn("E ... " + pluginType.Name + " (Already added)"); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | else if (pluginType.GetInterface("ITerrainLoader", false) != null) | 259 | else if (pluginType.GetInterface("ITerrainLoader", false) != null) |
260 | { | 260 | { |
261 | ITerrainLoader terLoader = (ITerrainLoader) Activator.CreateInstance(library.GetType(pluginType.ToString())); | 261 | ITerrainLoader terLoader = (ITerrainLoader) Activator.CreateInstance(library.GetType(pluginType.ToString())); |
262 | m_loaders[terLoader.FileExtension] = terLoader; | 262 | m_loaders[terLoader.FileExtension] = terLoader; |
263 | m_log.Info("L ... " + pluginType.Name); | 263 | m_log.Info("L ... " + pluginType.Name); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | catch (AmbiguousMatchException) | 266 | catch (AmbiguousMatchException) |
267 | { | 267 | { |
268 | } | 268 | } |
269 | } | 269 | } |
270 | } | 270 | } |
271 | catch (BadImageFormatException) | 271 | catch (BadImageFormatException) |
272 | { | 272 | { |
273 | } | 273 | } |
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | #endregion | 277 | #endregion |
278 | 278 | ||
279 | #endregion | 279 | #endregion |
280 | 280 | ||
281 | /// <summary> | 281 | /// <summary> |
282 | /// Installs into terrain module the standard suite of brushes | 282 | /// Installs into terrain module the standard suite of brushes |
283 | /// </summary> | 283 | /// </summary> |
284 | private void InstallDefaultEffects() | 284 | private void InstallDefaultEffects() |
285 | { | 285 | { |
286 | // Draggable Paint Brush Effects | 286 | // Draggable Paint Brush Effects |
287 | m_painteffects[StandardTerrainEffects.Raise] = new RaiseSphere(); | 287 | m_painteffects[StandardTerrainEffects.Raise] = new RaiseSphere(); |
288 | m_painteffects[StandardTerrainEffects.Lower] = new LowerSphere(); | 288 | m_painteffects[StandardTerrainEffects.Lower] = new LowerSphere(); |
289 | m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere(); | 289 | m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere(); |
290 | m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere(); | 290 | m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere(); |
291 | m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere(); | 291 | m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere(); |
292 | m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_revert); | 292 | m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_revert); |
293 | m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere(); | 293 | m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere(); |
294 | m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere(); | 294 | m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere(); |
295 | m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere(); | 295 | m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere(); |
296 | 296 | ||
297 | // Area of effect selection effects | 297 | // Area of effect selection effects |
298 | m_floodeffects[StandardTerrainEffects.Raise] = new RaiseArea(); | 298 | m_floodeffects[StandardTerrainEffects.Raise] = new RaiseArea(); |
299 | m_floodeffects[StandardTerrainEffects.Lower] = new LowerArea(); | 299 | m_floodeffects[StandardTerrainEffects.Lower] = new LowerArea(); |
300 | m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea(); | 300 | m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea(); |
301 | m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea(); | 301 | m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea(); |
302 | m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea(); | 302 | m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea(); |
303 | m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_revert); | 303 | m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_revert); |
304 | 304 | ||
305 | // Filesystem load/save loaders | 305 | // Filesystem load/save loaders |
306 | m_loaders[".r32"] = new RAW32(); | 306 | m_loaders[".r32"] = new RAW32(); |
307 | m_loaders[".f32"] = m_loaders[".r32"]; | 307 | m_loaders[".f32"] = m_loaders[".r32"]; |
308 | m_loaders[".ter"] = new Terragen(); | 308 | m_loaders[".ter"] = new Terragen(); |
309 | m_loaders[".raw"] = new LLRAW(); | 309 | m_loaders[".raw"] = new LLRAW(); |
310 | m_loaders[".jpg"] = new JPEG(); | 310 | m_loaders[".jpg"] = new JPEG(); |
311 | m_loaders[".jpeg"] = m_loaders[".jpg"]; | 311 | m_loaders[".jpeg"] = m_loaders[".jpg"]; |
312 | m_loaders[".bmp"] = new BMP(); | 312 | m_loaders[".bmp"] = new BMP(); |
313 | m_loaders[".png"] = new PNG(); | 313 | m_loaders[".png"] = new PNG(); |
314 | m_loaders[".gif"] = new GIF(); | 314 | m_loaders[".gif"] = new GIF(); |
315 | m_loaders[".tif"] = new TIFF(); | 315 | m_loaders[".tif"] = new TIFF(); |
316 | m_loaders[".tiff"] = m_loaders[".tif"]; | 316 | m_loaders[".tiff"] = m_loaders[".tif"]; |
317 | } | 317 | } |
318 | 318 | ||
319 | /// <summary> | 319 | /// <summary> |
320 | /// Saves the current state of the region into the revert map buffer. | 320 | /// Saves the current state of the region into the revert map buffer. |
321 | /// </summary> | 321 | /// </summary> |
322 | public void UpdateRevertMap() | 322 | public void UpdateRevertMap() |
323 | { | 323 | { |
324 | int x; | 324 | int x; |
325 | for (x = 0; x < m_channel.Width; x++) | 325 | for (x = 0; x < m_channel.Width; x++) |
326 | { | 326 | { |
327 | int y; | 327 | int y; |
328 | for (y = 0; y < m_channel.Height; y++) | 328 | for (y = 0; y < m_channel.Height; y++) |
329 | { | 329 | { |
330 | m_revert[x, y] = m_channel[x, y]; | 330 | m_revert[x, y] = m_channel[x, y]; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | /// <summary> | 335 | /// <summary> |
336 | /// Loads a tile from a larger terrain file and installs it into the region. | 336 | /// Loads a tile from a larger terrain file and installs it into the region. |
337 | /// </summary> | 337 | /// </summary> |
338 | /// <param name="filename">The terrain file to load</param> | 338 | /// <param name="filename">The terrain file to load</param> |
339 | /// <param name="fileWidth">The width of the file in units</param> | 339 | /// <param name="fileWidth">The width of the file in units</param> |
340 | /// <param name="fileHeight">The height of the file in units</param> | 340 | /// <param name="fileHeight">The height of the file in units</param> |
341 | /// <param name="fileStartX">Where to begin our slice</param> | 341 | /// <param name="fileStartX">Where to begin our slice</param> |
342 | /// <param name="fileStartY">Where to begin our slice</param> | 342 | /// <param name="fileStartY">Where to begin our slice</param> |
343 | public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) | 343 | public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) |
344 | { | 344 | { |
345 | int offsetX = (int) m_scene.RegionInfo.RegionLocX - fileStartX; | 345 | int offsetX = (int) m_scene.RegionInfo.RegionLocX - fileStartX; |
346 | int offsetY = (int) m_scene.RegionInfo.RegionLocY - fileStartY; | 346 | int offsetY = (int) m_scene.RegionInfo.RegionLocY - fileStartY; |
347 | 347 | ||
348 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) | 348 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) |
349 | { | 349 | { |
350 | // this region is included in the tile request | 350 | // this region is included in the tile request |
351 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 351 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
352 | { | 352 | { |
353 | if (filename.EndsWith(loader.Key)) | 353 | if (filename.EndsWith(loader.Key)) |
354 | { | 354 | { |
355 | lock (m_scene) | 355 | lock (m_scene) |
356 | { | 356 | { |
357 | ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY, | 357 | ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY, |
358 | fileWidth, fileHeight, | 358 | fileWidth, fileHeight, |
359 | (int) Constants.RegionSize, | 359 | (int) Constants.RegionSize, |
360 | (int) Constants.RegionSize); | 360 | (int) Constants.RegionSize); |
361 | m_scene.Heightmap = channel; | 361 | m_scene.Heightmap = channel; |
362 | m_channel = channel; | 362 | m_channel = channel; |
363 | UpdateRevertMap(); | 363 | UpdateRevertMap(); |
364 | } | 364 | } |
365 | return; | 365 | return; |
366 | } | 366 | } |
367 | } | 367 | } |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | /// <summary> | 371 | /// <summary> |
372 | /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections | 372 | /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections |
373 | /// </summary> | 373 | /// </summary> |
374 | private void EventManager_OnTerrainTick() | 374 | private void EventManager_OnTerrainTick() |
375 | { | 375 | { |
376 | if (m_tainted) | 376 | if (m_tainted) |
377 | { | 377 | { |
378 | m_tainted = false; | 378 | m_tainted = false; |
379 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); | 379 | m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); |
380 | m_scene.SaveTerrain(); | 380 | m_scene.SaveTerrain(); |
381 | m_scene.CreateTerrainTexture(true); | 381 | m_scene.CreateTerrainTexture(true); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | /// <summary> | 385 | /// <summary> |
386 | /// Processes commandline input. Do not call directly. | 386 | /// Processes commandline input. Do not call directly. |
387 | /// </summary> | 387 | /// </summary> |
388 | /// <param name="args">Commandline arguments</param> | 388 | /// <param name="args">Commandline arguments</param> |
389 | private void EventManager_OnPluginConsole(string[] args) | 389 | private void EventManager_OnPluginConsole(string[] args) |
390 | { | 390 | { |
391 | if (args[0] == "terrain") | 391 | if (args[0] == "terrain") |
392 | { | 392 | { |
393 | string[] tmpArgs = new string[args.Length - 2]; | 393 | string[] tmpArgs = new string[args.Length - 2]; |
394 | int i; | 394 | int i; |
395 | for (i = 2; i < args.Length; i++) | 395 | for (i = 2; i < args.Length; i++) |
396 | tmpArgs[i - 2] = args[i]; | 396 | tmpArgs[i - 2] = args[i]; |
397 | 397 | ||
398 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); | 398 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | /// <summary> | 402 | /// <summary> |
403 | /// Installs terrain brush hook to IClientAPI | 403 | /// Installs terrain brush hook to IClientAPI |
404 | /// </summary> | 404 | /// </summary> |
405 | /// <param name="client"></param> | 405 | /// <param name="client"></param> |
406 | private void EventManager_OnNewClient(IClientAPI client) | 406 | private void EventManager_OnNewClient(IClientAPI client) |
407 | { | 407 | { |
408 | client.OnModifyTerrain += client_OnModifyTerrain; | 408 | client.OnModifyTerrain += client_OnModifyTerrain; |
409 | } | 409 | } |
410 | 410 | ||
411 | /// <summary> | 411 | /// <summary> |
412 | /// Checks to see if the terrain has been modified since last check | 412 | /// Checks to see if the terrain has been modified since last check |
413 | /// </summary> | 413 | /// </summary> |
414 | private void CheckForTerrainUpdates() | 414 | private void CheckForTerrainUpdates() |
415 | { | 415 | { |
416 | bool shouldTaint = false; | 416 | bool shouldTaint = false; |
417 | float[] serialised = m_channel.GetFloatsSerialised(); | 417 | float[] serialised = m_channel.GetFloatsSerialised(); |
418 | int x; | 418 | int x; |
419 | for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize) | 419 | for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize) |
420 | { | 420 | { |
421 | int y; | 421 | int y; |
422 | for (y = 0; y < m_channel.Height; y += Constants.TerrainPatchSize) | 422 | for (y = 0; y < m_channel.Height; y += Constants.TerrainPatchSize) |
423 | { | 423 | { |
424 | if (m_channel.Tainted(x, y)) | 424 | if (m_channel.Tainted(x, y)) |
425 | { | 425 | { |
426 | SendToClients(serialised, x, y); | 426 | SendToClients(serialised, x, y); |
427 | shouldTaint = true; | 427 | shouldTaint = true; |
428 | } | 428 | } |
429 | } | 429 | } |
430 | } | 430 | } |
431 | if (shouldTaint) | 431 | if (shouldTaint) |
432 | { | 432 | { |
433 | m_tainted = true; | 433 | m_tainted = true; |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | /// <summary> | 437 | /// <summary> |
438 | /// Sends a copy of the current terrain to the scenes clients | 438 | /// Sends a copy of the current terrain to the scenes clients |
439 | /// </summary> | 439 | /// </summary> |
440 | /// <param name="serialised">A copy of the terrain as a 1D float array of size w*h</param> | 440 | /// <param name="serialised">A copy of the terrain as a 1D float array of size w*h</param> |
441 | /// <param name="x">The patch corner to send</param> | 441 | /// <param name="x">The patch corner to send</param> |
442 | /// <param name="y">The patch corner to send</param> | 442 | /// <param name="y">The patch corner to send</param> |
443 | private void SendToClients(float[] serialised, int x, int y) | 443 | private void SendToClients(float[] serialised, int x, int y) |
444 | { | 444 | { |
445 | m_scene.ForEachClient( | 445 | m_scene.ForEachClient( |
446 | delegate(IClientAPI controller) { controller.SendLayerData(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised); }); | 446 | delegate(IClientAPI controller) { controller.SendLayerData(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised); }); |
447 | } | 447 | } |
448 | 448 | ||
449 | private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, | 449 | private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, |
450 | float south, float east, IClientAPI remoteClient) | 450 | float south, float east, IClientAPI remoteClient) |
451 | { | 451 | { |
452 | // Not a good permissions check, if in area mode, need to check the entire area. | 452 | // Not a good permissions check, if in area mode, need to check the entire area. |
453 | if (m_scene.PermissionsMngr.CanTerraform(remoteClient.AgentId, new LLVector3(north, west, 0))) | 453 | if (m_scene.PermissionsMngr.CanTerraform(remoteClient.AgentId, new LLVector3(north, west, 0))) |
454 | { | 454 | { |
455 | if (north == south && east == west) | 455 | if (north == south && east == west) |
456 | { | 456 | { |
457 | if (m_painteffects.ContainsKey((StandardTerrainEffects) action)) | 457 | if (m_painteffects.ContainsKey((StandardTerrainEffects) action)) |
458 | { | 458 | { |
459 | m_painteffects[(StandardTerrainEffects) action].PaintEffect( | 459 | m_painteffects[(StandardTerrainEffects) action].PaintEffect( |
460 | m_channel, west, south, size, seconds); | 460 | m_channel, west, south, size, seconds); |
461 | 461 | ||
462 | CheckForTerrainUpdates(); | 462 | CheckForTerrainUpdates(); |
463 | } | 463 | } |
464 | else | 464 | else |
465 | { | 465 | { |
466 | m_log.Debug("Unknown terrain brush type " + action); | 466 | m_log.Debug("Unknown terrain brush type " + action); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | else | 469 | else |
470 | { | 470 | { |
471 | if (m_floodeffects.ContainsKey((StandardTerrainEffects) action)) | 471 | if (m_floodeffects.ContainsKey((StandardTerrainEffects) action)) |
472 | { | 472 | { |
473 | bool[,] fillArea = new bool[m_channel.Width,m_channel.Height]; | 473 | bool[,] fillArea = new bool[m_channel.Width,m_channel.Height]; |
474 | fillArea.Initialize(); | 474 | fillArea.Initialize(); |
475 | 475 | ||
476 | int x; | 476 | int x; |
477 | for (x = 0; x < m_channel.Width; x++) | 477 | for (x = 0; x < m_channel.Width; x++) |
478 | { | 478 | { |
479 | int y; | 479 | int y; |
480 | for (y = 0; y < m_channel.Height; y++) | 480 | for (y = 0; y < m_channel.Height; y++) |
481 | { | 481 | { |
482 | if (x < east && x > west) | 482 | if (x < east && x > west) |
483 | { | 483 | { |
484 | if (y < north && y > south) | 484 | if (y < north && y > south) |
485 | { | 485 | { |
486 | fillArea[x, y] = true; | 486 | fillArea[x, y] = true; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | } | 489 | } |
490 | } | 490 | } |
491 | 491 | ||
492 | m_floodeffects[(StandardTerrainEffects) action].FloodEffect( | 492 | m_floodeffects[(StandardTerrainEffects) action].FloodEffect( |
493 | m_channel, fillArea, size); | 493 | m_channel, fillArea, size); |
494 | 494 | ||
495 | CheckForTerrainUpdates(); | 495 | CheckForTerrainUpdates(); |
496 | } | 496 | } |
497 | else | 497 | else |
498 | { | 498 | { |
499 | m_log.Debug("Unknown terrain flood type " + action); | 499 | m_log.Debug("Unknown terrain flood type " + action); |
500 | } | 500 | } |
501 | } | 501 | } |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | #region Console Commands | 505 | #region Console Commands |
506 | 506 | ||
507 | private void InterfaceLoadFile(Object[] args) | 507 | private void InterfaceLoadFile(Object[] args) |
508 | { | 508 | { |
509 | LoadFromFile((string) args[0]); | 509 | LoadFromFile((string) args[0]); |
510 | CheckForTerrainUpdates(); | 510 | CheckForTerrainUpdates(); |
511 | } | 511 | } |
512 | 512 | ||
513 | private void InterfaceLoadTileFile(Object[] args) | 513 | private void InterfaceLoadTileFile(Object[] args) |
514 | { | 514 | { |
515 | LoadFromFile((string) args[0], | 515 | LoadFromFile((string) args[0], |
516 | (int) args[1], | 516 | (int) args[1], |
517 | (int) args[2], | 517 | (int) args[2], |
518 | (int) args[3], | 518 | (int) args[3], |
519 | (int) args[4]); | 519 | (int) args[4]); |
520 | CheckForTerrainUpdates(); | 520 | CheckForTerrainUpdates(); |
521 | } | 521 | } |
522 | 522 | ||
523 | private void InterfaceSaveFile(Object[] args) | 523 | private void InterfaceSaveFile(Object[] args) |
524 | { | 524 | { |
525 | SaveToFile((string) args[0]); | 525 | SaveToFile((string) args[0]); |
526 | } | 526 | } |
527 | 527 | ||
528 | private void InterfaceBakeTerrain(Object[] args) | 528 | private void InterfaceBakeTerrain(Object[] args) |
529 | { | 529 | { |
530 | UpdateRevertMap(); | 530 | UpdateRevertMap(); |
531 | } | 531 | } |
532 | 532 | ||
533 | private void InterfaceRevertTerrain(Object[] args) | 533 | private void InterfaceRevertTerrain(Object[] args) |
534 | { | 534 | { |
535 | int x, y; | 535 | int x, y; |
536 | for (x = 0; x < m_channel.Width; x++) | 536 | for (x = 0; x < m_channel.Width; x++) |
537 | for (y = 0; y < m_channel.Height; y++) | 537 | for (y = 0; y < m_channel.Height; y++) |
538 | m_channel[x, y] = m_revert[x, y]; | 538 | m_channel[x, y] = m_revert[x, y]; |
539 | 539 | ||
540 | CheckForTerrainUpdates(); | 540 | CheckForTerrainUpdates(); |
541 | } | 541 | } |
542 | 542 | ||
543 | private void InterfaceElevateTerrain(Object[] args) | 543 | private void InterfaceElevateTerrain(Object[] args) |
544 | { | 544 | { |
545 | int x, y; | 545 | int x, y; |
546 | for (x = 0; x < m_channel.Width; x++) | 546 | for (x = 0; x < m_channel.Width; x++) |
547 | for (y = 0; y < m_channel.Height; y++) | 547 | for (y = 0; y < m_channel.Height; y++) |
548 | m_channel[x, y] += (double) args[0]; | 548 | m_channel[x, y] += (double) args[0]; |
549 | CheckForTerrainUpdates(); | 549 | CheckForTerrainUpdates(); |
550 | } | 550 | } |
551 | 551 | ||
552 | private void InterfaceMultiplyTerrain(Object[] args) | 552 | private void InterfaceMultiplyTerrain(Object[] args) |
553 | { | 553 | { |
554 | int x, y; | 554 | int x, y; |
555 | for (x = 0; x < m_channel.Width; x++) | 555 | for (x = 0; x < m_channel.Width; x++) |
556 | for (y = 0; y < m_channel.Height; y++) | 556 | for (y = 0; y < m_channel.Height; y++) |
557 | m_channel[x, y] *= (double) args[0]; | 557 | m_channel[x, y] *= (double) args[0]; |
558 | CheckForTerrainUpdates(); | 558 | CheckForTerrainUpdates(); |
559 | } | 559 | } |
560 | 560 | ||
561 | private void InterfaceLowerTerrain(Object[] args) | 561 | private void InterfaceLowerTerrain(Object[] args) |
562 | { | 562 | { |
563 | int x, y; | 563 | int x, y; |
564 | for (x = 0; x < m_channel.Width; x++) | 564 | for (x = 0; x < m_channel.Width; x++) |
565 | for (y = 0; y < m_channel.Height; y++) | 565 | for (y = 0; y < m_channel.Height; y++) |
566 | m_channel[x, y] -= (double) args[0]; | 566 | m_channel[x, y] -= (double) args[0]; |
567 | CheckForTerrainUpdates(); | 567 | CheckForTerrainUpdates(); |
568 | } | 568 | } |
569 | 569 | ||
570 | private void InterfaceFillTerrain(Object[] args) | 570 | private void InterfaceFillTerrain(Object[] args) |
571 | { | 571 | { |
572 | int x, y; | 572 | int x, y; |
573 | 573 | ||
574 | for (x = 0; x < m_channel.Width; x++) | 574 | for (x = 0; x < m_channel.Width; x++) |
575 | for (y = 0; y < m_channel.Height; y++) | 575 | for (y = 0; y < m_channel.Height; y++) |
576 | m_channel[x, y] = (double) args[0]; | 576 | m_channel[x, y] = (double) args[0]; |
577 | CheckForTerrainUpdates(); | 577 | CheckForTerrainUpdates(); |
578 | } | 578 | } |
579 | 579 | ||
580 | private void InterfaceShowDebugStats(Object[] args) | 580 | private void InterfaceShowDebugStats(Object[] args) |
581 | { | 581 | { |
582 | double max = Double.MinValue; | 582 | double max = Double.MinValue; |
583 | double min = double.MaxValue; | 583 | double min = double.MaxValue; |
584 | double avg; | 584 | double avg; |
585 | double sum = 0; | 585 | double sum = 0; |
586 | 586 | ||
587 | int x; | 587 | int x; |
588 | for (x = 0; x < m_channel.Width; x++) | 588 | for (x = 0; x < m_channel.Width; x++) |
589 | { | 589 | { |
590 | int y; | 590 | int y; |
591 | for (y = 0; y < m_channel.Height; y++) | 591 | for (y = 0; y < m_channel.Height; y++) |
592 | { | 592 | { |
593 | sum += m_channel[x, y]; | 593 | sum += m_channel[x, y]; |
594 | if (max < m_channel[x, y]) | 594 | if (max < m_channel[x, y]) |
595 | max = m_channel[x, y]; | 595 | max = m_channel[x, y]; |
596 | if (min > m_channel[x, y]) | 596 | if (min > m_channel[x, y]) |
597 | min = m_channel[x, y]; | 597 | min = m_channel[x, y]; |
598 | } | 598 | } |
599 | } | 599 | } |
600 | 600 | ||
601 | avg = sum / (m_channel.Height * m_channel.Width); | 601 | avg = sum / (m_channel.Height * m_channel.Width); |
602 | 602 | ||
603 | m_log.Info("Channel " + m_channel.Width + "x" + m_channel.Height); | 603 | m_log.Info("Channel " + m_channel.Width + "x" + m_channel.Height); |
604 | m_log.Info("max/min/avg/sum: " + max + "/" + min + "/" + avg + "/" + sum); | 604 | m_log.Info("max/min/avg/sum: " + max + "/" + min + "/" + avg + "/" + sum); |
605 | } | 605 | } |
606 | 606 | ||
607 | private void InterfaceEnableExperimentalBrushes(Object[] args) | 607 | private void InterfaceEnableExperimentalBrushes(Object[] args) |
608 | { | 608 | { |
609 | if ((bool) args[0]) | 609 | if ((bool) args[0]) |
610 | { | 610 | { |
611 | m_painteffects[StandardTerrainEffects.Revert] = new WeatherSphere(); | 611 | m_painteffects[StandardTerrainEffects.Revert] = new WeatherSphere(); |
612 | m_painteffects[StandardTerrainEffects.Flatten] = new OlsenSphere(); | 612 | m_painteffects[StandardTerrainEffects.Flatten] = new OlsenSphere(); |
613 | m_painteffects[StandardTerrainEffects.Smooth] = new ErodeSphere(); | 613 | m_painteffects[StandardTerrainEffects.Smooth] = new ErodeSphere(); |
614 | } | 614 | } |
615 | else | 615 | else |
616 | { | 616 | { |
617 | InstallDefaultEffects(); | 617 | InstallDefaultEffects(); |
618 | } | 618 | } |
619 | } | 619 | } |
620 | 620 | ||
621 | private void InterfaceRunPluginEffect(Object[] args) | 621 | private void InterfaceRunPluginEffect(Object[] args) |
622 | { | 622 | { |
623 | if ((string) args[0] == "list") | 623 | if ((string) args[0] == "list") |
624 | { | 624 | { |
625 | m_log.Info("List of loaded plugins"); | 625 | m_log.Info("List of loaded plugins"); |
626 | foreach (KeyValuePair<string, ITerrainEffect> kvp in m_plugineffects) | 626 | foreach (KeyValuePair<string, ITerrainEffect> kvp in m_plugineffects) |
627 | { | 627 | { |
628 | m_log.Info(kvp.Key); | 628 | m_log.Info(kvp.Key); |
629 | } | 629 | } |
630 | return; | 630 | return; |
631 | } | 631 | } |
632 | if ((string) args[0] == "reload") | 632 | if ((string) args[0] == "reload") |
633 | { | 633 | { |
634 | LoadPlugins(); | 634 | LoadPlugins(); |
635 | return; | 635 | return; |
636 | } | 636 | } |
637 | if (m_plugineffects.ContainsKey((string) args[0])) | 637 | if (m_plugineffects.ContainsKey((string) args[0])) |
638 | { | 638 | { |
639 | m_plugineffects[(string) args[0]].RunEffect(m_channel); | 639 | m_plugineffects[(string) args[0]].RunEffect(m_channel); |
640 | CheckForTerrainUpdates(); | 640 | CheckForTerrainUpdates(); |
641 | } | 641 | } |
642 | else | 642 | else |
643 | { | 643 | { |
644 | m_log.Warn("No such plugin effect loaded."); | 644 | m_log.Warn("No such plugin effect loaded."); |
645 | } | 645 | } |
646 | } | 646 | } |
647 | 647 | ||
648 | private void InstallInterfaces() | 648 | private void InstallInterfaces() |
649 | { | 649 | { |
650 | // Load / Save | 650 | // Load / Save |
651 | string supportedFileExtensions = ""; | 651 | string supportedFileExtensions = ""; |
652 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 652 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
653 | supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")"; | 653 | supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")"; |
654 | 654 | ||
655 | Command loadFromFileCommand = | 655 | Command loadFromFileCommand = |
656 | new Command("load", InterfaceLoadFile, "Loads a terrain from a specified file."); | 656 | new Command("load", InterfaceLoadFile, "Loads a terrain from a specified file."); |
657 | loadFromFileCommand.AddArgument("filename", | 657 | loadFromFileCommand.AddArgument("filename", |
658 | "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + | 658 | "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + |
659 | supportedFileExtensions, "String"); | 659 | supportedFileExtensions, "String"); |
660 | 660 | ||
661 | Command saveToFileCommand = | 661 | Command saveToFileCommand = |
662 | new Command("save", InterfaceSaveFile, "Saves the current heightmap to a specified file."); | 662 | new Command("save", InterfaceSaveFile, "Saves the current heightmap to a specified file."); |
663 | saveToFileCommand.AddArgument("filename", | 663 | saveToFileCommand.AddArgument("filename", |
664 | "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " + | 664 | "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " + |
665 | supportedFileExtensions, "String"); | 665 | supportedFileExtensions, "String"); |
666 | 666 | ||
667 | Command loadFromTileCommand = | 667 | Command loadFromTileCommand = |
668 | new Command("load-tile", InterfaceLoadTileFile, "Loads a terrain from a section of a larger file."); | 668 | new Command("load-tile", InterfaceLoadTileFile, "Loads a terrain from a section of a larger file."); |
669 | loadFromTileCommand.AddArgument("filename", | 669 | loadFromTileCommand.AddArgument("filename", |
670 | "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + | 670 | "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " + |
671 | supportedFileExtensions, "String"); | 671 | supportedFileExtensions, "String"); |
672 | loadFromTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer"); | 672 | loadFromTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer"); |
673 | loadFromTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer"); | 673 | loadFromTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer"); |
674 | loadFromTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", | 674 | loadFromTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", |
675 | "Integer"); | 675 | "Integer"); |
676 | loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", | 676 | loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", |
677 | "Integer"); | 677 | "Integer"); |
678 | 678 | ||
679 | // Terrain adjustments | 679 | // Terrain adjustments |
680 | Command fillRegionCommand = | 680 | Command fillRegionCommand = |
681 | new Command("fill", InterfaceFillTerrain, "Fills the current heightmap with a specified value."); | 681 | new Command("fill", InterfaceFillTerrain, "Fills the current heightmap with a specified value."); |
682 | fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.", | 682 | fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.", |
683 | "Double"); | 683 | "Double"); |
684 | 684 | ||
685 | Command elevateCommand = | 685 | Command elevateCommand = |
686 | new Command("elevate", InterfaceElevateTerrain, "Raises the current heightmap by the specified amount."); | 686 | new Command("elevate", InterfaceElevateTerrain, "Raises the current heightmap by the specified amount."); |
687 | elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double"); | 687 | elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double"); |
688 | 688 | ||
689 | Command lowerCommand = | 689 | Command lowerCommand = |
690 | new Command("lower", InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount."); | 690 | new Command("lower", InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount."); |
691 | lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double"); | 691 | lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double"); |
692 | 692 | ||
693 | Command multiplyCommand = | 693 | Command multiplyCommand = |
694 | new Command("multiply", InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified."); | 694 | new Command("multiply", InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified."); |
695 | multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double"); | 695 | multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double"); |
696 | 696 | ||
697 | Command bakeRegionCommand = | 697 | Command bakeRegionCommand = |
698 | new Command("bake", InterfaceBakeTerrain, "Saves the current terrain into the regions revert map."); | 698 | new Command("bake", InterfaceBakeTerrain, "Saves the current terrain into the regions revert map."); |
699 | Command revertRegionCommand = | 699 | Command revertRegionCommand = |
700 | new Command("revert", InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap."); | 700 | new Command("revert", InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap."); |
701 | 701 | ||
702 | // Debug | 702 | // Debug |
703 | Command showDebugStatsCommand = | 703 | Command showDebugStatsCommand = |
704 | new Command("stats", InterfaceShowDebugStats, | 704 | new Command("stats", InterfaceShowDebugStats, |
705 | "Shows some information about the regions heightmap for debugging purposes."); | 705 | "Shows some information about the regions heightmap for debugging purposes."); |
706 | 706 | ||
707 | Command experimentalBrushesCommand = | 707 | Command experimentalBrushesCommand = |
708 | new Command("newbrushes", InterfaceEnableExperimentalBrushes, | 708 | new Command("newbrushes", InterfaceEnableExperimentalBrushes, |
709 | "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time."); | 709 | "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time."); |
710 | experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean"); | 710 | experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean"); |
711 | 711 | ||
712 | //Plugins | 712 | //Plugins |
713 | Command pluginRunCommand = | 713 | Command pluginRunCommand = |
714 | new Command("effect", InterfaceRunPluginEffect, "Runs a specified plugin effect"); | 714 | new Command("effect", InterfaceRunPluginEffect, "Runs a specified plugin effect"); |
715 | pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String"); | 715 | pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String"); |
716 | 716 | ||
717 | m_commander.RegisterCommand("load", loadFromFileCommand); | 717 | m_commander.RegisterCommand("load", loadFromFileCommand); |
718 | m_commander.RegisterCommand("load-tile", loadFromTileCommand); | 718 | m_commander.RegisterCommand("load-tile", loadFromTileCommand); |
719 | m_commander.RegisterCommand("save", saveToFileCommand); | 719 | m_commander.RegisterCommand("save", saveToFileCommand); |
720 | m_commander.RegisterCommand("fill", fillRegionCommand); | 720 | m_commander.RegisterCommand("fill", fillRegionCommand); |
721 | m_commander.RegisterCommand("elevate", elevateCommand); | 721 | m_commander.RegisterCommand("elevate", elevateCommand); |
722 | m_commander.RegisterCommand("lower", lowerCommand); | 722 | m_commander.RegisterCommand("lower", lowerCommand); |
723 | m_commander.RegisterCommand("multiply", multiplyCommand); | 723 | m_commander.RegisterCommand("multiply", multiplyCommand); |
724 | m_commander.RegisterCommand("bake", bakeRegionCommand); | 724 | m_commander.RegisterCommand("bake", bakeRegionCommand); |
725 | m_commander.RegisterCommand("revert", revertRegionCommand); | 725 | m_commander.RegisterCommand("revert", revertRegionCommand); |
726 | m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand); | 726 | m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand); |
727 | m_commander.RegisterCommand("stats", showDebugStatsCommand); | 727 | m_commander.RegisterCommand("stats", showDebugStatsCommand); |
728 | m_commander.RegisterCommand("effect", pluginRunCommand); | 728 | m_commander.RegisterCommand("effect", pluginRunCommand); |
729 | 729 | ||
730 | // Add this to our scene so scripts can call these functions | 730 | // Add this to our scene so scripts can call these functions |
731 | m_scene.RegisterModuleCommander("Terrain", m_commander); | 731 | m_scene.RegisterModuleCommander("Terrain", m_commander); |
732 | } | 732 | } |
733 | 733 | ||
734 | #endregion | 734 | #endregion |
735 | } | 735 | } |
736 | } \ No newline at end of file | 736 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs index b593717..daef6bd 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs | |||
@@ -1,133 +1,133 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.World.Terrain | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain |
32 | { | 32 | { |
33 | public static class TerrainUtil | 33 | public static class TerrainUtil |
34 | { | 34 | { |
35 | public static double MetersToSphericalStrength(double size) | 35 | public static double MetersToSphericalStrength(double size) |
36 | { | 36 | { |
37 | return Math.Pow(2, size); | 37 | return Math.Pow(2, size); |
38 | } | 38 | } |
39 | 39 | ||
40 | public static double SphericalFactor(double x, double y, double rx, double ry, double size) | 40 | public static double SphericalFactor(double x, double y, double rx, double ry, double size) |
41 | { | 41 | { |
42 | return size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 42 | return size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
43 | } | 43 | } |
44 | 44 | ||
45 | public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | 45 | public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) |
46 | { | 46 | { |
47 | int w = map.Width; | 47 | int w = map.Width; |
48 | int h = map.Height; | 48 | int h = map.Height; |
49 | 49 | ||
50 | if (x > w - 2.0) | 50 | if (x > w - 2.0) |
51 | x = w - 2.0; | 51 | x = w - 2.0; |
52 | if (y > h - 2.0) | 52 | if (y > h - 2.0) |
53 | y = h - 2.0; | 53 | y = h - 2.0; |
54 | if (x < 0.0) | 54 | if (x < 0.0) |
55 | x = 0.0; | 55 | x = 0.0; |
56 | if (y < 0.0) | 56 | if (y < 0.0) |
57 | y = 0.0; | 57 | y = 0.0; |
58 | 58 | ||
59 | int stepSize = 1; | 59 | int stepSize = 1; |
60 | double h00 = map[(int) x, (int) y]; | 60 | double h00 = map[(int) x, (int) y]; |
61 | double h10 = map[(int) x + stepSize, (int) y]; | 61 | double h10 = map[(int) x + stepSize, (int) y]; |
62 | double h01 = map[(int) x, (int) y + stepSize]; | 62 | double h01 = map[(int) x, (int) y + stepSize]; |
63 | double h11 = map[(int) x + stepSize, (int) y + stepSize]; | 63 | double h11 = map[(int) x + stepSize, (int) y + stepSize]; |
64 | double h1 = h00; | 64 | double h1 = h00; |
65 | double h2 = h10; | 65 | double h2 = h10; |
66 | double h3 = h01; | 66 | double h3 = h01; |
67 | double h4 = h11; | 67 | double h4 = h11; |
68 | double a00 = h1; | 68 | double a00 = h1; |
69 | double a10 = h2 - h1; | 69 | double a10 = h2 - h1; |
70 | double a01 = h3 - h1; | 70 | double a01 = h3 - h1; |
71 | double a11 = h1 - h2 - h3 + h4; | 71 | double a11 = h1 - h2 - h3 + h4; |
72 | double partialx = x - (int) x; | 72 | double partialx = x - (int) x; |
73 | double partialz = y - (int) y; | 73 | double partialz = y - (int) y; |
74 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | 74 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); |
75 | return hi; | 75 | return hi; |
76 | } | 76 | } |
77 | 77 | ||
78 | private static double Noise(double x, double y) | 78 | private static double Noise(double x, double y) |
79 | { | 79 | { |
80 | int n = (int) x + (int) (y * 749); | 80 | int n = (int) x + (int) (y * 749); |
81 | n = (n << 13) ^ n; | 81 | n = (n << 13) ^ n; |
82 | return (1.0 - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); | 82 | return (1.0 - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); |
83 | } | 83 | } |
84 | 84 | ||
85 | private static double SmoothedNoise1(double x, double y) | 85 | private static double SmoothedNoise1(double x, double y) |
86 | { | 86 | { |
87 | double corners = (Noise(x - 1, y - 1) + Noise(x + 1, y - 1) + Noise(x - 1, y + 1) + Noise(x + 1, y + 1)) / 16; | 87 | double corners = (Noise(x - 1, y - 1) + Noise(x + 1, y - 1) + Noise(x - 1, y + 1) + Noise(x + 1, y + 1)) / 16; |
88 | double sides = (Noise(x - 1, y) + Noise(x + 1, y) + Noise(x, y - 1) + Noise(x, y + 1)) / 8; | 88 | double sides = (Noise(x - 1, y) + Noise(x + 1, y) + Noise(x, y - 1) + Noise(x, y + 1)) / 8; |
89 | double center = Noise(x, y) / 4; | 89 | double center = Noise(x, y) / 4; |
90 | return corners + sides + center; | 90 | return corners + sides + center; |
91 | } | 91 | } |
92 | 92 | ||
93 | private static double Interpolate(double x, double y, double z) | 93 | private static double Interpolate(double x, double y, double z) |
94 | { | 94 | { |
95 | return (x * (1.0 - z)) + (y * z); | 95 | return (x * (1.0 - z)) + (y * z); |
96 | } | 96 | } |
97 | 97 | ||
98 | private static double InterpolatedNoise(double x, double y) | 98 | private static double InterpolatedNoise(double x, double y) |
99 | { | 99 | { |
100 | int integer_X = (int) (x); | 100 | int integer_X = (int) (x); |
101 | double fractional_X = x - integer_X; | 101 | double fractional_X = x - integer_X; |
102 | 102 | ||
103 | int integer_Y = (int) y; | 103 | int integer_Y = (int) y; |
104 | double fractional_Y = y - integer_Y; | 104 | double fractional_Y = y - integer_Y; |
105 | 105 | ||
106 | double v1 = SmoothedNoise1(integer_X, integer_Y); | 106 | double v1 = SmoothedNoise1(integer_X, integer_Y); |
107 | double v2 = SmoothedNoise1(integer_X + 1, integer_Y); | 107 | double v2 = SmoothedNoise1(integer_X + 1, integer_Y); |
108 | double v3 = SmoothedNoise1(integer_X, integer_Y + 1); | 108 | double v3 = SmoothedNoise1(integer_X, integer_Y + 1); |
109 | double v4 = SmoothedNoise1(integer_X + 1, integer_Y + 1); | 109 | double v4 = SmoothedNoise1(integer_X + 1, integer_Y + 1); |
110 | 110 | ||
111 | double i1 = Interpolate(v1, v2, fractional_X); | 111 | double i1 = Interpolate(v1, v2, fractional_X); |
112 | double i2 = Interpolate(v3, v4, fractional_X); | 112 | double i2 = Interpolate(v3, v4, fractional_X); |
113 | 113 | ||
114 | return Interpolate(i1, i2, fractional_Y); | 114 | return Interpolate(i1, i2, fractional_Y); |
115 | } | 115 | } |
116 | 116 | ||
117 | public static double PerlinNoise2D(double x, double y, int octaves, double persistence) | 117 | public static double PerlinNoise2D(double x, double y, int octaves, double persistence) |
118 | { | 118 | { |
119 | double frequency = 0.0; | 119 | double frequency = 0.0; |
120 | double amplitude = 0.0; | 120 | double amplitude = 0.0; |
121 | double total = 0.0; | 121 | double total = 0.0; |
122 | 122 | ||
123 | for (int i = 0; i < octaves; i++) | 123 | for (int i = 0; i < octaves; i++) |
124 | { | 124 | { |
125 | frequency = Math.Pow(2, i); | 125 | frequency = Math.Pow(2, i); |
126 | amplitude = Math.Pow(persistence, i); | 126 | amplitude = Math.Pow(persistence, i); |
127 | 127 | ||
128 | total += InterpolatedNoise(x * frequency, y * frequency) * amplitude; | 128 | total += InterpolatedNoise(x * frequency, y * frequency) * amplitude; |
129 | } | 129 | } |
130 | return total; | 130 | return total; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | } \ No newline at end of file | 133 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs index ccb0561..842e2ee 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs | |||
@@ -1,59 +1,59 @@ | |||
1 | using System; | 1 | using System; |
2 | using NUnit.Framework; | 2 | using NUnit.Framework; |
3 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; | 3 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; |
4 | 4 | ||
5 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests | 5 | namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests |
6 | { | 6 | { |
7 | [TestFixture] | 7 | [TestFixture] |
8 | public class TerrainTest | 8 | public class TerrainTest |
9 | { | 9 | { |
10 | [Test] | 10 | [Test] |
11 | public void BrushTest() | 11 | public void BrushTest() |
12 | { | 12 | { |
13 | TerrainChannel x = new TerrainChannel(256, 256); | 13 | TerrainChannel x = new TerrainChannel(256, 256); |
14 | ITerrainPaintableEffect effect = new RaiseSphere(); | 14 | ITerrainPaintableEffect effect = new RaiseSphere(); |
15 | 15 | ||
16 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); | 16 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); |
17 | Assert.That(x[128, 128] > 0.0, "Raise brush not raising values."); | 17 | Assert.That(x[128, 128] > 0.0, "Raise brush not raising values."); |
18 | Assert.That(x[0, 128] > 0.0, "Raise brush lowering edge values."); | 18 | Assert.That(x[0, 128] > 0.0, "Raise brush lowering edge values."); |
19 | 19 | ||
20 | x = new TerrainChannel(256, 256); | 20 | x = new TerrainChannel(256, 256); |
21 | effect = new LowerSphere(); | 21 | effect = new LowerSphere(); |
22 | 22 | ||
23 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); | 23 | effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); |
24 | Assert.That(x[128, 128] < 0.0, "Lower not lowering values."); | 24 | Assert.That(x[128, 128] < 0.0, "Lower not lowering values."); |
25 | Assert.That(x[0, 128] < 0.0, "Lower brush affecting edge values."); | 25 | Assert.That(x[0, 128] < 0.0, "Lower brush affecting edge values."); |
26 | } | 26 | } |
27 | 27 | ||
28 | [Test] | 28 | [Test] |
29 | public void TerrainChannelTest() | 29 | public void TerrainChannelTest() |
30 | { | 30 | { |
31 | TerrainChannel x = new TerrainChannel(256, 256); | 31 | TerrainChannel x = new TerrainChannel(256, 256); |
32 | Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly."); | 32 | Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly."); |
33 | 33 | ||
34 | x[0, 0] = 1.0; | 34 | x[0, 0] = 1.0; |
35 | Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly."); | 35 | Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly."); |
36 | 36 | ||
37 | x[0, 0] = 0; | 37 | x[0, 0] = 0; |
38 | x[0, 0] += 5.0; | 38 | x[0, 0] += 5.0; |
39 | x[0, 0] -= 1.0; | 39 | x[0, 0] -= 1.0; |
40 | Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error."); | 40 | Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error."); |
41 | 41 | ||
42 | x[0, 0] = Math.PI; | 42 | x[0, 0] = Math.PI; |
43 | double[,] doublesExport = x.GetDoubles(); | 43 | double[,] doublesExport = x.GetDoubles(); |
44 | Assert.That(doublesExport[0, 0] == Math.PI, "Export to double[,] array not working correctly."); | 44 | Assert.That(doublesExport[0, 0] == Math.PI, "Export to double[,] array not working correctly."); |
45 | 45 | ||
46 | x[0, 0] = 1.0; | 46 | x[0, 0] = 1.0; |
47 | float[] floatsExport = x.GetFloatsSerialised(); | 47 | float[] floatsExport = x.GetFloatsSerialised(); |
48 | Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly."); | 48 | Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly."); |
49 | 49 | ||
50 | x[0, 0] = 1.0; | 50 | x[0, 0] = 1.0; |
51 | Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly."); | 51 | Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly."); |
52 | Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly."); | 52 | Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly."); |
53 | 53 | ||
54 | TerrainChannel y = x.Copy(); | 54 | TerrainChannel y = x.Copy(); |
55 | Assert.That(!ReferenceEquals(x, y), "Terrain copy not duplicating correctly."); | 55 | Assert.That(!ReferenceEquals(x, y), "Terrain copy not duplicating correctly."); |
56 | Assert.That(!ReferenceEquals(x.GetDoubles(), y.GetDoubles()), "Terrain array not duplicating correctly."); | 56 | Assert.That(!ReferenceEquals(x.GetDoubles(), y.GetDoubles()), "Terrain array not duplicating correctly."); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | } \ No newline at end of file | 59 | } \ No newline at end of file |