aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2008-03-08 19:11:22 +0000
committerAdam Frisby2008-03-08 19:11:22 +0000
commit8f6f85e530b84217d14aa9f9c198e7ad14f18c03 (patch)
tree960d625dc706df580c1e18cde2a62b56dc04b1fc /OpenSim
parentThank you kindly, Ldviopeng for: (diff)
downloadopensim-SC_OLD-8f6f85e530b84217d14aa9f9c198e7ad14f18c03.zip
opensim-SC_OLD-8f6f85e530b84217d14aa9f9c198e7ad14f18c03.tar.gz
opensim-SC_OLD-8f6f85e530b84217d14aa9f9c198e7ad14f18c03.tar.bz2
opensim-SC_OLD-8f6f85e530b84217d14aa9f9c198e7ad14f18c03.tar.xz
* Implemented 'Revert' channel in Terrain Module.
* Added Revert Area, flood brush. * Added Revert Sphere, paint brush.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs60
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RevertSphere.cs75
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs20
3 files changed, 155 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs
new file mode 100644
index 0000000..856405a
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs
@@ -0,0 +1,60 @@
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*/
28using OpenSim.Region.Environment.Interfaces;
29
30namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
31{
32 public class RevertArea : ITerrainFloodEffect
33 {
34 ITerrainChannel m_revertmap;
35
36 public RevertArea(ITerrainChannel revertmap)
37 {
38 m_revertmap = revertmap;
39 }
40
41 #region ITerrainFloodEffect Members
42
43 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
44 {
45 int x, y;
46 for (x = 0; x < map.Width; x++)
47 {
48 for (y = 0; y < map.Height; y++)
49 {
50 if (fillArea[x, y] == true)
51 {
52 map[x, y] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength);
53 }
54 }
55 }
56 }
57
58 #endregion
59 }
60}
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RevertSphere.cs
new file mode 100644
index 0000000..e7ce68e
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RevertSphere.cs
@@ -0,0 +1,75 @@
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*/
28using System;
29using OpenSim.Region.Environment.Interfaces;
30
31namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
32{
33 public class RevertSphere : ITerrainPaintableEffect
34 {
35 ITerrainChannel m_revertmap;
36
37 public RevertSphere(ITerrainChannel revertmap)
38 {
39 m_revertmap = revertmap;
40 }
41
42 #region ITerrainPaintableEffect Members
43
44 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
45 {
46 int x, y;
47 for (x = 0; x < map.Width; x++)
48 {
49 // Skip everything unlikely to be affected
50 if (Math.Abs(x - rx) > strength * 1.1)
51 continue;
52
53 for (y = 0; y < map.Height; y++)
54 {
55 // Skip everything unlikely to be affected
56 if (Math.Abs(y - ry) > strength * 1.1)
57 continue;
58
59 // Calculate a sphere and add it to the heighmap
60 double z = strength;
61 z *= z;
62 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
63
64 if (z > 0.0)
65 {
66 z *= duration;
67 map[x, y] += (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z);
68 }
69 }
70 }
71 }
72
73 #endregion
74 }
75}
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
index 15c6dcf..491d2e0 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
@@ -190,6 +190,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
190 private Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>(); 190 private Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
191 Scene m_scene; 191 Scene m_scene;
192 ITerrainChannel m_channel; 192 ITerrainChannel m_channel;
193 ITerrainChannel m_revert;
193 bool m_tainted = false; 194 bool m_tainted = false;
194 private IConfigSource m_gConfig; 195 private IConfigSource m_gConfig;
195 196
@@ -201,6 +202,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
201 m_painteffects[StandardTerrainEffects.Smooth] = new PaintBrushes.SmoothSphere(); 202 m_painteffects[StandardTerrainEffects.Smooth] = new PaintBrushes.SmoothSphere();
202 m_painteffects[StandardTerrainEffects.Noise] = new PaintBrushes.NoiseSphere(); 203 m_painteffects[StandardTerrainEffects.Noise] = new PaintBrushes.NoiseSphere();
203 m_painteffects[StandardTerrainEffects.Flatten] = new PaintBrushes.FlattenSphere(); 204 m_painteffects[StandardTerrainEffects.Flatten] = new PaintBrushes.FlattenSphere();
205 m_painteffects[StandardTerrainEffects.Revert] = new PaintBrushes.RevertSphere(m_revert);
204 206
205 // Area of effect selection effects 207 // Area of effect selection effects
206 m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea(); 208 m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea();
@@ -208,6 +210,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
208 m_floodeffects[StandardTerrainEffects.Smooth] = new FloodBrushes.SmoothArea(); 210 m_floodeffects[StandardTerrainEffects.Smooth] = new FloodBrushes.SmoothArea();
209 m_floodeffects[StandardTerrainEffects.Noise] = new FloodBrushes.NoiseArea(); 211 m_floodeffects[StandardTerrainEffects.Noise] = new FloodBrushes.NoiseArea();
210 m_floodeffects[StandardTerrainEffects.Flatten] = new FloodBrushes.FlattenArea(); 212 m_floodeffects[StandardTerrainEffects.Flatten] = new FloodBrushes.FlattenArea();
213 m_floodeffects[StandardTerrainEffects.Revert] = new FloodBrushes.RevertArea(m_revert);
211 214
212 // Filesystem load/save loaders 215 // Filesystem load/save loaders
213 m_loaders[".r32"] = new FileLoaders.RAW32(); 216 m_loaders[".r32"] = new FileLoaders.RAW32();
@@ -218,6 +221,18 @@ namespace OpenSim.Region.Environment.Modules.Terrain
218 m_loaders[".jpeg"] = m_loaders[".jpg"]; 221 m_loaders[".jpeg"] = m_loaders[".jpg"];
219 } 222 }
220 223
224 public void UpdateRevertMap()
225 {
226 int x, y;
227 for (x = 0; x < m_channel.Width; x++)
228 {
229 for (y = 0; y < m_channel.Height; y++)
230 {
231 m_revert[x, y] = m_channel[x, y];
232 }
233 }
234 }
235
221 public void LoadFromFile(string filename) 236 public void LoadFromFile(string filename)
222 { 237 {
223 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) 238 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
@@ -229,6 +244,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
229 ITerrainChannel channel = loader.Value.LoadFile(filename); 244 ITerrainChannel channel = loader.Value.LoadFile(filename);
230 m_scene.Heightmap = channel; 245 m_scene.Heightmap = channel;
231 m_channel = channel; 246 m_channel = channel;
247 UpdateRevertMap();
232 } 248 }
233 return; 249 return;
234 } 250 }
@@ -266,11 +282,15 @@ namespace OpenSim.Region.Environment.Modules.Terrain
266 { 282 {
267 m_channel = new TerrainChannel(); 283 m_channel = new TerrainChannel();
268 m_scene.Heightmap = m_channel; 284 m_scene.Heightmap = m_channel;
285 m_revert = new TerrainChannel();
286 UpdateRevertMap();
269 } 287 }
270 } 288 }
271 else 289 else
272 { 290 {
273 m_channel = m_scene.Heightmap; 291 m_channel = m_scene.Heightmap;
292 m_revert = new TerrainChannel();
293 UpdateRevertMap();
274 } 294 }
275 295
276 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 296 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;