aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2019-11-09 23:59:19 +0000
committerUbitUmarov2019-11-09 23:59:19 +0000
commit53339d29704d3a9fb2d436ee48fc3ca99ab33108 (patch)
treebced7330f7391458403d2eefb61b124bd51acc1a /OpenSim/Region
parentcosmetics (diff)
downloadopensim-SC-53339d29704d3a9fb2d436ee48fc3ca99ab33108.zip
opensim-SC-53339d29704d3a9fb2d436ee48fc3ca99ab33108.tar.gz
opensim-SC-53339d29704d3a9fb2d436ee48fc3ca99ab33108.tar.bz2
opensim-SC-53339d29704d3a9fb2d436ee48fc3ca99ab33108.tar.xz
terraforming changes: make sliders work, remove some brushs, etc. Feedback needed (run prebuild)
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-xOpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs36
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs129
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs18
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/ITerrainFeature.cs60
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs323
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs46
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs21
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs14
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs223
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs17
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs25
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs211
-rwxr-xr-xOpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs71
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScenePresence.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/ITerrainModule.cs2
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainChannel.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainUtil.cs13
29 files changed, 157 insertions, 1180 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 4b6b6ac..c8af1d1 100755
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -5153,7 +5153,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5153 5153
5154 int count = 0; 5154 int count = 0;
5155 EntityUpdate eu; 5155 EntityUpdate eu;
5156 for(int indx = 0; indx < objectUpdates.Count;++indx) 5156 for(int indx = 0; indx < objectUpdates.Count; ++indx)
5157 { 5157 {
5158 eu = objectUpdates[indx]; 5158 eu = objectUpdates[indx];
5159 lastpos = zc.Position; 5159 lastpos = zc.Position;
@@ -8971,34 +8971,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP
8971 8971
8972 private bool HandlerModifyLand(IClientAPI sender, Packet Pack) 8972 private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
8973 { 8973 {
8974 if (OnModifyTerrain == null)
8975 return true;
8976
8974 ModifyLandPacket modify = (ModifyLandPacket)Pack; 8977 ModifyLandPacket modify = (ModifyLandPacket)Pack;
8975 8978
8976 #region Packet Session and User Check 8979 if (modify.ParcelData.Length == 0)
8977 if (modify.AgentData.SessionID != SessionId ||
8978 modify.AgentData.AgentID != AgentId)
8979 return true; 8980 return true;
8980 8981
8982 #region Packet Session and User Check
8983 if (modify.AgentData.SessionID != SessionId || modify.AgentData.AgentID != AgentId)
8984 return true;
8985
8981 #endregion 8986 #endregion
8982 //m_log.Info("[LAND]: LAND:" + modify.ToString()); 8987 //m_log.Info("[LAND]: LAND:" + modify.ToString());
8983 if (modify.ParcelData.Length > 0) 8988 for (int i = 0; i < modify.ParcelData.Length; i++)
8984 { 8989 {
8985 // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore, 8990 OnModifyTerrain?.Invoke(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
8986 // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit. 8991 modify.ModifyBlockExtended[i].BrushSize, modify.ModifyBlock.Action,
8987 if (OnModifyTerrain != null) 8992 modify.ParcelData[i].North, modify.ParcelData[i].West,
8988 { 8993 modify.ParcelData[i].South, modify.ParcelData[i].East);
8989 for (int i = 0; i < modify.ParcelData.Length; i++)
8990 {
8991 ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
8992 if (handlerModifyTerrain != null)
8993 {
8994 handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
8995 modify.ModifyBlock.BrushSize,
8996 modify.ModifyBlock.Action, modify.ParcelData[i].North,
8997 modify.ParcelData[i].West, modify.ParcelData[i].South,
8998 modify.ParcelData[i].East, AgentId);
8999 }
9000 }
9001 }
9002 } 8994 }
9003 8995
9004 return true; 8996 return true;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
index b456aa1..39d8d49 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
64 64
65 for (int i = 0; i < rounds; i++) 65 for (int i = 0; i < rounds; i++)
66 { 66 {
67 smoothFunction.FloodEffect(map, bitmap, 1.0, 0, map.Width - 1, 0, map.Height - 1); 67 smoothFunction.FloodEffect(map, bitmap, -1f, 1.0f, 0, map.Width - 1, 0, map.Height - 1);
68 } 68 }
69 } 69 }
70 70
@@ -99,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
99 } 99 }
100 } 100 }
101 101
102 raiseFunction.FloodEffect(map, bitmap, height, 0, map.Width - 1, 0, map.Height - 1); 102 raiseFunction.FloodEffect(map, bitmap, -1f,(float)height, 0, map.Width - 1, 0, map.Height - 1);
103 } 103 }
104 } 104 }
105 } 105 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs
deleted file mode 100644
index 3222524..0000000
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs
+++ /dev/null
@@ -1,129 +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 OpenSimulator 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 */
27using System;
28using OpenSim.Region.CoreModules.World.Terrain.PaintBrushes;
29using OpenSim.Region.Framework.Interfaces;
30using OpenSim.Region.Framework.Scenes;
31using log4net;
32using System.Reflection;
33
34namespace OpenSim.Region.CoreModules.World.Terrain.Effects
35{
36 internal class CookieCutter : ITerrainEffect
37 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39
40 #region ITerrainEffect Members
41
42 public void RunEffect(ITerrainChannel map)
43 {
44 ITerrainPaintableEffect eroder = new WeatherSphere();
45
46 bool[,] cliffMask = new bool[map.Width,map.Height];
47 bool[,] channelMask = new bool[map.Width,map.Height];
48 bool[,] smoothMask = new bool[map.Width,map.Height];
49 bool[,] allowMask = new bool[map.Width,map.Height];
50
51 m_log.Info("S1");
52
53 // Step one, generate rough mask
54 int x, y;
55 for (x = 0; x < map.Width; x++)
56 {
57 for (y = 0; y < map.Height; y++)
58 {
59 m_log.Info(".");
60 smoothMask[x, y] = true;
61 allowMask[x,y] = true;
62
63 // Start underwater
64 map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5;
65 // Add a little height. (terrain should now be above water, mostly.)
66 map[x, y] += 20;
67
68 const int channelsX = 4;
69 int channelWidth = (map.Width / channelsX / 4);
70 const int channelsY = 4;
71 int channelHeight = (map.Height / channelsY / 4);
72
73 SetLowerChannel(map, cliffMask, channelMask, x, y, channelsX, channelWidth, map.Width, x);
74 SetLowerChannel(map, cliffMask, channelMask, x, y, channelsY, channelHeight, map.Height, y);
75 }
76 }
77
78 m_log.Info("S2");
79 //smooth.FloodEffect(map, smoothMask, 4.0);
80
81 m_log.Info("S3");
82 for (x = 0; x < map.Width; x++)
83 {
84 for (y = 0; y < map.Height; y++)
85 {
86 if (cliffMask[x, y])
87 eroder.PaintEffect(map, allowMask, x, y, -1, 4, 0.1,0,map.Width - 1,0,map.Height - 1);
88 }
89 }
90
91 for (x = 0; x < map.Width; x += 2)
92 {
93 for (y = 0; y < map.Height; y += 2)
94 {
95 if (map[x, y] < 0.1)
96 map[x, y] = 0.1;
97 if (map[x, y] > 256)
98 map[x, y] = 256;
99 }
100 }
101 //smooth.FloodEffect(map, smoothMask, 4.0);
102 }
103
104 #endregion
105
106 private static void SetLowerChannel(ITerrainChannel map, bool[,] cliffMask, bool[,] channelMask, int x, int y, int numChannels, int channelWidth,
107 int mapSize, int rp)
108 {
109 for (int i = 0; i < numChannels; i++)
110 {
111 double distanceToLine = Math.Abs(rp - ((mapSize / numChannels) * i));
112
113 if (distanceToLine < channelWidth)
114 {
115 if (channelMask[x, y])
116 return;
117
118 // Remove channels
119 map[x, y] -= 10;
120 channelMask[x, y] = true;
121 }
122 if (distanceToLine < 1)
123 {
124 cliffMask[x, y] = true;
125 }
126 }
127 }
128 }
129}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
index 80396c4..5365aab 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
@@ -30,23 +30,27 @@ using OpenSim.Region.Framework.Scenes;
30 30
31namespace OpenSim.Region.CoreModules.World.Terrain.Effects 31namespace OpenSim.Region.CoreModules.World.Terrain.Effects
32{ 32{
33 internal class DefaultTerrainGenerator : ITerrainEffect 33 public class DefaultTerrainGenerator : ITerrainEffect
34 { 34 {
35 #region ITerrainEffect Members 35 #region ITerrainEffect Members
36 36
37 public void RunEffect(ITerrainChannel map) 37 public void RunEffect(ITerrainChannel map)
38 { 38 {
39 int x, y; 39 int x, y;
40 int cx = map.Width / 2;
41 int cy = map.Height / 2;
42 float h;
43 float b;
44
40 for (x = 0; x < map.Width; x++) 45 for (x = 0; x < map.Width; x++)
41 { 46 {
42 for (y = 0; y < map.Height; y++) 47 for (y = 0; y < map.Height; y++)
43 { 48 {
44 map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; 49 h = 25 * TerrainUtil.SphericalFactor(x - cx, y - cy, 50);
45 double spherFac = TerrainUtil.SphericalFactor(x, y, map.Width / 2, map.Height / 2, 50) * 0.01; 50 b = 10 * TerrainUtil.SphericalFactor(x - cx, y - cy, 100);
46 if (map[x, y] < spherFac) 51 if (h < b)
47 { 52 h = b;
48 map[x, y] = spherFac; 53 map[x, y] = h;
49 }
50 } 54 }
51 } 55 }
52 } 56 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs
index 0c4171e..9569d08 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs
@@ -33,35 +33,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength, 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
37 int startX, int endX, int startY, int endY) 37 int startX, int endX, int startY, int endY)
38 { 38 {
39 double sum = 0.0;
40 double steps = 0.0;
41 39
42 int x, y; 40 strength *= 0.04f;
43 for (x = startX; x <= endX; x++) 41 if(strength > 1.0f)
44 { 42 strength = 1.0f;
45 for (y = startY; y <= endY; y++)
46 {
47 if (fillArea[x, y])
48 {
49 sum += map[x, y];
50 steps += 1.0;
51 }
52 }
53 }
54
55 double avg = sum / steps;
56
57 double str = 0.1 * strength; // == 0.2 in the default client
58 43
59 for (x = startX; x <= endX; x++) 44 for (int x = startX; x <= endX; x++)
60 { 45 {
61 for (y = startY; y <= endY; y++) 46 for (int y = startY; y <= endY; y++)
62 { 47 {
63 if (fillArea[x, y]) 48 if (fillArea[x, y])
64 map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str); 49 map[x, y] = (map[x, y] * (1.0 - strength)) + (height * strength);
65 } 50 }
66 } 51 }
67 } 52 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs
index a275a86..8020962 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength, 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
37 int startX, int endX, int startY, int endY) 37 int startX, int endX, int startY, int endY)
38 { 38 {
39 int x,y; 39 int x,y;
@@ -44,6 +44,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
44 if (fillArea[x, y]) 44 if (fillArea[x, y])
45 { 45 {
46 map[x, y] -= strength; 46 map[x, y] -= strength;
47 if (map[x, y] < -100f)
48 map[x, y] = -100f;
47 } 49 }
48 } 50 }
49 } 51 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
index d634e8b..26d77ea 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
@@ -35,9 +35,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
35 { 35 {
36 #region ITerrainFloodEffect Members 36 #region ITerrainFloodEffect Members
37 37
38 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength, 38 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
39 int startX, int endX, int startY, int endY) 39 int startX, int endX, int startY, int endY)
40 { 40 {
41 strength *= 0.08f;
42
41 int x, y; 43 int x, y;
42 for (x = startX; x <= endX; x++) 44 for (x = startX; x <= endX; x++)
43 { 45 {
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs
index 6ccd5df..897ac72 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength, 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
37 int startX, int endX, int startY, int endY) 37 int startX, int endX, int startY, int endY)
38 { 38 {
39 int x,y; 39 int x,y;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs
index 4230133..973a765 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs
@@ -46,17 +46,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
46 /// <param name="map">the current heightmap</param> 46 /// <param name="map">the current heightmap</param>
47 /// <param name="fillArea">array indicating which sections of the map are to be reverted</param> 47 /// <param name="fillArea">array indicating which sections of the map are to be reverted</param>
48 /// <param name="strength">unused</param> 48 /// <param name="strength">unused</param>
49 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength, 49 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
50 int startX, int endX, int startY, int endY) 50 int startX, int endX, int startY, int endY)
51 { 51 {
52 int x, y; 52 int x, y;
53 strength *= 2f;
54 if (strength > 1.0f)
55 strength = 1.0f;
56
53 for (x = startX; x <= endX; x++) 57 for (x = startX; x <= endX; x++)
54 { 58 {
55 for (y = startY; y <= endY; y++) 59 for (y = startY; y <= endY; y++)
56 { 60 {
57 if (fillArea[x, y]) 61 if (fillArea[x, y])
58 { 62 {
59 map[x, y] = m_revertmap[x, y]; 63 map[x, y] = map[x, y] * (1.0f - strength) + m_revertmap[x, y] * strength;
60 } 64 }
61 } 65 }
62 } 66 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs
index 6c0d60d..64ffd4d 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs
@@ -33,11 +33,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength, 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, float height, float strength,
37 int startX, int endX, int startY, int endY) 37 int startX, int endX, int startY, int endY)
38 { 38 {
39 double area = strength; 39 double area = 4;
40 double step = strength / 4.0; 40 double step = 1;
41
42 strength *= 0.002f;
41 43
42 double[,] manipulate = new double[map.Width,map.Height]; 44 double[,] manipulate = new double[map.Width,map.Height];
43 int x, y; 45 int x, y;
@@ -72,7 +74,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
72 if (!fillArea[x, y]) 74 if (!fillArea[x, y])
73 continue; 75 continue;
74 76
75 map[x, y] = manipulate[x, y]; 77 map[x, y] = strength * manipulate[x, y];
76 } 78 }
77 } 79 }
78 } 80 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainFeature.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFeature.cs
deleted file mode 100644
index 78a43db..0000000
--- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainFeature.cs
+++ /dev/null
@@ -1,60 +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 OpenSimulator 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.Framework.Interfaces;
30
31namespace OpenSim.Region.CoreModules.World.Terrain
32{
33 public interface ITerrainFeature
34 {
35 /// <summary>
36 /// Creates the feature.
37 /// </summary>
38 /// <returns>
39 /// Empty string if successful, otherwise error message.
40 /// </returns>
41 /// <param name='map'>
42 /// ITerrainChannel holding terrain data.
43 /// </param>
44 /// <param name='args'>
45 /// command-line arguments from console.
46 /// </param>
47 string CreateFeature(ITerrainChannel map, string[] args);
48
49 /// <summary>
50 /// Gets a string describing the usage.
51 /// </summary>
52 /// <returns>
53 /// A string describing parameters for creating the feature.
54 /// Format is "feature-name <arg1> <arg2> ..."
55 /// </returns>
56 string GetUsage();
57 }
58
59}
60
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs
index f7be25f..63ea1ec 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs
@@ -32,7 +32,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
32{ 32{
33 public interface ITerrainFloodEffect 33 public interface ITerrainFloodEffect
34 { 34 {
35 void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength, 35 void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, float height, float strength,
36 int startX, int endX, int startY, int endY); 36 int startX, int endX, int startY, int endY);
37 } 37 }
38} \ No newline at end of file 38} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs
index d0b05e4..5741e4f 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs
@@ -31,7 +31,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
31{ 31{
32 public interface ITerrainPaintableEffect 32 public interface ITerrainPaintableEffect
33 { 33 {
34 void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z, 34 void PaintEffect(ITerrainChannel map, bool[,] allowMask, float x, float y, float z,
35 double strength, double duration, int startX, int endX, int startY, int endY); 35 float strength, float duration, int startX, int endX, int startY, int endY);
36 } 36 }
37} 37}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs
deleted file mode 100644
index 7358ba3..0000000
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs
+++ /dev/null
@@ -1,323 +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 OpenSimulator 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.Framework.Interfaces;
30using OpenSim.Region.Framework.Scenes;
31
32namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
33{
34 /// <summary>
35 /// Hydraulic Erosion Brush
36 /// </summary>
37 public class ErodeSphere : ITerrainPaintableEffect
38 {
39 private const double rainHeight = 0.2;
40 private const int rounds = 10;
41 private const NeighbourSystem type = NeighbourSystem.Moore;
42 private const double waterSaturation = 0.30;
43
44 #region Supporting Functions
45
46 private static int[] Neighbours(NeighbourSystem neighbourType, int index)
47 {
48 int[] coord = new int[2];
49
50 index++;
51
52 switch (neighbourType)
53 {
54 case NeighbourSystem.Moore:
55 switch (index)
56 {
57 case 1:
58 coord[0] = -1;
59 coord[1] = -1;
60 break;
61
62 case 2:
63 coord[0] = -0;
64 coord[1] = -1;
65 break;
66
67 case 3:
68 coord[0] = +1;
69 coord[1] = -1;
70 break;
71
72 case 4:
73 coord[0] = -1;
74 coord[1] = -0;
75 break;
76
77 case 5:
78 coord[0] = -0;
79 coord[1] = -0;
80 break;
81
82 case 6:
83 coord[0] = +1;
84 coord[1] = -0;
85 break;
86
87 case 7:
88 coord[0] = -1;
89 coord[1] = +1;
90 break;
91
92 case 8:
93 coord[0] = -0;
94 coord[1] = +1;
95 break;
96
97 case 9:
98 coord[0] = +1;
99 coord[1] = +1;
100 break;
101
102 default:
103 break;
104 }
105 break;
106
107 case NeighbourSystem.VonNeumann:
108 switch (index)
109 {
110 case 1:
111 coord[0] = 0;
112 coord[1] = -1;
113 break;
114
115 case 2:
116 coord[0] = -1;
117 coord[1] = 0;
118 break;
119
120 case 3:
121 coord[0] = +1;
122 coord[1] = 0;
123 break;
124
125 case 4:
126 coord[0] = 0;
127 coord[1] = +1;
128 break;
129
130 case 5:
131 coord[0] = -0;
132 coord[1] = -0;
133 break;
134
135 default:
136 break;
137 }
138 break;
139 }
140
141 return coord;
142 }
143
144 private enum NeighbourSystem
145 {
146 Moore,
147 VonNeumann
148 } ;
149
150 #endregion
151
152 #region ITerrainPaintableEffect Members
153
154 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
155 double strength, double duration, int startX, int endX, int startY, int endY)
156 {
157 strength = TerrainUtil.MetersToSphericalStrength(strength);
158
159 int x, y;
160 // Using one 'rain' round for this, so skipping a useless loop
161 // Will need to adapt back in for the Flood brush
162
163 ITerrainChannel water = new TerrainChannel(map.Width, map.Height);
164 ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height);
165
166 // Fill with rain
167 for (x = startX; x <= endX; x++)
168 {
169 for (y = startY; y <= endY; y++)
170 {
171 if (mask[x, y])
172 water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration);
173 }
174 }
175
176 for (int i = 0; i < rounds; i++)
177 {
178 // Erode underlying terrain
179 for (x = startX; x <= endX; x++)
180 {
181 for (y = startY; y <= endY; y++)
182 {
183 if (mask[x, y])
184 {
185 const double solConst = (1.0 / rounds);
186 double sedDelta = water[x, y] * solConst;
187 map[x, y] -= sedDelta;
188 sediment[x, y] += sedDelta;
189 }
190 }
191 }
192
193 // Move water
194 for (x = startX; x <= endX; x++)
195 {
196 for (y = startY; y <= endY; y++)
197 {
198 if (water[x, y] <= 0)
199 continue;
200
201 // Step 1. Calculate average of neighbours
202
203 int neighbours = 0;
204 double altitudeTotal = 0.0;
205 double altitudeMe = map[x, y] + water[x, y];
206
207 const int NEIGHBOUR_ME = 4;
208 const int NEIGHBOUR_MAX = 9;
209
210 for (int j = 0; j < NEIGHBOUR_MAX; j++)
211 {
212 if (j != NEIGHBOUR_ME)
213 {
214 int[] coords = Neighbours(type, j);
215
216 coords[0] += x;
217 coords[1] += y;
218
219 if (coords[0] > map.Width - 1)
220 continue;
221 if (coords[1] > map.Height - 1)
222 continue;
223 if (coords[0] < 0)
224 continue;
225 if (coords[1] < 0)
226 continue;
227
228 // Calculate total height of this neighbour
229 double altitudeNeighbour = water[coords[0], coords[1]] + map[coords[0], coords[1]];
230
231 // If it's greater than me...
232 if (altitudeNeighbour - altitudeMe < 0)
233 {
234 // Add it to our calculations
235 neighbours++;
236 altitudeTotal += altitudeNeighbour;
237 }
238 }
239 }
240
241 if (neighbours == 0)
242 continue;
243
244 double altitudeAvg = altitudeTotal / neighbours;
245
246 // Step 2. Allocate water to neighbours.
247 for (int j = 0; j < NEIGHBOUR_MAX; j++)
248 {
249 if (j != NEIGHBOUR_ME)
250 {
251 int[] coords = Neighbours(type, j);
252
253 coords[0] += x;
254 coords[1] += y;
255
256 if (coords[0] > map.Width - 1)
257 continue;
258 if (coords[1] > map.Height - 1)
259 continue;
260 if (coords[0] < 0)
261 continue;
262 if (coords[1] < 0)
263 continue;
264
265 // Skip if we dont have water to begin with.
266 if (water[x, y] < 0)
267 continue;
268
269 // Calculate our delta average
270 double altitudeDelta = altitudeMe - altitudeAvg;
271
272 if (altitudeDelta < 0)
273 continue;
274
275 // Calculate how much water we can move
276 double waterMin = Math.Min(water[x, y], altitudeDelta);
277 double waterDelta = waterMin * ((water[coords[0], coords[1]] + map[coords[0], coords[1]])
278 / altitudeTotal);
279
280 double sedimentDelta = sediment[x, y] * (waterDelta / water[x, y]);
281
282 if (sedimentDelta > 0)
283 {
284 sediment[x, y] -= sedimentDelta;
285 sediment[coords[0], coords[1]] += sedimentDelta;
286 }
287 }
288 }
289 }
290 }
291
292 // Evaporate
293
294 for (x = 0; x < water.Width; x++)
295 {
296 for (y = 0; y < water.Height; y++)
297 {
298 water[x, y] *= 1.0 - (rainHeight / rounds);
299
300 double waterCapacity = waterSaturation * water[x, y];
301
302 double sedimentDeposit = sediment[x, y] - waterCapacity;
303 if (sedimentDeposit > 0)
304 {
305 if (mask[x, y])
306 {
307 sediment[x, y] -= sedimentDeposit;
308 map[x, y] += sedimentDeposit;
309 }
310 }
311 }
312 }
313 }
314
315 // Deposit any remainder (should be minimal)
316 for (x = 0; x < water.Width; x++)
317 for (y = 0; y < water.Height; y++)
318 if (mask[x, y] && sediment[x, y] > 0)
319 map[x, y] += sediment[x, y];
320 }
321 #endregion
322 }
323}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs
index 9d3d4cb..4c24e49 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs
@@ -35,49 +35,29 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
35 { 35 {
36 #region ITerrainPaintableEffect Members 36 #region ITerrainPaintableEffect Members
37 37
38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, float rx, float ry, float rz,
39 double strength, double duration, int startX, int endX, int startY, int endY) 39 float size, float strength, int startX, int endX, int startY, int endY)
40 { 40 {
41 strength = TerrainUtil.MetersToSphericalStrength(strength);
42
43 int x, y; 41 int x, y;
44 42
43 size *= 2;
44
45 float distancefactor;
46
45 // blend in map 47 // blend in map
46 for (x = startX; x <= endX; x++) 48 for (x = startX; x <= endX; ++x)
47 { 49 {
48 for (y = startY; y <= endY; y++) 50 for (y = startY; y <= endY; ++y)
49 { 51 {
50 if (!mask[x,y]) 52 if (!mask[x,y])
51 continue; 53 continue;
52 54
53 double z; 55 distancefactor = strength * TerrainUtil.SphericalFactor(x - rx, y - ry, size);
54 if (duration < 4.0)
55 {
56 z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration * 0.25;
57 }
58 else {
59 z = 1.0;
60 }
61
62 double delta = rz - map[x, y];
63 if (Math.Abs(delta) > 0.1)
64 {
65 if (z > 1.0)
66 {
67 z = 1.0;
68 }
69 else if (z < 0.0)
70 {
71 z = 0.0;
72 }
73 delta *= z;
74 }
75
76 if (delta != 0) // add in non-zero amount
77 {
78 map[x, y] += delta;
79 }
80 56
57 if(distancefactor >= 1.0f)
58 map[x, y] = rz;
59 else
60 map[x, y] += (rz - (float)map[x, y]) * distancefactor;
81 } 61 }
82 } 62 }
83 } 63 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs
index a88a022..68c6151 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs
@@ -34,11 +34,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
34 { 34 {
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, 37 public void PaintEffect(ITerrainChannel map, bool[,] mask, float rx, float ry, float rz,
38 double strength, double duration, int startX, int endX, int startY, int endY) 38 float size, float strength, int startX, int endX, int startY, int endY)
39 { 39 {
40 int s = (int) (Math.Pow(2, strength) + 0.5); 40 size = 0.5f * (float)Math.PI / size;
41 41 strength *= 2;
42 int x, y; 42 int x, y;
43 43
44 for (x = startX; x <= endX; x++) 44 for (x = startX; x <= endX; x++)
@@ -49,19 +49,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
49 continue; 49 continue;
50 50
51 // Calculate a cos-sphere and add it to the heighmap 51 // Calculate a cos-sphere and add it to the heighmap
52 double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry))); 52 double r = Math.Sqrt((x - rx) * (x - rx) + (y - ry) * (y - ry));
53 double z = Math.Cos(r * Math.PI / (s * 2)); 53 double distancefactor = Math.Cos(r * size);
54 if (z > 0.0) 54 if (distancefactor > 0.0)
55 { 55 {
56 double newz = map[x, y] - z * duration; 56 double newz = map[x, y] - distancefactor * strength;
57 if (newz < 0.0) 57 if (newz <= -100f)
58 map[x, y] = 0.0; 58 map[x, y] = -100f;
59 else 59 else
60 map[x, y] = newz; 60 map[x, y] = newz;
61 } 61 }
62 } 62 }
63 } 63 }
64
65 } 64 }
66 #endregion 65 #endregion
67 } 66 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
index 46d47b4..010ca0c 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
@@ -35,11 +35,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
35 { 35 {
36 #region ITerrainPaintableEffect Members 36 #region ITerrainPaintableEffect Members
37 37
38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, float rx, float ry, float rz,
39 double strength, double duration, int startX, int endX, int startY, int endY) 39 float size, float strength, int startX, int endX, int startY, int endY)
40 { 40 {
41 strength = TerrainUtil.MetersToSphericalStrength(strength);
42
43 int x, y; 41 int x, y;
44 42
45 for (x = startX; x <= endX; x++) 43 for (x = startX; x <= endX; x++)
@@ -50,14 +48,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
50 continue; 48 continue;
51 49
52 // Calculate a sphere and add it to the heighmap 50 // Calculate a sphere and add it to the heighmap
53 double z = strength; 51 float distancefactor = TerrainUtil.SphericalFactor(x - rx, y - ry, size);
54 z *= z;
55 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
56 52
57 double noise = TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0); 53 double noise = TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0);
58 54
59 if (z > 0.0) 55 if (distancefactor > 0.0)
60 map[x, y] += noise * z * duration; 56 map[x, y] += noise * distancefactor * strength;
61 } 57 }
62 } 58 }
63 } 59 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs
deleted file mode 100644
index 281690d..0000000
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs
+++ /dev/null
@@ -1,223 +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 OpenSimulator 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.Framework.Interfaces;
30using OpenSim.Region.Framework.Scenes;
31
32namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
33{
34 /// <summary>
35 /// Speed-Optimised Hybrid Erosion Brush
36 ///
37 /// As per Jacob Olsen's Paper
38 /// http://www.oddlabs.com/download/terrain_generation.pdf
39 /// </summary>
40 public class OlsenSphere : ITerrainPaintableEffect
41 {
42 private const double nConst = 1024.0;
43 private const NeighbourSystem type = NeighbourSystem.Moore;
44
45 #region Supporting Functions
46
47 private static int[] Neighbours(NeighbourSystem neighbourType, int index)
48 {
49 int[] coord = new int[2];
50
51 index++;
52
53 switch (neighbourType)
54 {
55 case NeighbourSystem.Moore:
56 switch (index)
57 {
58 case 1:
59 coord[0] = -1;
60 coord[1] = -1;
61 break;
62
63 case 2:
64 coord[0] = -0;
65 coord[1] = -1;
66 break;
67
68 case 3:
69 coord[0] = +1;
70 coord[1] = -1;
71 break;
72
73 case 4:
74 coord[0] = -1;
75 coord[1] = -0;
76 break;
77
78 case 5:
79 coord[0] = -0;
80 coord[1] = -0;
81 break;
82
83 case 6:
84 coord[0] = +1;
85 coord[1] = -0;
86 break;
87
88 case 7:
89 coord[0] = -1;
90 coord[1] = +1;
91 break;
92
93 case 8:
94 coord[0] = -0;
95 coord[1] = +1;
96 break;
97
98 case 9:
99 coord[0] = +1;
100 coord[1] = +1;
101 break;
102
103 default:
104 break;
105 }
106 break;
107
108 case NeighbourSystem.VonNeumann:
109 switch (index)
110 {
111 case 1:
112 coord[0] = 0;
113 coord[1] = -1;
114 break;
115
116 case 2:
117 coord[0] = -1;
118 coord[1] = 0;
119 break;
120
121 case 3:
122 coord[0] = +1;
123 coord[1] = 0;
124 break;
125
126 case 4:
127 coord[0] = 0;
128 coord[1] = +1;
129 break;
130
131 case 5:
132 coord[0] = -0;
133 coord[1] = -0;
134 break;
135
136 default:
137 break;
138 }
139 break;
140 }
141
142 return coord;
143 }
144
145 private enum NeighbourSystem
146 {
147 Moore,
148 VonNeumann
149 } ;
150
151 #endregion
152
153 #region ITerrainPaintableEffect Members
154
155 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
156 double strength, double duration, int startX, int endX, int startY, int endY)
157 {
158 strength = TerrainUtil.MetersToSphericalStrength(strength);
159
160 int x, y;
161
162 for (x = startX; x <= endX; x++)
163 {
164 for (y = startY; y <= endY; y++)
165 {
166 if (!mask[x, y])
167 continue;
168
169 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
170
171 if (z > 0) // add in non-zero amount
172 {
173 const int NEIGHBOUR_ME = 4;
174 const int NEIGHBOUR_MAX = 9;
175
176 double max = Double.MinValue;
177 int loc = 0;
178
179
180 for (int j = 0; j < NEIGHBOUR_MAX; j++)
181 {
182 if (j != NEIGHBOUR_ME)
183 {
184 int[] coords = Neighbours(type, j);
185
186 coords[0] += x;
187 coords[1] += y;
188
189 if (coords[0] > map.Width - 1)
190 continue;
191 if (coords[1] > map.Height - 1)
192 continue;
193 if (coords[0] < 0)
194 continue;
195 if (coords[1] < 0)
196 continue;
197
198 double cellmax = map[x, y] - map[coords[0], coords[1]];
199 if (cellmax > max)
200 {
201 max = cellmax;
202 loc = j;
203 }
204 }
205 }
206
207 double T = nConst / ((map.Width + map.Height) / 2.0);
208 // Apply results
209 if (0 < max && max <= T)
210 {
211 int[] maxCoords = Neighbours(type, loc);
212 double heightDelta = 0.5 * max * z * duration;
213 map[x, y] -= heightDelta;
214 map[x + maxCoords[0], y + maxCoords[1]] += heightDelta;
215 }
216 }
217 }
218 }
219 }
220
221 #endregion
222 }
223}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs
index 5305cb4..2155368 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs
@@ -35,12 +35,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 37
38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, float rx, float ry, float rz,
39 double strength, double duration, int startX, int endX, int startY, int endY) 39 float size, float strength, int startX, int endX, int startY, int endY)
40 { 40 {
41 int s = (int) (Math.Pow(2, strength) + 0.5); 41 size = 0.5f *(float)Math.PI / size;
42 strength *= 2;
42 43
43 int x,y; 44 int x, y;
44 45
45 for (x = startX; x <= endX; x++) 46 for (x = startX; x <= endX; x++)
46 { 47 {
@@ -50,10 +51,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
50 continue; 51 continue;
51 52
52 // Calculate a cos-sphere and add it to the heighmap 53 // Calculate a cos-sphere and add it to the heighmap
53 double r = Math.Sqrt((x - rx) * (x - rx) + ((y - ry) * (y - ry))); 54 double r = Math.Sqrt((x - rx) * (x - rx) + (y - ry) * (y - ry));
54 double z = Math.Cos(r * Math.PI / (s * 2)); 55 double distancefactor = Math.Cos(r * size);
55 if (z > 0.0) 56 if (distancefactor > 0.0)
56 map[x, y] += z * duration; 57 map[x, y] += distancefactor * strength;
57 } 58 }
58 } 59 }
59 } 60 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs
index ca30e9e..ab3c5b7 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs
@@ -41,17 +41,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
41 41
42 #region ITerrainPaintableEffect Members 42 #region ITerrainPaintableEffect Members
43 43
44 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, 44 public void PaintEffect(ITerrainChannel map, bool[,] mask, float rx, float ry, float rz,
45 double strength, double duration, int startX, int endX, int startY, int endY) 45 float size, float strength, int startX, int endX, int startY, int endY)
46 { 46 {
47 strength = TerrainUtil.MetersToSphericalStrength(strength); 47 if (strength < 0)
48 duration = 0.03; //MCP Should be read from ini file
49
50 if (duration > 1.0)
51 duration = 1.0;
52 if (duration < 0)
53 return; 48 return;
54 49
50 if (strength > 1.0f)
51 strength = 1.0f;
52
55 int x,y; 53 int x,y;
56 for (x = startX; x <= endX; x++) 54 for (x = startX; x <= endX; x++)
57 { 55 {
@@ -61,14 +59,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
61 continue; 59 continue;
62 60
63 // Calculate a sphere and add it to the heighmap 61 // Calculate a sphere and add it to the heighmap
64 double z = strength; 62 double distancefactor = TerrainUtil.SphericalFactor(x - rx, y - ry, size);
65 z *= z; 63 if (distancefactor > 0.0)
66 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
67
68 if (z > 0.0)
69 { 64 {
70 z *= duration; 65 distancefactor *= strength;
71 map[x, y] = (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z); 66 map[x, y] = (map[x, y] * (1.0 - distancefactor)) + (m_revertmap[x, y] * distancefactor);
72 } 67 }
73 } 68 }
74 } 69 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs
index 0342962..a952694 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs
@@ -34,18 +34,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
34 { 34 {
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, 37 public void PaintEffect(ITerrainChannel map, bool[,] mask, float rx, float ry, float rz,
38 double strength, double duration, int startX, int endX, int startY, int endY) 38 float size, float strengh, int startX, int endX, int startY, int endY)
39 { 39 {
40 strength = TerrainUtil.MetersToSphericalStrength(strength);
41
42 int x, y; 40 int x, y;
43 double[,] tweak = new double[map.Width,map.Height]; 41 double[,] tweak = new double[map.Width, map.Height];
44 42
45 double area = strength; 43 double step = size / 4.0;
46 double step = strength / 4.0;
47 duration = 0.03; //MCP Should be read from ini file
48 44
45 if(strengh > 1.0f)
46 strengh = 1.0f;
49 47
50 // compute delta map 48 // compute delta map
51 for (x = startX; x <= endX; x++) 49 for (x = startX; x <= endX; x++)
@@ -55,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
55 if (!mask[x, y]) 53 if (!mask[x, y])
56 continue; 54 continue;
57 55
58 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 56 double z = TerrainUtil.SphericalFactor(x - rx, y - ry, size);
59 57
60 if (z > 0) // add in non-zero amount 58 if (z > 0) // add in non-zero amount
61 { 59 {
@@ -63,10 +61,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
63 int avgsteps = 0; 61 int avgsteps = 0;
64 62
65 double n; 63 double n;
66 for (n = 0.0 - area; n < area; n += step) 64 for (n =- size; n < size; n += step)
67 { 65 {
68 double l; 66 double l;
69 for (l = 0.0 - area; l < area; l += step) 67 for (l = -size; l < size; l += step)
70 { 68 {
71 avgsteps++; 69 avgsteps++;
72 average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map); 70 average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map);
@@ -84,13 +82,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
84 if (!mask[x, y]) 82 if (!mask[x, y])
85 continue; 83 continue;
86 84
87 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 85 float distancefactor = TerrainUtil.SphericalFactor(x - rx, y - ry, size);
88 86
89 if (z > 0) // add in non-zero amount 87 if (distancefactor > 0) // add in non-zero amount
90 { 88 {
91 double da = z; 89 double a = (map[x, y] - tweak[x, y]) * distancefactor;
92 double a = (map[x, y] - tweak[x, y]) * da; 90 double newz = map[x, y] - (a * strengh);
93 double newz = map[x, y] - (a * duration);
94 91
95 if (newz > 0.0) 92 if (newz > 0.0)
96 map[x, y] = newz; 93 map[x, y] = newz;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs
deleted file mode 100644
index f52fe07..0000000
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs
+++ /dev/null
@@ -1,211 +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 OpenSimulator 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.Framework.Interfaces;
29using OpenSim.Region.Framework.Scenes;
30
31namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
32{
33 /// <summary>
34 /// Thermal Weathering Paint Brush
35 /// </summary>
36 public class WeatherSphere : ITerrainPaintableEffect
37 {
38 private const double talus = 0.2;
39 private const NeighbourSystem type = NeighbourSystem.Moore;
40
41 #region Supporting Functions
42
43 private static int[] Neighbours(NeighbourSystem neighbourType, int index)
44 {
45 int[] coord = new int[2];
46
47 index++;
48
49 switch (neighbourType)
50 {
51 case NeighbourSystem.Moore:
52 switch (index)
53 {
54 case 1:
55 coord[0] = -1;
56 coord[1] = -1;
57 break;
58
59 case 2:
60 coord[0] = -0;
61 coord[1] = -1;
62 break;
63
64 case 3:
65 coord[0] = +1;
66 coord[1] = -1;
67 break;
68
69 case 4:
70 coord[0] = -1;
71 coord[1] = -0;
72 break;
73
74 case 5:
75 coord[0] = -0;
76 coord[1] = -0;
77 break;
78
79 case 6:
80 coord[0] = +1;
81 coord[1] = -0;
82 break;
83
84 case 7:
85 coord[0] = -1;
86 coord[1] = +1;
87 break;
88
89 case 8:
90 coord[0] = -0;
91 coord[1] = +1;
92 break;
93
94 case 9:
95 coord[0] = +1;
96 coord[1] = +1;
97 break;
98
99 default:
100 break;
101 }
102 break;
103
104 case NeighbourSystem.VonNeumann:
105 switch (index)
106 {
107 case 1:
108 coord[0] = 0;
109 coord[1] = -1;
110 break;
111
112 case 2:
113 coord[0] = -1;
114 coord[1] = 0;
115 break;
116
117 case 3:
118 coord[0] = +1;
119 coord[1] = 0;
120 break;
121
122 case 4:
123 coord[0] = 0;
124 coord[1] = +1;
125 break;
126
127 case 5:
128 coord[0] = -0;
129 coord[1] = -0;
130 break;
131
132 default:
133 break;
134 }
135 break;
136 }
137
138 return coord;
139 }
140
141 private enum NeighbourSystem
142 {
143 Moore,
144 VonNeumann
145 } ;
146
147 #endregion
148
149 #region ITerrainPaintableEffect Members
150
151 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
152 double strength, double duration, int startX, int endX, int startY, int endY)
153 {
154 strength = TerrainUtil.MetersToSphericalStrength(strength);
155
156 int x,y;
157
158 for (x = startX; x <= endX; x++)
159 {
160 for (y = startY; y <= endY; y++)
161 {
162 if (!mask[x,y])
163 continue;
164
165 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
166
167 if (z > 0) // add in non-zero amount
168 {
169 const int NEIGHBOUR_ME = 4;
170 const int NEIGHBOUR_MAX = 9;
171
172 for (int j = 0; j < NEIGHBOUR_MAX; j++)
173 {
174 if (j != NEIGHBOUR_ME)
175 {
176 int[] coords = Neighbours(type, j);
177
178 coords[0] += x;
179 coords[1] += y;
180
181 if (coords[0] > map.Width - 1)
182 continue;
183 if (coords[1] > map.Height - 1)
184 continue;
185 if (coords[0] < 0)
186 continue;
187 if (coords[1] < 0)
188 continue;
189
190 double heightF = map[x, y];
191 double target = map[coords[0], coords[1]];
192
193 if (target > heightF + talus)
194 {
195 double calc = duration * ((target - heightF) - talus) * z;
196 heightF += calc;
197 target -= calc;
198 }
199
200 map[x, y] = heightF;
201 map[coords[0], coords[1]] = target;
202 }
203 }
204 }
205 }
206 }
207 }
208
209 #endregion
210 }
211}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index e00fafb..a73de46 100755
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -65,11 +65,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
65 Smooth = 3, 65 Smooth = 3,
66 Noise = 4, 66 Noise = 4,
67 Revert = 5, 67 Revert = 5,
68
69 // Extended brushes
70 Erode = 255,
71 Weather = 254,
72 Olsen = 253
73 } 68 }
74 69
75 #endregion 70 #endregion
@@ -81,13 +76,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
81#pragma warning restore 414 76#pragma warning restore 414
82 77
83 private readonly Commander m_commander = new Commander("terrain"); 78 private readonly Commander m_commander = new Commander("terrain");
79 private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
84 private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects = 80 private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects =
85 new Dictionary<StandardTerrainEffects, ITerrainFloodEffect>(); 81 new Dictionary<StandardTerrainEffects, ITerrainFloodEffect>();
86 private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
87 private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = 82 private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =
88 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); 83 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
89 private Dictionary<string, ITerrainModifier> m_modifyOperations = 84 private Dictionary<string, ITerrainModifier> m_modifyOperations = new Dictionary<string, ITerrainModifier>();
90 new Dictionary<string, ITerrainModifier>();
91 private Dictionary<string, ITerrainEffect> m_plugineffects; 85 private Dictionary<string, ITerrainEffect> m_plugineffects;
92 private ITerrainChannel m_channel; 86 private ITerrainChannel m_channel;
93 private ITerrainChannel m_baked; 87 private ITerrainChannel m_baked;
@@ -520,13 +514,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain
520 /// <param name="size">The size of the brush (0=small, 1=medium, 2=large)</param> 514 /// <param name="size">The size of the brush (0=small, 1=medium, 2=large)</param>
521 /// <param name="action">0=LAND_LEVEL, 1=LAND_RAISE, 2=LAND_LOWER, 3=LAND_SMOOTH, 4=LAND_NOISE, 5=LAND_REVERT</param> 515 /// <param name="action">0=LAND_LEVEL, 1=LAND_RAISE, 2=LAND_LOWER, 3=LAND_SMOOTH, 4=LAND_NOISE, 5=LAND_REVERT</param>
522 /// <param name="agentId">UUID of script-owner</param> 516 /// <param name="agentId">UUID of script-owner</param>
523 public void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId) 517 public void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action)
524 { 518 {
525 float duration = 0.25f; 519 float duration = 0.25f;
526 if (action == 0) 520 float brushSize = size + 1;
527 duration = 4.0f; 521 if (brushSize > 2)
522 brushSize = 4;
528 523
529 client_OnModifyTerrain(user, (float)pos.Z, duration, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId); 524 client_OnModifyTerrain(user, pos.Z, duration, brushSize, action, pos.Y, pos.X, pos.Y, pos.X);
530 } 525 }
531 526
532 /// <summary> 527 /// <summary>
@@ -686,9 +681,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
686 m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere(); 681 m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere();
687 m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere(); 682 m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere();
688 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked); 683 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked);
689 m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere();
690 m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere();
691 m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere();
692 684
693 // Area of effect selection effects 685 // Area of effect selection effects
694 m_floodeffects[StandardTerrainEffects.Raise] = new RaiseArea(); 686 m_floodeffects[StandardTerrainEffects.Raise] = new RaiseArea();
@@ -1310,9 +1302,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1310 return ret; 1302 return ret;
1311 } 1303 }
1312 1304
1313 private void client_OnModifyTerrain(UUID user, float height, float seconds, byte size, byte action, 1305 private void client_OnModifyTerrain(UUID user, float height, float seconds, float brushSize, byte action,
1314 float north, float west, float south, float east, UUID agentId) 1306 float north, float west, float south, float east)
1315 { 1307 {
1308 m_log.DebugFormat("brushs {0} seconds {1} height {2}", brushSize, seconds, height);
1316 bool god = m_scene.Permissions.IsGod(user); 1309 bool god = m_scene.Permissions.IsGod(user);
1317 bool allowed = false; 1310 bool allowed = false;
1318 if (north == south && east == west) 1311 if (north == south && east == west)
@@ -1321,25 +1314,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1321 { 1314 {
1322 bool[,] allowMask = new bool[m_channel.Width, m_channel.Height]; 1315 bool[,] allowMask = new bool[m_channel.Width, m_channel.Height];
1323 allowMask.Initialize(); 1316 allowMask.Initialize();
1324 int n = size + 1;
1325 if (n > 2)
1326 n = 4;
1327
1328 int zx = (int)(west + 0.5);
1329 int zy = (int)(north + 0.5);
1330 1317
1331 int startX = zx - n; 1318 int startX = (int)(west - brushSize + 0.5);
1332 if (startX < 0) 1319 if (startX < 0)
1333 startX = 0; 1320 startX = 0;
1334 1321
1335 int startY = zy - n; 1322 int startY = (int)(north - brushSize + 0.5);
1336 if (startY < 0) 1323 if (startY < 0)
1337 startY = 0; 1324 startY = 0;
1338 1325
1339 int endX = zx + n; 1326 int endX = (int)(west + brushSize + 0.5);
1340 if (endX >= m_channel.Width) 1327 if (endX >= m_channel.Width)
1341 endX = m_channel.Width - 1; 1328 endX = m_channel.Width - 1;
1342 int endY = zy + n; 1329 int endY = (int)(north + brushSize + 0.5);
1343 if (endY >= m_channel.Height) 1330 if (endY >= m_channel.Height)
1344 endY = m_channel.Height - 1; 1331 endY = m_channel.Height - 1;
1345 1332
@@ -1349,7 +1336,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1349 { 1336 {
1350 for (y = startY; y <= endY; y++) 1337 for (y = startY; y <= endY; y++)
1351 { 1338 {
1352 if (m_scene.Permissions.CanTerraformLand(agentId, new Vector3(x, y, 0))) 1339 if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, 0)))
1353 { 1340 {
1354 allowMask[x, y] = true; 1341 allowMask[x, y] = true;
1355 allowed = true; 1342 allowed = true;
@@ -1360,7 +1347,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1360 { 1347 {
1361 StoreUndoState(); 1348 StoreUndoState();
1362 m_painteffects[(StandardTerrainEffects) action].PaintEffect( 1349 m_painteffects[(StandardTerrainEffects) action].PaintEffect(
1363 m_channel, allowMask, west, south, height, size, seconds, 1350 m_channel, allowMask, west, south, height, brushSize, seconds,
1364 startX, endX, startY, endY); 1351 startX, endX, startY, endY);
1365 1352
1366 //block changes outside estate limits 1353 //block changes outside estate limits
@@ -1412,7 +1399,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1412 { 1399 {
1413 for (y = startY; y <= endY; y++) 1400 for (y = startY; y <= endY; y++)
1414 { 1401 {
1415 if (m_scene.Permissions.CanTerraformLand(agentId, new Vector3(x, y, 0))) 1402 if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, 0)))
1416 { 1403 {
1417 fillArea[x, y] = true; 1404 fillArea[x, y] = true;
1418 allowed = true; 1405 allowed = true;
@@ -1423,7 +1410,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1423 if (allowed) 1410 if (allowed)
1424 { 1411 {
1425 StoreUndoState(); 1412 StoreUndoState();
1426 m_floodeffects[(StandardTerrainEffects)action].FloodEffect(m_channel, fillArea, size, 1413 m_floodeffects[(StandardTerrainEffects)action].FloodEffect(m_channel, fillArea, height, seconds,
1427 startX, endX, startY, endY); 1414 startX, endX, startY, endY);
1428 1415
1429 //block changes outside estate limits 1416 //block changes outside estate limits
@@ -1707,20 +1694,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1707 MainConsole.Instance.Output("max/min/avg/sum: {0}/{1}/{2}/{3}", max, min, avg, sum); 1694 MainConsole.Instance.Output("max/min/avg/sum: {0}/{1}/{2}/{3}", max, min, avg, sum);
1708 } 1695 }
1709 1696
1710 private void InterfaceEnableExperimentalBrushes(Object[] args)
1711 {
1712 if ((bool)args[0])
1713 {
1714 m_painteffects[StandardTerrainEffects.Revert] = new WeatherSphere();
1715 m_painteffects[StandardTerrainEffects.Flatten] = new OlsenSphere();
1716 m_painteffects[StandardTerrainEffects.Smooth] = new ErodeSphere();
1717 }
1718 else
1719 {
1720 InstallDefaultEffects();
1721 }
1722 }
1723
1724 private void InterfaceRunPluginEffect(Object[] args) 1697 private void InterfaceRunPluginEffect(Object[] args)
1725 { 1698 {
1726 string firstArg = (string)args[0]; 1699 string firstArg = (string)args[0];
@@ -1841,12 +1814,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1841 "Shows terrain height at a given co-ordinate."); 1814 "Shows terrain height at a given co-ordinate.");
1842 showCommand.AddArgument("point", "point in <x>,<y> format with no spaces (e.g. 45,45)", "String"); 1815 showCommand.AddArgument("point", "point in <x>,<y> format with no spaces (e.g. 45,45)", "String");
1843 1816
1844 Command experimentalBrushesCommand = 1817 // Plugins
1845 new Command("newbrushes", CommandIntentions.COMMAND_HAZARDOUS, InterfaceEnableExperimentalBrushes,
1846 "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time.");
1847 experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean");
1848
1849 // Plugins
1850 Command pluginRunCommand = 1818 Command pluginRunCommand =
1851 new Command("effect", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRunPluginEffect, "Runs a specified plugin effect"); 1819 new Command("effect", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRunPluginEffect, "Runs a specified plugin effect");
1852 pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String"); 1820 pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String");
@@ -1861,7 +1829,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1861 m_commander.RegisterCommand("multiply", multiplyCommand); 1829 m_commander.RegisterCommand("multiply", multiplyCommand);
1862 m_commander.RegisterCommand("bake", bakeRegionCommand); 1830 m_commander.RegisterCommand("bake", bakeRegionCommand);
1863 m_commander.RegisterCommand("revert", revertRegionCommand); 1831 m_commander.RegisterCommand("revert", revertRegionCommand);
1864 m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand);
1865 m_commander.RegisterCommand("show", showCommand); 1832 m_commander.RegisterCommand("show", showCommand);
1866 m_commander.RegisterCommand("stats", showDebugStatsCommand); 1833 m_commander.RegisterCommand("stats", showDebugStatsCommand);
1867 m_commander.RegisterCommand("effect", pluginRunCommand); 1834 m_commander.RegisterCommand("effect", pluginRunCommand);
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
index 8e77962..3edef3a 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
60 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); 60 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
61 ITerrainPaintableEffect effect = new RaiseSphere(); 61 ITerrainPaintableEffect effect = new RaiseSphere();
62 62
63 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0, 63 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0f, 2, 6.0f,
64 0, midRegion - 1,0, (int)Constants.RegionSize -1); 64 0, midRegion - 1,0, (int)Constants.RegionSize -1);
65 Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128)."); 65 Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
66 Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128)."); 66 Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
@@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
80 } 80 }
81 effect = new LowerSphere(); 81 effect = new LowerSphere();
82 82
83 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0, 83 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0f, 2, 6.0f,
84 0, (int)Constants.RegionSize -1,0, (int)Constants.RegionSize -1); 84 0, (int)Constants.RegionSize -1,0, (int)Constants.RegionSize -1);
85 Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); 85 Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
86 Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128)."); 86 Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
index 0fe681f..412c86e 100644
--- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
@@ -53,7 +53,8 @@ namespace OpenSim.Region.Framework.Interfaces
53 /// All add and remove attachment operations must synchronize on this for the lifetime of their operations. 53 /// All add and remove attachment operations must synchronize on this for the lifetime of their operations.
54 /// </remarks> 54 /// </remarks>
55 Object AttachmentsSyncLock { get; } 55 Object AttachmentsSyncLock { get; }
56 56 int MaxNumberAttachments { get; }
57 int GetAttachmentsCount();
57 /// <summary> 58 /// <summary>
58 /// The scene objects attached to this avatar. 59 /// The scene objects attached to this avatar.
59 /// </summary> 60 /// </summary>
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs
index 3fc5ce7..6b1ef1b 100644
--- a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces
35 { 35 {
36 void LoadFromFile(string filename); 36 void LoadFromFile(string filename);
37 void SaveToFile(string filename); 37 void SaveToFile(string filename);
38 void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId); 38 void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action);
39 39
40 /// <summary> 40 /// <summary>
41 /// Taint the terrain. This will lead to sending the terrain data to the clients again. 41 /// Taint the terrain. This will lead to sending the terrain data to the clients again.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 03f46bb..ff1e922 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2963,7 +2963,6 @@ namespace OpenSim.Region.Framework.Scenes
2963 if (sceneObject.IsAttachmentCheckFull()) // Attachment 2963 if (sceneObject.IsAttachmentCheckFull()) // Attachment
2964 { 2964 {
2965 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); 2965 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
2966// sceneObject.RootPart.AddFlag(PrimFlags.Phantom);
2967 2966
2968 // Don't sent a full update here because this will cause full updates to be sent twice for 2967 // Don't sent a full update here because this will cause full updates to be sent twice for
2969 // attachments on region crossings, resulting in viewer glitches. 2968 // attachments on region crossings, resulting in viewer glitches.
@@ -2984,13 +2983,17 @@ namespace OpenSim.Region.Framework.Scenes
2984 // m_log.DebugFormat( 2983 // m_log.DebugFormat(
2985 // "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2984 // "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2986 2985
2987 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2988
2989 // We must currently not resume scripts at this stage since AttachmentsModule does not have the 2986 // We must currently not resume scripts at this stage since AttachmentsModule does not have the
2990 // information that this is due to a teleport/border cross rather than an ordinary attachment. 2987 // information that this is due to a teleport/border cross rather than an ordinary attachment.
2991 // We currently do this in Scene.MakeRootAgent() instead. 2988 // We currently do this in Scene.MakeRootAgent() instead.
2989 bool attached = false;
2992 if (AttachmentsModule != null) 2990 if (AttachmentsModule != null)
2993 AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); 2991 attached = AttachmentsModule.AttachObject(sp, grp, 0, false, false, true);
2992
2993 if (attached)
2994 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2995 else
2996 m_log.DebugFormat("[SCENE]: Attachment {0} arrived but failed to attach, setting to temp", sceneObject.UUID);
2994 } 2997 }
2995 else 2998 else
2996 { 2999 {
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
index 96d2dc4..28bbdda 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
@@ -538,19 +538,15 @@ namespace OpenSim.Region.Framework.Scenes
538 { 538 {
539 float cx = m_terrainData.SizeX * 0.5f; 539 float cx = m_terrainData.SizeX * 0.5f;
540 float cy = m_terrainData.SizeY * 0.5f; 540 float cy = m_terrainData.SizeY * 0.5f;
541 float h; 541 float h, b;
542 for (int x = 0; x < Width; x++) 542 for (int x = 0; x < Width; x++)
543 { 543 {
544 for (int y = 0; y < Height; y++) 544 for (int y = 0; y < Height; y++)
545 { 545 {
546 // h = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; 546 h = 25 * TerrainUtil.SphericalFactor(x - cx, y - cy, 50);
547 h = 1.0f; 547 b = 10 * TerrainUtil.SphericalFactor(x - cx, y - cy, 100);
548 float spherFacA = (float)(TerrainUtil.SphericalFactor(x, y, cx, cy, 50) * 0.01d); 548 if (h < b)
549 float spherFacB = (float)(TerrainUtil.SphericalFactor(x, y, cx, cy, 100) * 0.001d); 549 h = b;
550 if (h < spherFacA)
551 h = spherFacA;
552 if (h < spherFacB)
553 h = spherFacB;
554 m_terrainData[x, y] = h; 550 m_terrainData[x, y] = h;
555 } 551 }
556 } 552 }
diff --git a/OpenSim/Region/Framework/Scenes/TerrainUtil.cs b/OpenSim/Region/Framework/Scenes/TerrainUtil.cs
index 7f76e01..4569c9b 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainUtil.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainUtil.cs
@@ -32,15 +32,12 @@ namespace OpenSim.Region.Framework.Scenes
32{ 32{
33 public static class TerrainUtil 33 public static class TerrainUtil
34 { 34 {
35 public static double MetersToSphericalStrength(double size) 35 public static float SphericalFactor(float dx, float dy, float size)
36 { 36 {
37 //return Math.Pow(2, size); 37 float a = ((dx * dx) + (dy * dy))/ (size * size);
38 return (size + 1) * 1.35; // MCP: a more useful brush size range 38 if( a >= 1.0f)
39 } 39 return 0;
40 40 return 1.0f - a;
41 public static double SphericalFactor(double x, double y, double rx, double ry, double size)
42 {
43 return size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry));
44 } 41 }
45 42
46 public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) 43 public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map)