diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs | 238 |
1 files changed, 119 insertions, 119 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs index 59937d1..64e8668 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs | |||
@@ -1,119 +1,119 @@ | |||
1 | | 1 | |
2 | using OpenSim.Framework; | 2 | using OpenSim.Framework; |
3 | using OpenSim.Region.Environment.Interfaces; | 3 | using OpenSim.Region.Environment.Interfaces; |
4 | 4 | ||
5 | namespace OpenSim.Region.Environment.Modules.Terrain | 5 | namespace OpenSim.Region.Environment.Modules.Terrain |
6 | { | 6 | { |
7 | 7 | ||
8 | /// <summary> | 8 | /// <summary> |
9 | /// A new version of the old Channel class, simplified | 9 | /// A new version of the old Channel class, simplified |
10 | /// </summary> | 10 | /// </summary> |
11 | public class TerrainChannel : ITerrainChannel | 11 | public class TerrainChannel : ITerrainChannel |
12 | { | 12 | { |
13 | private double[,] map; | 13 | private double[,] map; |
14 | private bool[,] taint; | 14 | private bool[,] taint; |
15 | 15 | ||
16 | public int Width | 16 | public int Width |
17 | { | 17 | { |
18 | get { return map.GetLength(0); } | 18 | get { return map.GetLength(0); } |
19 | } | 19 | } |
20 | 20 | ||
21 | public int Height | 21 | public int Height |
22 | { | 22 | { |
23 | get { return map.GetLength(1); } | 23 | get { return map.GetLength(1); } |
24 | } | 24 | } |
25 | 25 | ||
26 | public TerrainChannel Copy() | 26 | public TerrainChannel Copy() |
27 | { | 27 | { |
28 | TerrainChannel copy = new TerrainChannel(false); | 28 | TerrainChannel copy = new TerrainChannel(false); |
29 | copy.map = (double[,])this.map.Clone(); | 29 | copy.map = (double[,])this.map.Clone(); |
30 | 30 | ||
31 | return copy; | 31 | return copy; |
32 | } | 32 | } |
33 | 33 | ||
34 | public float[] GetFloatsSerialised() | 34 | public float[] GetFloatsSerialised() |
35 | { | 35 | { |
36 | float[] heights = new float[Width * Height]; | 36 | float[] heights = new float[Width * Height]; |
37 | int i; | 37 | int i; |
38 | 38 | ||
39 | for (i = 0; i < Width * Height; i++) | 39 | for (i = 0; i < Width * Height; i++) |
40 | { | 40 | { |
41 | heights[i] = (float)map[i % Width, i / Width]; | 41 | heights[i] = (float)map[i % Width, i / Width]; |
42 | } | 42 | } |
43 | 43 | ||
44 | return heights; | 44 | return heights; |
45 | } | 45 | } |
46 | 46 | ||
47 | public double[,] GetDoubles() | 47 | public double[,] GetDoubles() |
48 | { | 48 | { |
49 | return map; | 49 | return map; |
50 | } | 50 | } |
51 | 51 | ||
52 | public double this[int x, int y] | 52 | public double this[int x, int y] |
53 | { | 53 | { |
54 | get | 54 | get |
55 | { | 55 | { |
56 | return map[x, y]; | 56 | return map[x, y]; |
57 | } | 57 | } |
58 | set | 58 | set |
59 | { | 59 | { |
60 | if (map[x, y] != value) | 60 | if (map[x, y] != value) |
61 | { | 61 | { |
62 | taint[x / 16, y / 16] = true; | 62 | taint[x / 16, y / 16] = true; |
63 | map[x, y] = value; | 63 | map[x, y] = value; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | public bool Tainted(int x, int y) | 68 | public bool Tainted(int x, int y) |
69 | { | 69 | { |
70 | if (taint[x / 16, y / 16] != false) | 70 | if (taint[x / 16, y / 16] != false) |
71 | { | 71 | { |
72 | taint[x / 16, y / 16] = false; | 72 | taint[x / 16, y / 16] = false; |
73 | return true; | 73 | return true; |
74 | } | 74 | } |
75 | else | 75 | else |
76 | { | 76 | { |
77 | return false; | 77 | return false; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | public TerrainChannel() | 81 | public TerrainChannel() |
82 | { | 82 | { |
83 | map = new double[Constants.RegionSize, Constants.RegionSize]; | 83 | map = new double[Constants.RegionSize, Constants.RegionSize]; |
84 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; | 84 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; |
85 | 85 | ||
86 | int x, y; | 86 | int x, y; |
87 | for (x = 0; x < Constants.RegionSize; x++) | 87 | for (x = 0; x < Constants.RegionSize; x++) |
88 | { | 88 | { |
89 | for (y = 0; y < Constants.RegionSize; y++) | 89 | for (y = 0; y < Constants.RegionSize; y++) |
90 | { | 90 | { |
91 | map[x, y] = 60.0 - // 60 = Sphere Radius | 91 | map[x, y] = 60.0 - // 60 = Sphere Radius |
92 | ((x - (Constants.RegionSize / 2)) * (x - (Constants.RegionSize / 2)) + | 92 | ((x - (Constants.RegionSize / 2)) * (x - (Constants.RegionSize / 2)) + |
93 | (y - (Constants.RegionSize / 2)) * (y - (Constants.RegionSize / 2))); | 93 | (y - (Constants.RegionSize / 2)) * (y - (Constants.RegionSize / 2))); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | public TerrainChannel(double[,] import) | 98 | public TerrainChannel(double[,] import) |
99 | { | 99 | { |
100 | map = import; | 100 | map = import; |
101 | taint = new bool[import.GetLength(0), import.GetLength(1)]; | 101 | taint = new bool[import.GetLength(0), import.GetLength(1)]; |
102 | } | 102 | } |
103 | 103 | ||
104 | public TerrainChannel(bool createMap) | 104 | public TerrainChannel(bool createMap) |
105 | { | 105 | { |
106 | if (createMap) | 106 | if (createMap) |
107 | { | 107 | { |
108 | map = new double[Constants.RegionSize, Constants.RegionSize]; | 108 | map = new double[Constants.RegionSize, Constants.RegionSize]; |
109 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; | 109 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | public TerrainChannel(int w, int h) | 113 | public TerrainChannel(int w, int h) |
114 | { | 114 | { |
115 | map = new double[w, h]; | 115 | map = new double[w, h]; |
116 | taint = new bool[w / 16, h / 16]; | 116 | taint = new bool[w / 16, h / 16]; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |