From 4f6cdc08d65cbdd60591d08d71c1c7648a3032cd Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Mon, 6 Oct 2008 00:46:27 +0000 Subject: 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) --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 2 +- .../Modules/World/Permissions/PermissionsModule.cs | 18 ++-- .../Modules/World/Terrain/Effects/CookieCutter.cs | 6 +- .../Modules/World/Terrain/ITerrainModule.cs | 5 +- .../World/Terrain/ITerrainPaintableEffect.cs | 4 +- .../World/Terrain/PaintBrushes/ErodeSphere.cs | 24 ++++-- .../World/Terrain/PaintBrushes/FlattenSphere.cs | 41 ++++----- .../World/Terrain/PaintBrushes/LowerSphere.cs | 11 +-- .../World/Terrain/PaintBrushes/NoiseSphere.cs | 11 +-- .../World/Terrain/PaintBrushes/OlsenSphere.cs | 7 +- .../World/Terrain/PaintBrushes/RaiseSphere.cs | 11 +-- .../World/Terrain/PaintBrushes/RevertSphere.cs | 9 +- .../World/Terrain/PaintBrushes/SmoothSphere.cs | 5 +- .../World/Terrain/PaintBrushes/WeatherSphere.cs | 7 +- .../Modules/World/Terrain/TerrainModule.cs | 97 ++++++++++++++++------ .../Modules/World/Terrain/Tests/TerrainTest.cs | 27 ++++-- .../Region/Environment/Scenes/SceneObjectPart.cs | 2 + .../Shared/Api/Implementation/LSL_Api.cs | 7 +- 18 files changed, 177 insertions(+), 117 deletions(-) (limited to 'OpenSim/Region') 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 modify.ModifyBlock.BrushSize, modify.ModifyBlock.Action, modify.ParcelData[i].North, modify.ParcelData[i].West, modify.ParcelData[i].South, - modify.ParcelData[i].East, this); + modify.ParcelData[i].East, this.AgentId); } } } 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 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; - bool permission = false; - // Estate override if (GenericEstatePermission(user)) - permission = true; + return true; float X = position.X; float Y = position.Y; @@ -1002,13 +1000,19 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions if (Y < 0) Y = 0; - // Land owner can terraform too ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y); - if (parcel != null && GenericParcelPermission(user, parcel)) - permission = true; + if (parcel == null) + return false; + // Others allowed to terraform? + if ((parcel.landData.Flags & ((int)Parcel.ParcelFlags.AllowTerraform)) != 0) + return true; - return permission; + // Land owner can terraform too + if (parcel != null && GenericParcelPermission(user, parcel)) + return true; + + return false; } 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 bool[,] cliffMask = new bool[map.Width,map.Height]; bool[,] channelMask = new bool[map.Width,map.Height]; bool[,] smoothMask = new bool[map.Width,map.Height]; + bool[,] allowMask = new bool[map.Width,map.Height]; Console.WriteLine("S1"); @@ -52,6 +53,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects { Console.Write("."); smoothMask[x, y] = true; + allowMask[x,y] = true; // Start underwater map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5; @@ -77,7 +79,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects for (y = 0; y < map.Height; y++) { if (cliffMask[x, y]) - eroder.PaintEffect(map, x, y, 4, 0.1); + eroder.PaintEffect(map, allowMask, x, y, -1, 4, 0.1); } } @@ -119,4 +121,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects } } } -} \ No newline at end of file +} 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 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + using System.IO; +using OpenMetaverse; namespace OpenSim.Region.Environment.Modules.World.Terrain { @@ -33,7 +35,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain { void LoadFromFile(string filename); void SaveToFile(string filename); - + void ModifyTerrain(Vector3 pos, byte size, byte action, UUID agentId); + /// /// Load a terrain from a stream. /// 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 { public interface ITerrainPaintableEffect { - void PaintEffect(ITerrainChannel map, double x, double y, double strength, double duration); + void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z, double strength, double duration); } -} \ No newline at end of file +} 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 #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -173,10 +173,13 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes { for (y = 0; y < water.Height; y++) { - const double solConst = (1.0 / rounds); - double sedDelta = water[x, y] * solConst; - map[x, y] -= sedDelta; - sediment[x, y] += sedDelta; + if (mask[x,y]) + { + const double solConst = (1.0 / rounds); + double sedDelta = water[x, y] * solConst; + map[x, y] -= sedDelta; + sediment[x, y] += sedDelta; + } } } @@ -292,8 +295,11 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes double sedimentDeposit = sediment[x, y] - waterCapacity; if (sedimentDeposit > 0) { - sediment[x, y] -= sedimentDeposit; - map[x, y] += sedimentDeposit; + if (mask[x,y]) + { + sediment[x, y] -= sedimentDeposit; + map[x, y] += sedimentDeposit; + } } } } @@ -302,10 +308,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes // Deposit any remainder (should be minimal) for (x = 0; x < water.Width; x++) for (y = 0; y < water.Height; y++) - if (sediment[x, y] > 0) + if (mask[x,y] && sediment[x, y] > 0) map[x, y] += sediment[x, y]; } #endregion } -} \ No newline at end of file +} 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 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes { public class FlattenSphere : ITerrainPaintableEffect { - #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); int x, y; - double sum = 0.0; - double step2 = 0.0; - duration = 0.009; //MCP Should be read from ini file - - - // compute delta map - for (x = 0; x < map.Width; x++) - { - for (y = 0; y < map.Height; y++) - { - double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); - - if (z > 0) // add in non-zero amount - { - sum += map[x, y] * z; - step2 += z; - } - } - } - - double avg = sum / step2; - // blend in map for (x = 0; x < map.Width; x++) { for (y = 0; y < map.Height; y++) { + if (!mask[x,y]) + continue; + double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration; if (z > 0) // add in non-zero amount @@ -74,8 +55,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes if (z > 1.0) z = 1.0; - map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); + map[x, y] = (map[x, y] * (1.0 - z)) + (rz * z); } + + double delta = rz - map[x, y]; + if (Math.Abs(delta) > 0.1) + delta *= 0.25; + + if (delta != 0) // add in non-zero amount + { + map[x, y] += delta; + } + } } } 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 { #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); duration = 0.03; //MCP Should be read from ini file @@ -42,15 +42,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int x; for (x = 0; x < map.Width; x++) { - // Skip everything unlikely to be affected - if (Math.Abs(x - rx) > strength * 1.1) - continue; - int y; for (y = 0; y < map.Height; y++) { - // Skip everything unlikely to be affected - if (Math.Abs(y - ry) > strength * 1.1) + if (!mask[x,y]) continue; // Calculate a sphere and add it to the heighmap @@ -66,4 +61,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} 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 { #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); int x; for (x = 0; x < map.Width; x++) { - // Skip everything unlikely to be affected - if (Math.Abs(x - rx) > strength * 1.1) - continue; - int y; for (y = 0; y < map.Height; y++) { - // Skip everything unlikely to be affected - if (Math.Abs(y - ry) > strength * 1.1) + if (!mask[x,y]) continue; // Calculate a sphere and add it to the heighmap @@ -68,4 +63,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} 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 #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -162,6 +162,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int y; for (y = 0; y < map.Height; y++) { + if (!mask[x,y]) + continue; + double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); if (z > 0) // add in non-zero amount @@ -216,4 +219,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} 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 #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { duration = 0.03; //MCP Should be read from ini file strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -43,15 +43,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int x; for (x = 0; x < map.Width; x++) { - // Skip everything unlikely to be affected - if (Math.Abs(x - rx) > strength * 1.1) - continue; - int y; for (y = 0; y < map.Height; y++) { - // Skip everything unlikely to be affected - if (Math.Abs(y - ry) > strength * 1.1) + if (!mask[x,y]) continue; // Calculate a sphere and add it to the heighmap @@ -67,4 +62,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} 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 #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); duration = 0.03; //MCP Should be read from ini file @@ -54,15 +54,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int x; for (x = 0; x < map.Width; x++) { - // Skip everything unlikely to be affected - if (Math.Abs(x - rx) > strength * 1.1) - continue; - int y; for (y = 0; y < map.Height; y++) { - // Skip everything unlikely to be affected - if (Math.Abs(y - ry) > strength * 1.1) + if (!mask[x,y]) continue; // 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 { #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -76,6 +76,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes { for (y = 0; y < map.Height; y++) { + if (!mask[x,y]) + continue; + double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 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 #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -158,6 +158,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int y; for (y = 0; y < map.Height; y++) { + if (!mask[x,y]) + continue; + double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); if (z > 0) // add in non-zero amount @@ -204,4 +207,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} 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; using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules.World.Terrain { public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule @@ -259,6 +260,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain } /// + /// Modify Land + /// + /// Land-position (X,Y,0) + /// The size of the brush (0=small, 1=medium, 2=large) + /// 0=LAND_LEVEL, 1=LAND_RAISE, 2=LAND_LOWER, 3=LAND_SMOOTH, 4=LAND_NOISE, 5=LAND_REVERT + /// UUID of script-owner + public void ModifyTerrain(Vector3 pos, byte size, byte action, UUID agentId) + { + client_OnModifyTerrain((float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId); + } + + /// /// Saves the current heightmap to a specified stream. /// /// The destination filename. Used here only to identify the image type @@ -587,58 +600,92 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain ); } - private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, - float south, float east, IClientAPI remoteClient) + private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, + float north, float west, float south, float east, UUID agentId) { - // Not a good permissions check, if in area mode, need to check the entire area. - if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(remoteClient.AgentId, new Vector3(north, west, 0))) + bool allowed = false; + if (north == south && east == west) { - if (north == south && east == west) + if (m_painteffects.ContainsKey((StandardTerrainEffects) action)) { - if (m_painteffects.ContainsKey((StandardTerrainEffects) action)) + bool[,] allowMask = new bool[m_channel.Width,m_channel.Height]; + allowMask.Initialize(); + int n = size + 1; + if (n > 2) + n = 4; + + int zx = (int) (west + 0.5); + int zy = (int) (north + 0.5); + + int dx; + for (dx=-n; dx<=n; dx++) + { + int dy; + for (dy=-n; dy<=n; dy++) + { + int x = zx + dx; + int y = zy + dy; + if (x>=0 && y>=0 && x west) { - if (x < east && x > west) + if (y < north && y > south) { - if (y < north && y > south) + if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(agentId, new Vector3(x,y,0))) { fillArea[x, y] = true; + allowed = true; } } } } + } + if (allowed) + { m_floodeffects[(StandardTerrainEffects) action].FloodEffect( m_channel, fillArea, size); CheckForTerrainUpdates(true); //revert changes outside estate limits } - else - { - m_log.Debug("Unknown terrain flood type " + action); - } + } + else + { + m_log.Debug("Unknown terrain flood type " + action); } } } 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 [Test] public void BrushTest() { - TerrainChannel x = new TerrainChannel(256, 256); + TerrainChannel map = new TerrainChannel(256, 256); + bool[,] allowMask = new bool[map.Width,map.Height]; + int x; + int y; + for (x=0; x 0.0, "Raise brush not raising values."); - Assert.That(x[0, 128] > 0.0, "Raise brush lowering edge values."); + effect.PaintEffect(map, allowMask, 128.0, 128.0, 23.0, 50, 0.1); + Assert.That(map[128, 128] > 0.0, "Raise brush not raising values."); + Assert.That(map[0, 128] > 0.0, "Raise brush lowering edge values."); - x = new TerrainChannel(256, 256); + map = new TerrainChannel(256, 256); effect = new LowerSphere(); - effect.PaintEffect(x, 128.0, 128.0, 100, 0.1); - Assert.That(x[128, 128] < 0.0, "Lower not lowering values."); - Assert.That(x[0, 128] < 0.0, "Lower brush affecting edge values."); + effect.PaintEffect(map, allowMask, 128.0, 128.0, -1, 50, 0.1); + Assert.That(map[128, 128] < 0.0, "Lower not lowering values."); + Assert.That(map[0, 128] < 0.0, "Lower brush affecting edge values."); } [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 set { StoreUndoState(); +if (m_shape != null) { m_shape.Scale = value; if (PhysActor != null && m_parentGroup != null) @@ -769,6 +770,7 @@ namespace OpenSim.Region.Environment.Scenes } } } +} TriggerScriptChangedEvent(Changed.SCALE); } } 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; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; using OpenSim.Region.Environment.Modules.World.Land; +using OpenSim.Region.Environment.Modules.World.Terrain; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Physics.Manager; using OpenSim.Region.ScriptEngine.Shared; @@ -3368,7 +3369,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llModifyLand(int action, int brush) { m_host.AddScriptLPS(1); - World.ExternalChecks.ExternalChecksCanTerraformLand(m_host.OwnerID, new Vector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0)); + ITerrainModule tm = m_ScriptEngine.World.RequestModuleInterface(); + if (tm != null) + { + tm.ModifyTerrain(m_host.AbsolutePosition, (byte) brush, (byte) action, m_host.OwnerID); + } } public void llCollisionSound(string impact_sound, double impact_volume) -- cgit v1.1