diff options
10 files changed, 890 insertions, 890 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs index 20e5277..79d6840 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs | |||
@@ -1,79 +1,79 @@ | |||
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.Drawing; | 30 | using System.Drawing; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | 32 | ||
33 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | 33 | namespace OpenSim.Region.Environment.Modules.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 ITerrainChannel LoadFile(string filename) | 39 | public ITerrainChannel LoadFile(string filename) |
40 | { | 40 | { |
41 | throw new NotImplementedException(); | 41 | throw new NotImplementedException(); |
42 | } | 42 | } |
43 | 43 | ||
44 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) | 44 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) |
45 | { | 45 | { |
46 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 46 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); |
47 | 47 | ||
48 | int pallete = gradientmapLd.Height; | 48 | int pallete = gradientmapLd.Height; |
49 | 49 | ||
50 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 50 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
51 | Color[] colours = new Color[pallete]; | 51 | Color[] colours = new Color[pallete]; |
52 | 52 | ||
53 | for (int i = 0; i < pallete; i++) | 53 | for (int i = 0; i < pallete; i++) |
54 | { | 54 | { |
55 | colours[i] = gradientmapLd.GetPixel(0, i); | 55 | colours[i] = gradientmapLd.GetPixel(0, i); |
56 | } | 56 | } |
57 | 57 | ||
58 | for (int y = 0; y < map.Height; y++) | 58 | for (int y = 0; y < map.Height; y++) |
59 | { | 59 | { |
60 | for (int x = 0; x < map.Width; x++) | 60 | for (int x = 0; x < map.Width; x++) |
61 | { | 61 | { |
62 | // 512 is the largest possible height before colours clamp | 62 | // 512 is the largest possible height before colours clamp |
63 | int colorindex = (int)(Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); | 63 | int colorindex = (int)(Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); |
64 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); | 64 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | return bmp; | 67 | return bmp; |
68 | } | 68 | } |
69 | 69 | ||
70 | public void SaveFile(string filename, ITerrainChannel map) | 70 | public void SaveFile(string filename, ITerrainChannel map) |
71 | { | 71 | { |
72 | Bitmap colours = CreateBitmapFromMap(map); | 72 | Bitmap colours = CreateBitmapFromMap(map); |
73 | 73 | ||
74 | colours.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg); | 74 | colours.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg); |
75 | } | 75 | } |
76 | 76 | ||
77 | #endregion | 77 | #endregion |
78 | } | 78 | } |
79 | } \ No newline at end of file | 79 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs index 58dc6c7..64f8751 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs | |||
@@ -1,132 +1,132 @@ | |||
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.Terrain.FileLoaders | 32 | namespace OpenSim.Region.Environment.Modules.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 void SaveFile(string filename, ITerrainChannel map) | 61 | public void SaveFile(string filename, ITerrainChannel map) |
62 | { | 62 | { |
63 | FileInfo file = new FileInfo(filename); | 63 | FileInfo file = new FileInfo(filename); |
64 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | 64 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); |
65 | BinaryWriter binStream = new BinaryWriter(s); | 65 | BinaryWriter binStream = new BinaryWriter(s); |
66 | 66 | ||
67 | // Generate a smegging big lookup table to speed the operation up (it needs it) | 67 | // Generate a smegging big lookup table to speed the operation up (it needs it) |
68 | double[] lookupHeightTable = new double[65536]; | 68 | double[] lookupHeightTable = new double[65536]; |
69 | int i, j, x, y; | 69 | int i, j, x, y; |
70 | for (i = 0; i < 256; i++) | 70 | for (i = 0; i < 256; i++) |
71 | { | 71 | { |
72 | for (j = 0; j < 256; j++) | 72 | for (j = 0; j < 256; j++) |
73 | { | 73 | { |
74 | lookupHeightTable[i + (j * 256)] = ((double)i * ((double)j / 127.0)); | 74 | lookupHeightTable[i + (j * 256)] = ((double)i * ((double)j / 127.0)); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | // Output the calculated raw | 78 | // Output the calculated raw |
79 | for (y = 0; y < map.Height; y++) | 79 | for (y = 0; y < map.Height; y++) |
80 | { | 80 | { |
81 | for (x = 0; x < map.Width; x++) | 81 | for (x = 0; x < map.Width; x++) |
82 | { | 82 | { |
83 | double t = map[x, y]; | 83 | double t = map[x, y]; |
84 | double min = double.MaxValue; | 84 | double min = double.MaxValue; |
85 | int index = 0; | 85 | int index = 0; |
86 | 86 | ||
87 | for (i = 0; i < 65536; i++) | 87 | for (i = 0; i < 65536; i++) |
88 | { | 88 | { |
89 | if (Math.Abs(t - lookupHeightTable[i]) < min) | 89 | if (Math.Abs(t - lookupHeightTable[i]) < min) |
90 | { | 90 | { |
91 | min = Math.Abs(t - lookupHeightTable[i]); | 91 | min = Math.Abs(t - lookupHeightTable[i]); |
92 | index = i; | 92 | index = i; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | byte red = (byte)(index & 0xFF); | 96 | byte red = (byte)(index & 0xFF); |
97 | byte green = (byte)((index >> 8) & 0xFF); | 97 | byte green = (byte)((index >> 8) & 0xFF); |
98 | byte blue = 20; | 98 | byte blue = 20; |
99 | byte alpha1 = 0; // Land Parcels | 99 | byte alpha1 = 0; // Land Parcels |
100 | byte alpha2 = 0; // For Sale Land | 100 | byte alpha2 = 0; // For Sale Land |
101 | byte alpha3 = 0; // Public Edit Object | 101 | byte alpha3 = 0; // Public Edit Object |
102 | byte alpha4 = 0; // Public Edit Land | 102 | byte alpha4 = 0; // Public Edit Land |
103 | byte alpha5 = 255; // Safe Land | 103 | byte alpha5 = 255; // Safe Land |
104 | byte alpha6 = 255; // Flying Allowed | 104 | byte alpha6 = 255; // Flying Allowed |
105 | byte alpha7 = 255; // Create Landmark | 105 | byte alpha7 = 255; // Create Landmark |
106 | byte alpha8 = 255; // Outside Scripts | 106 | byte alpha8 = 255; // Outside Scripts |
107 | byte alpha9 = red; | 107 | byte alpha9 = red; |
108 | byte alpha10 = green; | 108 | byte alpha10 = green; |
109 | 109 | ||
110 | binStream.Write(red); | 110 | binStream.Write(red); |
111 | binStream.Write(green); | 111 | binStream.Write(green); |
112 | binStream.Write(blue); | 112 | binStream.Write(blue); |
113 | binStream.Write(alpha1); | 113 | binStream.Write(alpha1); |
114 | binStream.Write(alpha2); | 114 | binStream.Write(alpha2); |
115 | binStream.Write(alpha3); | 115 | binStream.Write(alpha3); |
116 | binStream.Write(alpha4); | 116 | binStream.Write(alpha4); |
117 | binStream.Write(alpha5); | 117 | binStream.Write(alpha5); |
118 | binStream.Write(alpha6); | 118 | binStream.Write(alpha6); |
119 | binStream.Write(alpha7); | 119 | binStream.Write(alpha7); |
120 | binStream.Write(alpha8); | 120 | binStream.Write(alpha8); |
121 | binStream.Write(alpha9); | 121 | binStream.Write(alpha9); |
122 | binStream.Write(alpha10); | 122 | binStream.Write(alpha10); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | binStream.Close(); | 126 | binStream.Close(); |
127 | s.Close(); | 127 | s.Close(); |
128 | } | 128 | } |
129 | 129 | ||
130 | #endregion | 130 | #endregion |
131 | } | 131 | } |
132 | } | 132 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs index d022fbe..91a9081 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs | |||
@@ -1,73 +1,73 @@ | |||
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.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Environment.Modules.Terrain; | 31 | using OpenSim.Region.Environment.Modules.Terrain; |
32 | using OpenSim.Region.Environment.Interfaces; | 32 | using OpenSim.Region.Environment.Interfaces; |
33 | 33 | ||
34 | namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes | 34 | namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes |
35 | { | 35 | { |
36 | public class FlattenArea : ITerrainFloodEffect | 36 | public class FlattenArea : ITerrainFloodEffect |
37 | { | 37 | { |
38 | #region ITerrainFloodEffect Members | 38 | #region ITerrainFloodEffect Members |
39 | 39 | ||
40 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 40 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
41 | { | 41 | { |
42 | double sum = 0.0; | 42 | double sum = 0.0; |
43 | double steps = 0.0; | 43 | double steps = 0.0; |
44 | double avg = 0.0; | 44 | double avg = 0.0; |
45 | 45 | ||
46 | int x, y; | 46 | int x, y; |
47 | for (x = 0; x < map.Width; x++) | 47 | for (x = 0; x < map.Width; x++) |
48 | { | 48 | { |
49 | for (y = 0; y < map.Height; y++) | 49 | for (y = 0; y < map.Height; y++) |
50 | { | 50 | { |
51 | if (fillArea[x, y] == true) | 51 | if (fillArea[x, y] == true) |
52 | { | 52 | { |
53 | sum += map[x, y]; | 53 | sum += map[x, y]; |
54 | steps += 1.0; | 54 | steps += 1.0; |
55 | } | 55 | } |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | avg = sum / steps; | 59 | avg = sum / steps; |
60 | 60 | ||
61 | for (x = 0; x < map.Width; x++) | 61 | for (x = 0; x < map.Width; x++) |
62 | { | 62 | { |
63 | for (y = 0; y < map.Height; y++) | 63 | for (y = 0; y < map.Height; y++) |
64 | { | 64 | { |
65 | if (fillArea[x, y] == true) | 65 | if (fillArea[x, y] == true) |
66 | map[x, y] = avg; | 66 | map[x, y] = avg; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | #endregion | 71 | #endregion |
72 | } | 72 | } |
73 | } | 73 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs index 1706575..1045377 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.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.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.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, 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] == true) | 43 | if (fillArea[x, y] == true) |
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 | } | 53 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs index 690ca53..52fd3cc 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs | |||
@@ -1,57 +1,57 @@ | |||
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.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class NoiseArea : ITerrainFloodEffect | 32 | public class NoiseArea : 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] == true) | 43 | if (fillArea[x, y] == true) |
44 | { | 44 | { |
45 | lock (OpenSim.Framework.Util.RandomClass) | 45 | lock (OpenSim.Framework.Util.RandomClass) |
46 | { | 46 | { |
47 | double noise = OpenSim.Framework.Util.RandomClass.NextDouble(); | 47 | double noise = OpenSim.Framework.Util.RandomClass.NextDouble(); |
48 | map[x, y] += (noise - 0.5) * strength; | 48 | map[x, y] += (noise - 0.5) * strength; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | #endregion | 55 | #endregion |
56 | } | 56 | } |
57 | } | 57 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs index aa685e4..a178dc8 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs | |||
@@ -1,107 +1,107 @@ | |||
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.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class SmoothArea : ITerrainFloodEffect | 32 | public class SmoothArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | private double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | 34 | private double GetBilinearInterpolate(double x, double y, ITerrainChannel map) |
35 | { | 35 | { |
36 | int w = map.Width; | 36 | int w = map.Width; |
37 | int h = map.Height; | 37 | int h = map.Height; |
38 | 38 | ||
39 | if (x > w - 2.0) | 39 | if (x > w - 2.0) |
40 | x = w - 2.0; | 40 | x = w - 2.0; |
41 | if (y > h - 2.0) | 41 | if (y > h - 2.0) |
42 | y = h - 2.0; | 42 | y = h - 2.0; |
43 | if (x < 0.0) | 43 | if (x < 0.0) |
44 | x = 0.0; | 44 | x = 0.0; |
45 | if (y < 0.0) | 45 | if (y < 0.0) |
46 | y = 0.0; | 46 | y = 0.0; |
47 | 47 | ||
48 | int stepSize = 1; | 48 | int stepSize = 1; |
49 | double h00 = map[(int)x, (int)y]; | 49 | double h00 = map[(int)x, (int)y]; |
50 | double h10 = map[(int)x + stepSize, (int)y]; | 50 | double h10 = map[(int)x + stepSize, (int)y]; |
51 | double h01 = map[(int)x, (int)y + stepSize]; | 51 | double h01 = map[(int)x, (int)y + stepSize]; |
52 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; | 52 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; |
53 | double h1 = h00; | 53 | double h1 = h00; |
54 | double h2 = h10; | 54 | double h2 = h10; |
55 | double h3 = h01; | 55 | double h3 = h01; |
56 | double h4 = h11; | 56 | double h4 = h11; |
57 | double a00 = h1; | 57 | double a00 = h1; |
58 | double a10 = h2 - h1; | 58 | double a10 = h2 - h1; |
59 | double a01 = h3 - h1; | 59 | double a01 = h3 - h1; |
60 | double a11 = h1 - h2 - h3 + h4; | 60 | double a11 = h1 - h2 - h3 + h4; |
61 | double partialx = x - (int)x; | 61 | double partialx = x - (int)x; |
62 | double partialz = y - (int)y; | 62 | double partialz = y - (int)y; |
63 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | 63 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); |
64 | return hi; | 64 | return hi; |
65 | } | 65 | } |
66 | 66 | ||
67 | #region ITerrainFloodEffect Members | 67 | #region ITerrainFloodEffect Members |
68 | 68 | ||
69 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 69 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
70 | { | 70 | { |
71 | double area = strength; | 71 | double area = strength; |
72 | double step = strength / 4.0; | 72 | double step = strength / 4.0; |
73 | 73 | ||
74 | double[,] manipulate = new double[map.Width, map.Height]; | 74 | double[,] manipulate = new double[map.Width, map.Height]; |
75 | int x, y; | 75 | int x, y; |
76 | double n, l; | 76 | double n, l; |
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 | double average = 0.0; | 81 | double average = 0.0; |
82 | int avgsteps = 0; | 82 | int avgsteps = 0; |
83 | 83 | ||
84 | for (n = 0.0 - area; n < area; n += step) | 84 | for (n = 0.0 - area; n < area; n += step) |
85 | { | 85 | { |
86 | for (l = 0.0 - area; l < area; l += step) | 86 | for (l = 0.0 - area; l < area; l += step) |
87 | { | 87 | { |
88 | avgsteps++; | 88 | avgsteps++; |
89 | average += GetBilinearInterpolate(x + n, y + l, map); | 89 | average += GetBilinearInterpolate(x + n, y + l, map); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | manipulate[x, y] = average / avgsteps; | 93 | manipulate[x, y] = average / avgsteps; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | for (x = 0; x < map.Width; x++) | 96 | for (x = 0; x < map.Width; x++) |
97 | { | 97 | { |
98 | for (y = 0; y < map.Height; y++) | 98 | for (y = 0; y < map.Height; y++) |
99 | { | 99 | { |
100 | map[x, y] = manipulate[x, y]; | 100 | map[x, y] = manipulate[x, y]; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | #endregion | 105 | #endregion |
106 | } | 106 | } |
107 | } \ No newline at end of file | 107 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs index d2cf1bc..f02a8dd 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs | |||
@@ -1,125 +1,125 @@ | |||
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.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes |
31 | { | 31 | { |
32 | public class FlattenSphere : ITerrainPaintableEffect | 32 | public class FlattenSphere : ITerrainPaintableEffect |
33 | { | 33 | { |
34 | private double SphericalFactor(double x, double y, double rx, double ry, double size) | 34 | private double SphericalFactor(double x, double y, double rx, double ry, double size) |
35 | { | 35 | { |
36 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 36 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
37 | return z; | 37 | return z; |
38 | } | 38 | } |
39 | 39 | ||
40 | private double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | 40 | private double GetBilinearInterpolate(double x, double y, ITerrainChannel map) |
41 | { | 41 | { |
42 | int w = map.Width; | 42 | int w = map.Width; |
43 | int h = map.Height; | 43 | int h = map.Height; |
44 | 44 | ||
45 | if (x > w - 2.0) | 45 | if (x > w - 2.0) |
46 | x = w - 2.0; | 46 | x = w - 2.0; |
47 | if (y > h - 2.0) | 47 | if (y > h - 2.0) |
48 | y = h - 2.0; | 48 | y = h - 2.0; |
49 | if (x < 0.0) | 49 | if (x < 0.0) |
50 | x = 0.0; | 50 | x = 0.0; |
51 | if (y < 0.0) | 51 | if (y < 0.0) |
52 | y = 0.0; | 52 | y = 0.0; |
53 | 53 | ||
54 | int stepSize = 1; | 54 | int stepSize = 1; |
55 | double h00 = map[(int)x, (int)y]; | 55 | double h00 = map[(int)x, (int)y]; |
56 | double h10 = map[(int)x + stepSize, (int)y]; | 56 | double h10 = map[(int)x + stepSize, (int)y]; |
57 | double h01 = map[(int)x, (int)y + stepSize]; | 57 | double h01 = map[(int)x, (int)y + stepSize]; |
58 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; | 58 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; |
59 | double h1 = h00; | 59 | double h1 = h00; |
60 | double h2 = h10; | 60 | double h2 = h10; |
61 | double h3 = h01; | 61 | double h3 = h01; |
62 | double h4 = h11; | 62 | double h4 = h11; |
63 | double a00 = h1; | 63 | double a00 = h1; |
64 | double a10 = h2 - h1; | 64 | double a10 = h2 - h1; |
65 | double a01 = h3 - h1; | 65 | double a01 = h3 - h1; |
66 | double a11 = h1 - h2 - h3 + h4; | 66 | double a11 = h1 - h2 - h3 + h4; |
67 | double partialx = x - (int)x; | 67 | double partialx = x - (int)x; |
68 | double partialz = y - (int)y; | 68 | double partialz = y - (int)y; |
69 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | 69 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); |
70 | return hi; | 70 | return hi; |
71 | } | 71 | } |
72 | 72 | ||
73 | #region ITerrainPaintableEffect Members | 73 | #region ITerrainPaintableEffect Members |
74 | 74 | ||
75 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) | 75 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) |
76 | { | 76 | { |
77 | int x, y; | 77 | int x, y; |
78 | double[,] tweak = new double[map.Width, map.Height]; | 78 | double[,] tweak = new double[map.Width, map.Height]; |
79 | 79 | ||
80 | double n, l; | 80 | double n, l; |
81 | double area = strength; | 81 | double area = strength; |
82 | double step = strength / 4.0; | 82 | double step = strength / 4.0; |
83 | 83 | ||
84 | double sum = 0.0; | 84 | double sum = 0.0; |
85 | double step2 = 0.0; | 85 | double step2 = 0.0; |
86 | double avg = 0.0; | 86 | double avg = 0.0; |
87 | 87 | ||
88 | // compute delta map | 88 | // compute delta map |
89 | for (x = 0; x < map.Width; x++) | 89 | for (x = 0; x < map.Width; x++) |
90 | { | 90 | { |
91 | for (y = 0; y < map.Height; y++) | 91 | for (y = 0; y < map.Height; y++) |
92 | { | 92 | { |
93 | double z = SphericalFactor(x, y, rx, ry, strength); | 93 | double z = SphericalFactor(x, y, rx, ry, strength); |
94 | 94 | ||
95 | if (z > 0) // add in non-zero amount | 95 | if (z > 0) // add in non-zero amount |
96 | { | 96 | { |
97 | sum += map[x, y] * z; | 97 | sum += map[x, y] * z; |
98 | step2 += z; | 98 | step2 += z; |
99 | } | 99 | } |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | avg = sum / step2; | 103 | avg = sum / step2; |
104 | 104 | ||
105 | // blend in map | 105 | // blend in map |
106 | for (x = 0; x < map.Width; x++) | 106 | for (x = 0; x < map.Width; x++) |
107 | { | 107 | { |
108 | for (y = 0; y < map.Height; y++) | 108 | for (y = 0; y < map.Height; y++) |
109 | { | 109 | { |
110 | double z = SphericalFactor(x, y, rx, ry, strength); | 110 | double z = SphericalFactor(x, y, rx, ry, strength); |
111 | 111 | ||
112 | if (z > 0) // add in non-zero amount | 112 | if (z > 0) // add in non-zero amount |
113 | { | 113 | { |
114 | if (z > 1.0) | 114 | if (z > 1.0) |
115 | z = 1.0; | 115 | z = 1.0; |
116 | 116 | ||
117 | map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); | 117 | map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | #endregion | 123 | #endregion |
124 | } | 124 | } |
125 | } \ No newline at end of file | 125 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs index 4a05e76..2902b9a 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs | |||
@@ -1,65 +1,65 @@ | |||
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.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.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) | 37 | public void PaintEffect(ITerrainChannel map, double rx, double ry, 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 | // Skip everything unlikely to be affected | 42 | // Skip everything unlikely to be affected |
43 | if (Math.Abs(x - rx) > strength * 1.1) | 43 | if (Math.Abs(x - rx) > strength * 1.1) |
44 | continue; | 44 | continue; |
45 | 45 | ||
46 | for (y = 0; y < map.Height; y++) | 46 | for (y = 0; y < map.Height; y++) |
47 | { | 47 | { |
48 | // Skip everything unlikely to be affected | 48 | // Skip everything unlikely to be affected |
49 | if (Math.Abs(y - ry) > strength * 1.1) | 49 | if (Math.Abs(y - ry) > strength * 1.1) |
50 | continue; | 50 | continue; |
51 | 51 | ||
52 | // Calculate a sphere and add it to the heighmap | 52 | // Calculate a sphere and add it to the heighmap |
53 | double z = strength; | 53 | double z = strength; |
54 | z *= z; | 54 | z *= z; |
55 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 55 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
56 | 56 | ||
57 | if (z > 0.0) | 57 | if (z > 0.0) |
58 | map[x, y] -= z; | 58 | map[x, y] -= z; |
59 | } | 59 | } |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | #endregion | 63 | #endregion |
64 | } | 64 | } |
65 | } | 65 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs index 226bd3e..6f1d283 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs | |||
@@ -1,73 +1,73 @@ | |||
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.Terrain.PaintBrushes | 32 | namespace OpenSim.Region.Environment.Modules.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) | 38 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) |
39 | { | 39 | { |
40 | int x, y; | 40 | int x, y; |
41 | for (x = 0; x < map.Width; x++) | 41 | for (x = 0; x < map.Width; x++) |
42 | { | 42 | { |
43 | // Skip everything unlikely to be affected | 43 | // Skip everything unlikely to be affected |
44 | if (Math.Abs(x - rx) > strength * 1.1) | 44 | if (Math.Abs(x - rx) > strength * 1.1) |
45 | continue; | 45 | continue; |
46 | 46 | ||
47 | for (y = 0; y < map.Height; y++) | 47 | for (y = 0; y < map.Height; y++) |
48 | { | 48 | { |
49 | // Skip everything unlikely to be affected | 49 | // Skip everything unlikely to be affected |
50 | if (Math.Abs(y - ry) > strength * 1.1) | 50 | if (Math.Abs(y - ry) > strength * 1.1) |
51 | continue; | 51 | continue; |
52 | 52 | ||
53 | // Calculate a sphere and add it to the heighmap | 53 | // Calculate a sphere and add it to the heighmap |
54 | double z = strength; | 54 | double z = strength; |
55 | z *= z; | 55 | z *= z; |
56 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 56 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
57 | 57 | ||
58 | double noise; | 58 | double noise; |
59 | 59 | ||
60 | lock (Util.RandomClass) | 60 | lock (Util.RandomClass) |
61 | { | 61 | { |
62 | noise = Util.RandomClass.NextDouble(); | 62 | noise = Util.RandomClass.NextDouble(); |
63 | } | 63 | } |
64 | 64 | ||
65 | if (z > 0.0) | 65 | if (z > 0.0) |
66 | map[x, y] += (noise - 0.5) * z; | 66 | map[x, y] += (noise - 0.5) * z; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | #endregion | 71 | #endregion |
72 | } | 72 | } |
73 | } | 73 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs index 076b3cc..dfe3dfc 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs | |||
@@ -1,130 +1,130 @@ | |||
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.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes |
31 | { | 31 | { |
32 | public class SmoothSphere : ITerrainPaintableEffect | 32 | public class SmoothSphere : ITerrainPaintableEffect |
33 | { | 33 | { |
34 | private double SphericalFactor(double x, double y, double rx, double ry, double size) | 34 | private double SphericalFactor(double x, double y, double rx, double ry, double size) |
35 | { | 35 | { |
36 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 36 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
37 | return z; | 37 | return z; |
38 | } | 38 | } |
39 | 39 | ||
40 | private double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | 40 | private double GetBilinearInterpolate(double x, double y, ITerrainChannel map) |
41 | { | 41 | { |
42 | int w = map.Width; | 42 | int w = map.Width; |
43 | int h = map.Height; | 43 | int h = map.Height; |
44 | 44 | ||
45 | if (x > w - 2.0) | 45 | if (x > w - 2.0) |
46 | x = w - 2.0; | 46 | x = w - 2.0; |
47 | if (y > h - 2.0) | 47 | if (y > h - 2.0) |
48 | y = h - 2.0; | 48 | y = h - 2.0; |
49 | if (x < 0.0) | 49 | if (x < 0.0) |
50 | x = 0.0; | 50 | x = 0.0; |
51 | if (y < 0.0) | 51 | if (y < 0.0) |
52 | y = 0.0; | 52 | y = 0.0; |
53 | 53 | ||
54 | int stepSize = 1; | 54 | int stepSize = 1; |
55 | double h00 = map[(int)x, (int)y]; | 55 | double h00 = map[(int)x, (int)y]; |
56 | double h10 = map[(int)x + stepSize, (int)y]; | 56 | double h10 = map[(int)x + stepSize, (int)y]; |
57 | double h01 = map[(int)x, (int)y + stepSize]; | 57 | double h01 = map[(int)x, (int)y + stepSize]; |
58 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; | 58 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; |
59 | double h1 = h00; | 59 | double h1 = h00; |
60 | double h2 = h10; | 60 | double h2 = h10; |
61 | double h3 = h01; | 61 | double h3 = h01; |
62 | double h4 = h11; | 62 | double h4 = h11; |
63 | double a00 = h1; | 63 | double a00 = h1; |
64 | double a10 = h2 - h1; | 64 | double a10 = h2 - h1; |
65 | double a01 = h3 - h1; | 65 | double a01 = h3 - h1; |
66 | double a11 = h1 - h2 - h3 + h4; | 66 | double a11 = h1 - h2 - h3 + h4; |
67 | double partialx = x - (int)x; | 67 | double partialx = x - (int)x; |
68 | double partialz = y - (int)y; | 68 | double partialz = y - (int)y; |
69 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | 69 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); |
70 | return hi; | 70 | return hi; |
71 | } | 71 | } |
72 | 72 | ||
73 | #region ITerrainPaintableEffect Members | 73 | #region ITerrainPaintableEffect Members |
74 | 74 | ||
75 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) | 75 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) |
76 | { | 76 | { |
77 | int x, y; | 77 | int x, y; |
78 | double[,] tweak = new double[map.Width, map.Height]; | 78 | double[,] tweak = new double[map.Width, map.Height]; |
79 | 79 | ||
80 | double n, l; | 80 | double n, l; |
81 | double area = strength; | 81 | double area = strength; |
82 | double step = strength / 4.0; | 82 | double step = strength / 4.0; |
83 | 83 | ||
84 | // compute delta map | 84 | // compute delta map |
85 | for (x = 0; x < map.Width; x++) | 85 | for (x = 0; x < map.Width; x++) |
86 | { | 86 | { |
87 | for (y = 0; y < map.Height; y++) | 87 | for (y = 0; y < map.Height; y++) |
88 | { | 88 | { |
89 | double z = SphericalFactor(x, y, rx, ry, strength); | 89 | double z = SphericalFactor(x, y, rx, ry, strength); |
90 | 90 | ||
91 | if (z > 0) // add in non-zero amount | 91 | if (z > 0) // add in non-zero amount |
92 | { | 92 | { |
93 | double average = 0.0; | 93 | double average = 0.0; |
94 | int avgsteps = 0; | 94 | int avgsteps = 0; |
95 | 95 | ||
96 | for (n = 0.0 - area; n < area; n += step) | 96 | for (n = 0.0 - area; n < area; n += step) |
97 | { | 97 | { |
98 | for (l = 0.0 - area; l < area; l += step) | 98 | for (l = 0.0 - area; l < area; l += step) |
99 | { | 99 | { |
100 | avgsteps++; | 100 | avgsteps++; |
101 | average += GetBilinearInterpolate(x + n, y + l, map); | 101 | average += GetBilinearInterpolate(x + n, y + l, map); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | tweak[x, y] = average / avgsteps; | 104 | tweak[x, y] = average / avgsteps; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | } | 107 | } |
108 | // blend in map | 108 | // blend in map |
109 | for (x = 0; x < map.Width; x++) | 109 | for (x = 0; x < map.Width; x++) |
110 | { | 110 | { |
111 | for (y = 0; y < map.Height; y++) | 111 | for (y = 0; y < map.Height; y++) |
112 | { | 112 | { |
113 | double z = SphericalFactor(x, y, rx, ry, strength); | 113 | double z = SphericalFactor(x, y, rx, ry, strength); |
114 | 114 | ||
115 | if (z > 0) // add in non-zero amount | 115 | if (z > 0) // add in non-zero amount |
116 | { | 116 | { |
117 | double da = z; | 117 | double da = z; |
118 | double a = (map[x, y] - tweak[x, y]) * da; | 118 | double a = (map[x, y] - tweak[x, y]) * da; |
119 | double newz = map[x, y] - a; | 119 | double newz = map[x, y] - a; |
120 | 120 | ||
121 | if (newz > 0.0) | 121 | if (newz > 0.0) |
122 | map[x, y] = newz; | 122 | map[x, y] = newz; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | #endregion | 128 | #endregion |
129 | } | 129 | } |
130 | } \ No newline at end of file | 130 | } \ No newline at end of file |