diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs deleted file mode 100644 index 1344715..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenSim.Framework; | ||
29 | using OpenSim.Region.Environment.Interfaces; | ||
30 | |||
31 | namespace OpenSim.Region.Environment.Modules.Terrain | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// A new version of the old Channel class, simplified | ||
35 | /// </summary> | ||
36 | public class TerrainChannel : ITerrainChannel | ||
37 | { | ||
38 | private readonly bool[,] taint; | ||
39 | private double[,] map; | ||
40 | |||
41 | public TerrainChannel() | ||
42 | { | ||
43 | map = new double[Constants.RegionSize,Constants.RegionSize]; | ||
44 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; | ||
45 | |||
46 | int x; | ||
47 | for (x = 0; x < Constants.RegionSize; x++) | ||
48 | { | ||
49 | int y; | ||
50 | for (y = 0; y < Constants.RegionSize; y++) | ||
51 | { | ||
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; | ||
54 | if (map[x, y] < spherFac) | ||
55 | { | ||
56 | map[x, y] = spherFac; | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | public TerrainChannel(double[,] import) | ||
63 | { | ||
64 | map = import; | ||
65 | taint = new bool[import.GetLength(0),import.GetLength(1)]; | ||
66 | } | ||
67 | |||
68 | public TerrainChannel(bool createMap) | ||
69 | { | ||
70 | if (createMap) | ||
71 | { | ||
72 | map = new double[Constants.RegionSize,Constants.RegionSize]; | ||
73 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; | ||
74 | } | ||
75 | } | ||
76 | |||
77 | public TerrainChannel(int w, int h) | ||
78 | { | ||
79 | map = new double[w,h]; | ||
80 | taint = new bool[w / 16,h / 16]; | ||
81 | } | ||
82 | |||
83 | #region ITerrainChannel Members | ||
84 | |||
85 | public int Width | ||
86 | { | ||
87 | get { return map.GetLength(0); } | ||
88 | } | ||
89 | |||
90 | public int Height | ||
91 | { | ||
92 | get { return map.GetLength(1); } | ||
93 | } | ||
94 | |||
95 | public ITerrainChannel MakeCopy() | ||
96 | { | ||
97 | TerrainChannel copy = new TerrainChannel(false); | ||
98 | copy.map = (double[,]) map.Clone(); | ||
99 | |||
100 | return copy; | ||
101 | } | ||
102 | |||
103 | public float[] GetFloatsSerialised() | ||
104 | { | ||
105 | float[] heights = new float[Width * Height]; | ||
106 | int i; | ||
107 | |||
108 | for (i = 0; i < Width * Height; i++) | ||
109 | { | ||
110 | heights[i] = (float) map[i % Width, i / Width]; | ||
111 | } | ||
112 | |||
113 | return heights; | ||
114 | } | ||
115 | |||
116 | public double[,] GetDoubles() | ||
117 | { | ||
118 | return map; | ||
119 | } | ||
120 | |||
121 | public double this[int x, int y] | ||
122 | { | ||
123 | get { return map[x, y]; } | ||
124 | set | ||
125 | { | ||
126 | if (map[x, y] != value) | ||
127 | { | ||
128 | taint[x / 16, y / 16] = true; | ||
129 | map[x, y] = value; | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | |||
134 | public bool Tainted(int x, int y) | ||
135 | { | ||
136 | if (taint[x / 16, y / 16]) | ||
137 | { | ||
138 | taint[x / 16, y / 16] = false; | ||
139 | return true; | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | return false; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | #endregion | ||
148 | |||
149 | public TerrainChannel Copy() | ||
150 | { | ||
151 | TerrainChannel copy = new TerrainChannel(false); | ||
152 | copy.map = (double[,]) map.Clone(); | ||
153 | |||
154 | return copy; | ||
155 | } | ||
156 | } | ||
157 | } \ No newline at end of file | ||