aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-03-14 13:37:39 +0000
committerAdam Frisby2008-03-14 13:37:39 +0000
commit53e8d91c06b3fc5cf61ba767930fa733a6efb232 (patch)
tree28db1d0e7e96c737da680bef72de527e2dacfb8f /OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
parent* Added proper handling of llSetStatus(STATUS_PHYSICS,BOOL) (diff)
downloadopensim-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/TerrainModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs149
1 files changed, 8 insertions, 141 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
index 83c6658..5931552 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
@@ -36,151 +36,18 @@ using OpenSim.Region.Environment.Scenes;
36 36
37namespace OpenSim.Region.Environment.Modules.Terrain 37namespace OpenSim.Region.Environment.Modules.Terrain
38{ 38{
39 public interface ITerrainPaintableEffect 39 public class TerrainModule : IRegionModule
40 {
41 void PaintEffect(ITerrainChannel map, double x, double y, double strength, double duration);
42 }
43
44 public interface ITerrainFloodEffect
45 {
46 void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength);
47 }
48
49 public interface ITerrainEffect
50 {
51 void RunEffect(ITerrainChannel map, double strength);
52 }
53
54 public interface ITerrainLoader
55 {
56 ITerrainChannel LoadFile(string filename);
57 void SaveFile(string filename, ITerrainChannel map);
58 }
59
60 /// <summary>
61 /// A new version of the old Channel class, simplified
62 /// </summary>
63 public class TerrainChannel : ITerrainChannel
64 { 40 {
65 private double[,] map; 41 public enum StandardTerrainEffects : byte
66 private bool[,] taint;
67
68 public int Width
69 {
70 get { return map.GetLength(0); }
71 }
72
73 public int Height
74 {
75 get { return map.GetLength(1); }
76 }
77
78 public TerrainChannel Copy()
79 {
80 TerrainChannel copy = new TerrainChannel(false);
81 copy.map = (double[,])this.map.Clone();
82
83 return copy;
84 }
85
86 public float[] GetFloatsSerialised()
87 {
88 float[] heights = new float[Width * Height];
89 int i;
90
91 for (i = 0; i < Width * Height; i++)
92 {
93 heights[i] = (float)map[i % Width, i / Width];
94 }
95
96 return heights;
97 }
98
99 public double[,] GetDoubles()
100 {
101 return map;
102 }
103
104 public double this[int x, int y]
105 {
106 get
107 {
108 return map[x, y];
109 }
110 set
111 {
112 if (map[x, y] != value)
113 {
114 taint[x / 16, y / 16] = true;
115 map[x, y] = value;
116 }
117 }
118 }
119
120 public bool Tainted(int x, int y)
121 { 42 {
122 if (taint[x / 16, y / 16] != false) 43 Flatten = 0,
123 { 44 Raise = 1,
124 taint[x / 16, y / 16] = false; 45 Lower = 2,
125 return true; 46 Smooth = 3,
126 } 47 Noise = 4,
127 else 48 Revert = 5
128 {
129 return false;
130 }
131 } 49 }
132 50
133 public TerrainChannel()
134 {
135 map = new double[Constants.RegionSize, Constants.RegionSize];
136 taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16];
137
138 int x, y;
139 for (x = 0; x < Constants.RegionSize; x++)
140 {
141 for (y = 0; y < Constants.RegionSize; y++)
142 {
143 map[x, y] = 60.0 - // 60 = Sphere Radius
144 ((x - (Constants.RegionSize / 2)) * (x - (Constants.RegionSize / 2)) +
145 (y - (Constants.RegionSize / 2)) * (y - (Constants.RegionSize / 2)));
146 }
147 }
148 }
149
150 public TerrainChannel(double[,] import)
151 {
152 map = import;
153 taint = new bool[import.GetLength(0), import.GetLength(1)];
154 }
155
156 public TerrainChannel(bool createMap)
157 {
158 if (createMap)
159 {
160 map = new double[Constants.RegionSize, Constants.RegionSize];
161 taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16];
162 }
163 }
164
165 public TerrainChannel(int w, int h)
166 {
167 map = new double[w, h];
168 taint = new bool[w / 16, h / 16];
169 }
170 }
171
172 public enum StandardTerrainEffects : byte
173 {
174 Flatten = 0,
175 Raise = 1,
176 Lower = 2,
177 Smooth = 3,
178 Noise = 4,
179 Revert = 5
180 }
181
182 public class TerrainModule : IRegionModule
183 {
184 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
185 52
186 private Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = 53 private Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =