diff options
author | Adam Frisby | 2008-03-14 13:37:39 +0000 |
---|---|---|
committer | Adam Frisby | 2008-03-14 13:37:39 +0000 |
commit | 53e8d91c06b3fc5cf61ba767930fa733a6efb232 (patch) | |
tree | 28db1d0e7e96c737da680bef72de527e2dacfb8f /OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs | |
parent | * Added proper handling of llSetStatus(STATUS_PHYSICS,BOOL) (diff) | |
download | opensim-SC-53e8d91c06b3fc5cf61ba767930fa733a6efb232.zip opensim-SC-53e8d91c06b3fc5cf61ba767930fa733a6efb232.tar.gz opensim-SC-53e8d91c06b3fc5cf61ba767930fa733a6efb232.tar.bz2 opensim-SC-53e8d91c06b3fc5cf61ba767930fa733a6efb232.tar.xz |
* Fixed 'flatten area' brush, so it now has a 'force' instead of instantly flattening the selected area.
* Noise, and Noise-Area brushes now use Perlin noise, more closely simulating the method LL uses officially.
* TerrainModule has been cleaned up slightly.
* TerrainUtil class has several new functions related to seeded noise generation.
* Extracted ITerrainEffect, ITerrainFloodEffect, ITerrainLoader, ITerrainPaintableEffect, TerrainChannel to seperate files.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs new file mode 100644 index 0000000..59937d1 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs | |||
@@ -0,0 +1,119 @@ | |||
1 | | ||
2 | using OpenSim.Framework; | ||
3 | using OpenSim.Region.Environment.Interfaces; | ||
4 | |||
5 | namespace OpenSim.Region.Environment.Modules.Terrain | ||
6 | { | ||
7 | |||
8 | /// <summary> | ||
9 | /// A new version of the old Channel class, simplified | ||
10 | /// </summary> | ||
11 | public class TerrainChannel : ITerrainChannel | ||
12 | { | ||
13 | private double[,] map; | ||
14 | private bool[,] taint; | ||
15 | |||
16 | public int Width | ||
17 | { | ||
18 | get { return map.GetLength(0); } | ||
19 | } | ||
20 | |||
21 | public int Height | ||
22 | { | ||
23 | get { return map.GetLength(1); } | ||
24 | } | ||
25 | |||
26 | public TerrainChannel Copy() | ||
27 | { | ||
28 | TerrainChannel copy = new TerrainChannel(false); | ||
29 | copy.map = (double[,])this.map.Clone(); | ||
30 | |||
31 | return copy; | ||
32 | } | ||
33 | |||
34 | public float[] GetFloatsSerialised() | ||
35 | { | ||
36 | float[] heights = new float[Width * Height]; | ||
37 | int i; | ||
38 | |||
39 | for (i = 0; i < Width * Height; i++) | ||
40 | { | ||
41 | heights[i] = (float)map[i % Width, i / Width]; | ||
42 | } | ||
43 | |||
44 | return heights; | ||
45 | } | ||
46 | |||
47 | public double[,] GetDoubles() | ||
48 | { | ||
49 | return map; | ||
50 | } | ||
51 | |||
52 | public double this[int x, int y] | ||
53 | { | ||
54 | get | ||
55 | { | ||
56 | return map[x, y]; | ||
57 | } | ||
58 | set | ||
59 | { | ||
60 | if (map[x, y] != value) | ||
61 | { | ||
62 | taint[x / 16, y / 16] = true; | ||
63 | map[x, y] = value; | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | |||
68 | public bool Tainted(int x, int y) | ||
69 | { | ||
70 | if (taint[x / 16, y / 16] != false) | ||
71 | { | ||
72 | taint[x / 16, y / 16] = false; | ||
73 | return true; | ||
74 | } | ||
75 | else | ||
76 | { | ||
77 | return false; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | public TerrainChannel() | ||
82 | { | ||
83 | map = new double[Constants.RegionSize, Constants.RegionSize]; | ||
84 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; | ||
85 | |||
86 | int x, y; | ||
87 | for (x = 0; x < Constants.RegionSize; x++) | ||
88 | { | ||
89 | for (y = 0; y < Constants.RegionSize; y++) | ||
90 | { | ||
91 | map[x, y] = 60.0 - // 60 = Sphere Radius | ||
92 | ((x - (Constants.RegionSize / 2)) * (x - (Constants.RegionSize / 2)) + | ||
93 | (y - (Constants.RegionSize / 2)) * (y - (Constants.RegionSize / 2))); | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public TerrainChannel(double[,] import) | ||
99 | { | ||
100 | map = import; | ||
101 | taint = new bool[import.GetLength(0), import.GetLength(1)]; | ||
102 | } | ||
103 | |||
104 | public TerrainChannel(bool createMap) | ||
105 | { | ||
106 | if (createMap) | ||
107 | { | ||
108 | map = new double[Constants.RegionSize, Constants.RegionSize]; | ||
109 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | public TerrainChannel(int w, int h) | ||
114 | { | ||
115 | map = new double[w, h]; | ||
116 | taint = new bool[w / 16, h / 16]; | ||
117 | } | ||
118 | } | ||
119 | } | ||