aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCharles Krinke2008-10-06 00:46:27 +0000
committerCharles Krinke2008-10-06 00:46:27 +0000
commit4f6cdc08d65cbdd60591d08d71c1c7648a3032cd (patch)
treec124af14da43a3b6f15d8a96d8ed151cbfca05b5
parentPatch by Fly-Man, with modifications. Add more fields to DataSnapshot. (diff)
downloadopensim-SC-4f6cdc08d65cbdd60591d08d71c1c7648a3032cd.zip
opensim-SC-4f6cdc08d65cbdd60591d08d71c1c7648a3032cd.tar.gz
opensim-SC-4f6cdc08d65cbdd60591d08d71c1c7648a3032cd.tar.bz2
opensim-SC-4f6cdc08d65cbdd60591d08d71c1c7648a3032cd.tar.xz
Mantis#1207. Thank you, TGlion for a patch that addresses:
Implementation of llModifyLand() and There is a bug on permission-check of land-terraforming: x an y-coordinates are interchanged on function-call ExternalChecksCanTerraformLand. Correct: x is west, and y is north. 2) Missing check of "Other allow to terraform-flag" (Parcel.ParcelFlags.AllowTerraform)
-rw-r--r--OpenSim/Framework/IClientAPI.cs2
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs18
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs5
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs24
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs41
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs11
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs11
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs7
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs11
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs9
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs5
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs7
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs97
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs27
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs7
19 files changed, 178 insertions, 118 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index dbaa0a8..560c308 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Framework
61 61
62 public delegate void ModifyTerrain( 62 public delegate void ModifyTerrain(
63 float height, float seconds, byte size, byte action, float north, float west, float south, float east, 63 float height, float seconds, byte size, byte action, float north, float west, float south, float east,
64 IClientAPI remoteClient); 64 UUID agentId);
65 65
66 public delegate void SetAppearance(byte[] texture, List<byte> visualParamList); 66 public delegate void SetAppearance(byte[] texture, List<byte> visualParamList);
67 67
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 102b9c4..6402974 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4171,7 +4171,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4171 modify.ModifyBlock.BrushSize, 4171 modify.ModifyBlock.BrushSize,
4172 modify.ModifyBlock.Action, modify.ParcelData[i].North, 4172 modify.ModifyBlock.Action, modify.ParcelData[i].North,
4173 modify.ParcelData[i].West, modify.ParcelData[i].South, 4173 modify.ParcelData[i].West, modify.ParcelData[i].South,
4174 modify.ParcelData[i].East, this); 4174 modify.ParcelData[i].East, this.AgentId);
4175 } 4175 }
4176 } 4176 }
4177 } 4177 }
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
index 16743ea..abbf40e 100644
--- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
@@ -984,11 +984,9 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
984 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 984 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
985 if (m_bypassPermissions) return m_bypassPermissionsValue; 985 if (m_bypassPermissions) return m_bypassPermissionsValue;
986 986
987 bool permission = false;
988
989 // Estate override 987 // Estate override
990 if (GenericEstatePermission(user)) 988 if (GenericEstatePermission(user))
991 permission = true; 989 return true;
992 990
993 float X = position.X; 991 float X = position.X;
994 float Y = position.Y; 992 float Y = position.Y;
@@ -1002,13 +1000,19 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
1002 if (Y < 0) 1000 if (Y < 0)
1003 Y = 0; 1001 Y = 0;
1004 1002
1005 // Land owner can terraform too
1006 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y); 1003 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y);
1007 if (parcel != null && GenericParcelPermission(user, parcel)) 1004 if (parcel == null)
1008 permission = true; 1005 return false;
1009 1006
1007 // Others allowed to terraform?
1008 if ((parcel.landData.Flags & ((int)Parcel.ParcelFlags.AllowTerraform)) != 0)
1009 return true;
1010 1010
1011 return permission; 1011 // Land owner can terraform too
1012 if (parcel != null && GenericParcelPermission(user, parcel))
1013 return true;
1014
1015 return false;
1012 } 1016 }
1013 1017
1014 private bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene) 1018 private bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene)
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs
index 399287d..c5e99b5 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs
@@ -41,6 +41,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects
41 bool[,] cliffMask = new bool[map.Width,map.Height]; 41 bool[,] cliffMask = new bool[map.Width,map.Height];
42 bool[,] channelMask = new bool[map.Width,map.Height]; 42 bool[,] channelMask = new bool[map.Width,map.Height];
43 bool[,] smoothMask = new bool[map.Width,map.Height]; 43 bool[,] smoothMask = new bool[map.Width,map.Height];
44 bool[,] allowMask = new bool[map.Width,map.Height];
44 45
45 Console.WriteLine("S1"); 46 Console.WriteLine("S1");
46 47
@@ -52,6 +53,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects
52 { 53 {
53 Console.Write("."); 54 Console.Write(".");
54 smoothMask[x, y] = true; 55 smoothMask[x, y] = true;
56 allowMask[x,y] = true;
55 57
56 // Start underwater 58 // Start underwater
57 map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5; 59 map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5;
@@ -77,7 +79,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects
77 for (y = 0; y < map.Height; y++) 79 for (y = 0; y < map.Height; y++)
78 { 80 {
79 if (cliffMask[x, y]) 81 if (cliffMask[x, y])
80 eroder.PaintEffect(map, x, y, 4, 0.1); 82 eroder.PaintEffect(map, allowMask, x, y, -1, 4, 0.1);
81 } 83 }
82 } 84 }
83 85
@@ -119,4 +121,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects
119 } 121 }
120 } 122 }
121 } 123 }
122} \ No newline at end of file 124}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs
index beeff03..bc5dc72 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs
@@ -25,7 +25,9 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28
28using System.IO; 29using System.IO;
30using OpenMetaverse;
29 31
30namespace OpenSim.Region.Environment.Modules.World.Terrain 32namespace OpenSim.Region.Environment.Modules.World.Terrain
31{ 33{
@@ -33,7 +35,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
33 { 35 {
34 void LoadFromFile(string filename); 36 void LoadFromFile(string filename);
35 void SaveToFile(string filename); 37 void SaveToFile(string filename);
36 38 void ModifyTerrain(Vector3 pos, byte size, byte action, UUID agentId);
39
37 /// <summary> 40 /// <summary>
38 /// Load a terrain from a stream. 41 /// Load a terrain from a stream.
39 /// </summary> 42 /// </summary>
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs
index cf2e58a..e2a9cde 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs
@@ -31,6 +31,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
31{ 31{
32 public interface ITerrainPaintableEffect 32 public interface ITerrainPaintableEffect
33 { 33 {
34 void PaintEffect(ITerrainChannel map, double x, double y, double strength, double duration); 34 void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z, double strength, double duration);
35 } 35 }
36} \ No newline at end of file 36}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs
index dae4cf8..3fa3f8a 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs
@@ -150,7 +150,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
150 150
151 #region ITerrainPaintableEffect Members 151 #region ITerrainPaintableEffect Members
152 152
153 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 153 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
154 { 154 {
155 strength = TerrainUtil.MetersToSphericalStrength(strength); 155 strength = TerrainUtil.MetersToSphericalStrength(strength);
156 156
@@ -173,10 +173,13 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
173 { 173 {
174 for (y = 0; y < water.Height; y++) 174 for (y = 0; y < water.Height; y++)
175 { 175 {
176 const double solConst = (1.0 / rounds); 176 if (mask[x,y])
177 double sedDelta = water[x, y] * solConst; 177 {
178 map[x, y] -= sedDelta; 178 const double solConst = (1.0 / rounds);
179 sediment[x, y] += sedDelta; 179 double sedDelta = water[x, y] * solConst;
180 map[x, y] -= sedDelta;
181 sediment[x, y] += sedDelta;
182 }
180 } 183 }
181 } 184 }
182 185
@@ -292,8 +295,11 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
292 double sedimentDeposit = sediment[x, y] - waterCapacity; 295 double sedimentDeposit = sediment[x, y] - waterCapacity;
293 if (sedimentDeposit > 0) 296 if (sedimentDeposit > 0)
294 { 297 {
295 sediment[x, y] -= sedimentDeposit; 298 if (mask[x,y])
296 map[x, y] += sedimentDeposit; 299 {
300 sediment[x, y] -= sedimentDeposit;
301 map[x, y] += sedimentDeposit;
302 }
297 } 303 }
298 } 304 }
299 } 305 }
@@ -302,10 +308,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
302 // Deposit any remainder (should be minimal) 308 // Deposit any remainder (should be minimal)
303 for (x = 0; x < water.Width; x++) 309 for (x = 0; x < water.Width; x++)
304 for (y = 0; y < water.Height; y++) 310 for (y = 0; y < water.Height; y++)
305 if (sediment[x, y] > 0) 311 if (mask[x,y] && sediment[x, y] > 0)
306 map[x, y] += sediment[x, y]; 312 map[x, y] += sediment[x, y];
307 } 313 }
308 314
309 #endregion 315 #endregion
310 } 316 }
311} \ No newline at end of file 317}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
index 1e2d611..e507481 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
@@ -25,48 +25,29 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
29 30
30namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes 31namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
31{ 32{
32 public class FlattenSphere : ITerrainPaintableEffect 33 public class FlattenSphere : ITerrainPaintableEffect
33 { 34 {
34
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
38 { 38 {
39 strength = TerrainUtil.MetersToSphericalStrength(strength); 39 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 40
41 int x, y; 41 int x, y;
42 42
43 double sum = 0.0;
44 double step2 = 0.0;
45 duration = 0.009; //MCP Should be read from ini file
46
47
48 // compute delta map
49 for (x = 0; x < map.Width; x++)
50 {
51 for (y = 0; y < map.Height; y++)
52 {
53 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
54
55 if (z > 0) // add in non-zero amount
56 {
57 sum += map[x, y] * z;
58 step2 += z;
59 }
60 }
61 }
62
63 double avg = sum / step2;
64
65 // blend in map 43 // blend in map
66 for (x = 0; x < map.Width; x++) 44 for (x = 0; x < map.Width; x++)
67 { 45 {
68 for (y = 0; y < map.Height; y++) 46 for (y = 0; y < map.Height; y++)
69 { 47 {
48 if (!mask[x,y])
49 continue;
50
70 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration; 51 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration;
71 52
72 if (z > 0) // add in non-zero amount 53 if (z > 0) // add in non-zero amount
@@ -74,8 +55,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
74 if (z > 1.0) 55 if (z > 1.0)
75 z = 1.0; 56 z = 1.0;
76 57
77 map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); 58 map[x, y] = (map[x, y] * (1.0 - z)) + (rz * z);
78 } 59 }
60
61 double delta = rz - map[x, y];
62 if (Math.Abs(delta) > 0.1)
63 delta *= 0.25;
64
65 if (delta != 0) // add in non-zero amount
66 {
67 map[x, y] += delta;
68 }
69
79 } 70 }
80 } 71 }
81 } 72 }
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
index 08b2879..fe82396 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
@@ -34,7 +34,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
34 { 34 {
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
38 { 38 {
39 strength = TerrainUtil.MetersToSphericalStrength(strength); 39 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 duration = 0.03; //MCP Should be read from ini file 40 duration = 0.03; //MCP Should be read from ini file
@@ -42,15 +42,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
42 int x; 42 int x;
43 for (x = 0; x < map.Width; x++) 43 for (x = 0; x < map.Width; x++)
44 { 44 {
45 // Skip everything unlikely to be affected
46 if (Math.Abs(x - rx) > strength * 1.1)
47 continue;
48
49 int y; 45 int y;
50 for (y = 0; y < map.Height; y++) 46 for (y = 0; y < map.Height; y++)
51 { 47 {
52 // Skip everything unlikely to be affected 48 if (!mask[x,y])
53 if (Math.Abs(y - ry) > strength * 1.1)
54 continue; 49 continue;
55 50
56 // Calculate a sphere and add it to the heighmap 51 // Calculate a sphere and add it to the heighmap
@@ -66,4 +61,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
66 61
67 #endregion 62 #endregion
68 } 63 }
69} \ No newline at end of file 64}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
index 0824efd..23f7bc5 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
@@ -35,22 +35,17 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
35 { 35 {
36 #region ITerrainPaintableEffect Members 36 #region ITerrainPaintableEffect Members
37 37
38 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
39 { 39 {
40 strength = TerrainUtil.MetersToSphericalStrength(strength); 40 strength = TerrainUtil.MetersToSphericalStrength(strength);
41 41
42 int x; 42 int x;
43 for (x = 0; x < map.Width; x++) 43 for (x = 0; x < map.Width; x++)
44 { 44 {
45 // Skip everything unlikely to be affected
46 if (Math.Abs(x - rx) > strength * 1.1)
47 continue;
48
49 int y; 45 int y;
50 for (y = 0; y < map.Height; y++) 46 for (y = 0; y < map.Height; y++)
51 { 47 {
52 // Skip everything unlikely to be affected 48 if (!mask[x,y])
53 if (Math.Abs(y - ry) > strength * 1.1)
54 continue; 49 continue;
55 50
56 // Calculate a sphere and add it to the heighmap 51 // Calculate a sphere and add it to the heighmap
@@ -68,4 +63,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
68 63
69 #endregion 64 #endregion
70 } 65 }
71} \ No newline at end of file 66}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
index 6df8408..42ec794 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
@@ -151,7 +151,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
151 151
152 #region ITerrainPaintableEffect Members 152 #region ITerrainPaintableEffect Members
153 153
154 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 154 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
155 { 155 {
156 strength = TerrainUtil.MetersToSphericalStrength(strength); 156 strength = TerrainUtil.MetersToSphericalStrength(strength);
157 157
@@ -162,6 +162,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
162 int y; 162 int y;
163 for (y = 0; y < map.Height; y++) 163 for (y = 0; y < map.Height; y++)
164 { 164 {
165 if (!mask[x,y])
166 continue;
167
165 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 168 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
166 169
167 if (z > 0) // add in non-zero amount 170 if (z > 0) // add in non-zero amount
@@ -216,4 +219,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
216 219
217 #endregion 220 #endregion
218 } 221 }
219} \ No newline at end of file 222}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
index e4fe091..92bac63 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 37
38 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
39 { 39 {
40 duration = 0.03; //MCP Should be read from ini file 40 duration = 0.03; //MCP Should be read from ini file
41 strength = TerrainUtil.MetersToSphericalStrength(strength); 41 strength = TerrainUtil.MetersToSphericalStrength(strength);
@@ -43,15 +43,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
43 int x; 43 int x;
44 for (x = 0; x < map.Width; x++) 44 for (x = 0; x < map.Width; x++)
45 { 45 {
46 // Skip everything unlikely to be affected
47 if (Math.Abs(x - rx) > strength * 1.1)
48 continue;
49
50 int y; 46 int y;
51 for (y = 0; y < map.Height; y++) 47 for (y = 0; y < map.Height; y++)
52 { 48 {
53 // Skip everything unlikely to be affected 49 if (!mask[x,y])
54 if (Math.Abs(y - ry) > strength * 1.1)
55 continue; 50 continue;
56 51
57 // Calculate a sphere and add it to the heighmap 52 // Calculate a sphere and add it to the heighmap
@@ -67,4 +62,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
67 62
68 #endregion 63 #endregion
69 } 64 }
70} \ No newline at end of file 65}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
index 7a1ec72..d3a1d3d 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
41 41
42 #region ITerrainPaintableEffect Members 42 #region ITerrainPaintableEffect Members
43 43
44 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 44 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
45 { 45 {
46 strength = TerrainUtil.MetersToSphericalStrength(strength); 46 strength = TerrainUtil.MetersToSphericalStrength(strength);
47 duration = 0.03; //MCP Should be read from ini file 47 duration = 0.03; //MCP Should be read from ini file
@@ -54,15 +54,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
54 int x; 54 int x;
55 for (x = 0; x < map.Width; x++) 55 for (x = 0; x < map.Width; x++)
56 { 56 {
57 // Skip everything unlikely to be affected
58 if (Math.Abs(x - rx) > strength * 1.1)
59 continue;
60
61 int y; 57 int y;
62 for (y = 0; y < map.Height; y++) 58 for (y = 0; y < map.Height; y++)
63 { 59 {
64 // Skip everything unlikely to be affected 60 if (!mask[x,y])
65 if (Math.Abs(y - ry) > strength * 1.1)
66 continue; 61 continue;
67 62
68 // Calculate a sphere and add it to the heighmap 63 // Calculate a sphere and add it to the heighmap
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs
index 89d9063..c63cb90 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
33 { 33 {
34 #region ITerrainPaintableEffect Members 34 #region ITerrainPaintableEffect Members
35 35
36 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 36 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
37 { 37 {
38 strength = TerrainUtil.MetersToSphericalStrength(strength); 38 strength = TerrainUtil.MetersToSphericalStrength(strength);
39 39
@@ -76,6 +76,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
76 { 76 {
77 for (y = 0; y < map.Height; y++) 77 for (y = 0; y < map.Height; y++)
78 { 78 {
79 if (!mask[x,y])
80 continue;
81
79 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 82 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
80 83
81 if (z > 0) // add in non-zero amount 84 if (z > 0) // add in non-zero amount
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs
index b3aa732..1288419 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs
@@ -147,7 +147,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
147 147
148 #region ITerrainPaintableEffect Members 148 #region ITerrainPaintableEffect Members
149 149
150 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 150 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
151 { 151 {
152 strength = TerrainUtil.MetersToSphericalStrength(strength); 152 strength = TerrainUtil.MetersToSphericalStrength(strength);
153 153
@@ -158,6 +158,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
158 int y; 158 int y;
159 for (y = 0; y < map.Height; y++) 159 for (y = 0; y < map.Height; y++)
160 { 160 {
161 if (!mask[x,y])
162 continue;
163
161 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 164 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
162 165
163 if (z > 0) // add in non-zero amount 166 if (z > 0) // add in non-zero amount
@@ -204,4 +207,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
204 207
205 #endregion 208 #endregion
206 } 209 }
207} \ No newline at end of file 210}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
index ed4075c..3b8debb 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
@@ -40,6 +40,7 @@ using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes;
40using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; 40using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
41using OpenSim.Region.Environment.Scenes; 41using OpenSim.Region.Environment.Scenes;
42 42
43
43namespace OpenSim.Region.Environment.Modules.World.Terrain 44namespace OpenSim.Region.Environment.Modules.World.Terrain
44{ 45{
45 public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule 46 public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule
@@ -259,6 +260,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
259 } 260 }
260 261
261 /// <summary> 262 /// <summary>
263 /// Modify Land
264 /// </summary>
265 /// <param name="pos">Land-position (X,Y,0)</param>
266 /// <param name="size">The size of the brush (0=small, 1=medium, 2=large)</param>
267 /// <param name="action">0=LAND_LEVEL, 1=LAND_RAISE, 2=LAND_LOWER, 3=LAND_SMOOTH, 4=LAND_NOISE, 5=LAND_REVERT</param>
268 /// <param name="agentId">UUID of script-owner</param>
269 public void ModifyTerrain(Vector3 pos, byte size, byte action, UUID agentId)
270 {
271 client_OnModifyTerrain((float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId);
272 }
273
274 /// <summary>
262 /// Saves the current heightmap to a specified stream. 275 /// Saves the current heightmap to a specified stream.
263 /// </summary> 276 /// </summary>
264 /// <param name="filename">The destination filename. Used here only to identify the image type</param> 277 /// <param name="filename">The destination filename. Used here only to identify the image type</param>
@@ -587,58 +600,92 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
587 ); 600 );
588 } 601 }
589 602
590 private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, 603 private void client_OnModifyTerrain(float height, float seconds, byte size, byte action,
591 float south, float east, IClientAPI remoteClient) 604 float north, float west, float south, float east, UUID agentId)
592 { 605 {
593 // Not a good permissions check, if in area mode, need to check the entire area. 606 bool allowed = false;
594 if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(remoteClient.AgentId, new Vector3(north, west, 0))) 607 if (north == south && east == west)
595 { 608 {
596 if (north == south && east == west) 609 if (m_painteffects.ContainsKey((StandardTerrainEffects) action))
597 { 610 {
598 if (m_painteffects.ContainsKey((StandardTerrainEffects) action)) 611 bool[,] allowMask = new bool[m_channel.Width,m_channel.Height];
612 allowMask.Initialize();
613 int n = size + 1;
614 if (n > 2)
615 n = 4;
616
617 int zx = (int) (west + 0.5);
618 int zy = (int) (north + 0.5);
619
620 int dx;
621 for (dx=-n; dx<=n; dx++)
622 {
623 int dy;
624 for (dy=-n; dy<=n; dy++)
625 {
626 int x = zx + dx;
627 int y = zy + dy;
628 if (x>=0 && y>=0 && x<m_channel.Width && y<m_channel.Height)
629 {
630 if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(agentId, new Vector3(x,y,0)))
631 {
632 allowMask[x, y] = true;
633 allowed = true;
634 }
635 }
636 }
637 }
638 if (allowed)
599 { 639 {
600 m_painteffects[(StandardTerrainEffects) action].PaintEffect( 640 m_painteffects[(StandardTerrainEffects) action].PaintEffect(
601 m_channel, west, south, size, seconds); 641 m_channel, allowMask, west, south, height, size, seconds);
602 642
603 CheckForTerrainUpdates(true); //revert changes outside estate limits 643 CheckForTerrainUpdates(true); //revert changes outside estate limits
604 } 644 }
605 else
606 {
607 m_log.Debug("Unknown terrain brush type " + action);
608 }
609 } 645 }
610 else 646 else
611 { 647 {
612 if (m_floodeffects.ContainsKey((StandardTerrainEffects) action)) 648 m_log.Debug("Unknown terrain brush type " + action);
613 { 649 }
614 bool[,] fillArea = new bool[m_channel.Width,m_channel.Height]; 650 }
615 fillArea.Initialize(); 651 else
652 {
653 if (m_floodeffects.ContainsKey((StandardTerrainEffects) action))
654 {
655 bool[,] fillArea = new bool[m_channel.Width,m_channel.Height];
656 fillArea.Initialize();
616 657
617 int x; 658 int x;
618 for (x = 0; x < m_channel.Width; x++) 659 for (x = 0; x < m_channel.Width; x++)
660 {
661 int y;
662 for (y = 0; y < m_channel.Height; y++)
619 { 663 {
620 int y; 664 if (x < east && x > west)
621 for (y = 0; y < m_channel.Height; y++)
622 { 665 {
623 if (x < east && x > west) 666 if (y < north && y > south)
624 { 667 {
625 if (y < north && y > south) 668 if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(agentId, new Vector3(x,y,0)))
626 { 669 {
627 fillArea[x, y] = true; 670 fillArea[x, y] = true;
671 allowed = true;
628 } 672 }
629 } 673 }
630 } 674 }
631 } 675 }
676 }
632 677
678 if (allowed)
679 {
633 m_floodeffects[(StandardTerrainEffects) action].FloodEffect( 680 m_floodeffects[(StandardTerrainEffects) action].FloodEffect(
634 m_channel, fillArea, size); 681 m_channel, fillArea, size);
635 682
636 CheckForTerrainUpdates(true); //revert changes outside estate limits 683 CheckForTerrainUpdates(true); //revert changes outside estate limits
637 } 684 }
638 else 685 }
639 { 686 else
640 m_log.Debug("Unknown terrain flood type " + action); 687 {
641 } 688 m_log.Debug("Unknown terrain flood type " + action);
642 } 689 }
643 } 690 }
644 } 691 }
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs
index eaa674e..71ea07d 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs
@@ -37,19 +37,30 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests
37 [Test] 37 [Test]
38 public void BrushTest() 38 public void BrushTest()
39 { 39 {
40 TerrainChannel x = new TerrainChannel(256, 256); 40 TerrainChannel map = new TerrainChannel(256, 256);
41 bool[,] allowMask = new bool[map.Width,map.Height];
42 int x;
43 int y;
44 for (x=0; x<map.Width; x++)
45 {
46 for (y=0; y<map.Height; y++)
47 {
48 allowMask[x,y] = true;
49 }
50 }
51
41 ITerrainPaintableEffect effect = new RaiseSphere(); 52 ITerrainPaintableEffect effect = new RaiseSphere();
42 53
43 effect.PaintEffect(x, 128.0, 128.0, 100, 0.1); 54 effect.PaintEffect(map, allowMask, 128.0, 128.0, 23.0, 50, 0.1);
44 Assert.That(x[128, 128] > 0.0, "Raise brush not raising values."); 55 Assert.That(map[128, 128] > 0.0, "Raise brush not raising values.");
45 Assert.That(x[0, 128] > 0.0, "Raise brush lowering edge values."); 56 Assert.That(map[0, 128] > 0.0, "Raise brush lowering edge values.");
46 57
47 x = new TerrainChannel(256, 256); 58 map = new TerrainChannel(256, 256);
48 effect = new LowerSphere(); 59 effect = new LowerSphere();
49 60
50 effect.PaintEffect(x, 128.0, 128.0, 100, 0.1); 61 effect.PaintEffect(map, allowMask, 128.0, 128.0, -1, 50, 0.1);
51 Assert.That(x[128, 128] < 0.0, "Lower not lowering values."); 62 Assert.That(map[128, 128] < 0.0, "Lower not lowering values.");
52 Assert.That(x[0, 128] < 0.0, "Lower brush affecting edge values."); 63 Assert.That(map[0, 128] < 0.0, "Lower brush affecting edge values.");
53 } 64 }
54 65
55 [Test] 66 [Test]
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 80c4259..8391fab 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -756,6 +756,7 @@ namespace OpenSim.Region.Environment.Scenes
756 set 756 set
757 { 757 {
758 StoreUndoState(); 758 StoreUndoState();
759if (m_shape != null) {
759 m_shape.Scale = value; 760 m_shape.Scale = value;
760 761
761 if (PhysActor != null && m_parentGroup != null) 762 if (PhysActor != null && m_parentGroup != null)
@@ -769,6 +770,7 @@ namespace OpenSim.Region.Environment.Scenes
769 } 770 }
770 } 771 }
771 } 772 }
773}
772 TriggerScriptChangedEvent(Changed.SCALE); 774 TriggerScriptChangedEvent(Changed.SCALE);
773 } 775 }
774 } 776 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fffc331..b7072a0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -42,6 +42,7 @@ using OpenSim.Region.Interfaces;
42using OpenSim.Region.Environment.Interfaces; 42using OpenSim.Region.Environment.Interfaces;
43using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; 43using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney;
44using OpenSim.Region.Environment.Modules.World.Land; 44using OpenSim.Region.Environment.Modules.World.Land;
45using OpenSim.Region.Environment.Modules.World.Terrain;
45using OpenSim.Region.Environment.Scenes; 46using OpenSim.Region.Environment.Scenes;
46using OpenSim.Region.Physics.Manager; 47using OpenSim.Region.Physics.Manager;
47using OpenSim.Region.ScriptEngine.Shared; 48using OpenSim.Region.ScriptEngine.Shared;
@@ -3368,7 +3369,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3368 public void llModifyLand(int action, int brush) 3369 public void llModifyLand(int action, int brush)
3369 { 3370 {
3370 m_host.AddScriptLPS(1); 3371 m_host.AddScriptLPS(1);
3371 World.ExternalChecks.ExternalChecksCanTerraformLand(m_host.OwnerID, new Vector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0)); 3372 ITerrainModule tm = m_ScriptEngine.World.RequestModuleInterface<ITerrainModule>();
3373 if (tm != null)
3374 {
3375 tm.ModifyTerrain(m_host.AbsolutePosition, (byte) brush, (byte) action, m_host.OwnerID);
3376 }
3372 } 3377 }
3373 3378
3374 public void llCollisionSound(string impact_sound, double impact_volume) 3379 public void llCollisionSound(string impact_sound, double impact_volume)