From b4d9f7ffe89f5995511c4abe75d54ec190dfd3e3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 10 Nov 2019 02:48:54 +0000 Subject: [PATCH] terraforming changes: support selected parcel edit; fix area smooth --- OpenSim/Framework/IClientAPI.cs | 2 +- .../ClientStack/Linden/UDP/LLClientView.cs | 3 +- .../World/Permissions/PermissionsModule.cs | 28 ++++++---- .../World/Terrain/FloodBrushes/SmoothArea.cs | 8 +-- .../World/Terrain/TerrainModule.cs | 51 +++++++++++++++---- .../Framework/Scenes/Scene.Permissions.cs | 2 + 6 files changed, 68 insertions(+), 26 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 2929207cfe..662e47046c 100755 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -61,7 +61,7 @@ namespace OpenSim.Framework IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent); public delegate void ModifyTerrain(UUID user, float height, float seconds, float brushSize, - byte action, float north, float west, float south, float east); + byte action, float north, float west, float south, float east, int parcelLocalID); public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index c8af1d1a43..c395890583 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -8990,7 +8990,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP OnModifyTerrain?.Invoke(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlockExtended[i].BrushSize, modify.ModifyBlock.Action, modify.ParcelData[i].North, modify.ParcelData[i].West, - modify.ParcelData[i].South, modify.ParcelData[i].East); + modify.ParcelData[i].South, modify.ParcelData[i].East, + modify.ParcelData[i].LocalID); } return true; diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 8069ce23e2..51bc63d633 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -2073,20 +2073,28 @@ namespace OpenSim.Region.CoreModules.World.Permissions float X = position.X; float Y = position.Y; + int id = (int)position.Z; + ILandObject parcel; - if (X > ((int)m_scene.RegionInfo.RegionSizeX - 1)) - X = ((int)m_scene.RegionInfo.RegionSizeX - 1); - if (Y > ((int)m_scene.RegionInfo.RegionSizeY - 1)) - Y = ((int)m_scene.RegionInfo.RegionSizeY - 1); - if (X < 0) - X = 0; - if (Y < 0) - Y = 0; + if(id >= 0 && X < 0 && Y < 0) + parcel = m_scene.LandChannel.GetLandObject(id); + else + { + if (X < 0) + X = 0; + else if (X > ((int)m_scene.RegionInfo.RegionSizeX - 1)) + X = ((int)m_scene.RegionInfo.RegionSizeX - 1); + if (Y < 0) + Y = 0; + else if (Y > ((int)m_scene.RegionInfo.RegionSizeY - 1)) + Y = ((int)m_scene.RegionInfo.RegionSizeY - 1); + + parcel = m_scene.LandChannel.GetLandObject(X, Y); + } - ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y); if (parcel == null) return false; - + LandData landdata = parcel.LandData; if (landdata == null) return false; diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs index 64ffd4d73c..e5e6f4df85 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs @@ -40,6 +40,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes double step = 1; strength *= 0.002f; + if(strength > 1.0f) + strength = 1.0f; double[,] manipulate = new double[map.Width,map.Height]; int x, y; @@ -54,10 +56,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes int avgsteps = 0; double n; - for (n = 0.0 - area; n < area; n += step) + for (n = -area; n < area; n += step) { double l; - for (l = 0.0 - area; l < area; l += step) + for (l = -area; l < area; l += step) { avgsteps++; average += GetBilinearInterpolate(x + n, y + l, map); @@ -74,7 +76,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes if (!fillArea[x, y]) continue; - map[x, y] = strength * manipulate[x, y]; + map[x, y] = (1.0 - strength) * map[x, y] + strength * manipulate[x, y]; } } } diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index a73de46612..52386d38c2 100755 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -521,7 +521,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain if (brushSize > 2) brushSize = 4; - client_OnModifyTerrain(user, pos.Z, duration, brushSize, action, pos.Y, pos.X, pos.Y, pos.X); + client_OnModifyTerrain(user, pos.Z, duration, brushSize, action, pos.Y, pos.X, pos.Y, pos.X, -1); } /// @@ -1303,9 +1303,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain } private void client_OnModifyTerrain(UUID user, float height, float seconds, float brushSize, byte action, - float north, float west, float south, float east) + float north, float west, float south, float east, int parcelLocalID) { - m_log.DebugFormat("brushs {0} seconds {1} height {2}", brushSize, seconds, height); + m_log.DebugFormat("brushs {0} seconds {1} height {2}, parcel {3}", brushSize, seconds, height, parcelLocalID); bool god = m_scene.Permissions.IsGod(user); bool allowed = false; if (north == south && east == west) @@ -1313,6 +1313,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain if (m_painteffects.ContainsKey((StandardTerrainEffects)action)) { bool[,] allowMask = new bool[m_channel.Width, m_channel.Height]; + allowMask.Initialize(); int startX = (int)(west - brushSize + 0.5); @@ -1336,7 +1337,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain { for (y = startY; y <= endY; y++) { - if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, 0))) + if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, -1))) { allowMask[x, y] = true; allowed = true; @@ -1392,20 +1393,48 @@ namespace OpenSim.Region.CoreModules.World.Terrain else if (endY >= m_channel.Height) endY = m_channel.Height - 1; - int x, y; - - for (x = startX; x <= endX; x++) + if (parcelLocalID == -1) { - for (y = startY; y <= endY; y++) + for (x = startX; x <= endX; x++) { - if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, 0))) + for (y = startY; y <= endY; y++) { - fillArea[x, y] = true; - allowed = true; + if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, -1))) + { + fillArea[x, y] = true; + allowed = true; + } } } } + else + { + if (!m_scene.Permissions.CanTerraformLand(user, new Vector3(-1, -1, parcelLocalID))) + return; + + ILandObject parcel = m_scene.LandChannel.GetLandObject(parcelLocalID); + if(parcel == null) + return; + bool [,] parcelmap = parcel.GetLandBitmap(); +//ugly + for (x = startX; x <= endX; x++) + { + int px = x >> 2; + y = startY; + while( y <= endY) + { + int py = y >> 2; + bool inp = parcelmap[px, py]; + fillArea[x, y++] = inp; + fillArea[x, y++] = inp; + fillArea[x, y++] = inp; + fillArea[x, y++] = inp; + } + } + + allowed = true; + } if (allowed) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index a75671e6fd..60fb095e24 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -844,6 +844,8 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region TERRAFORM LAND + // if pos.x < 0, pos.y <0 and pos.z >=0 pos.z is parcel localID + // id pos.z < 0 x a and y identify the parcel public bool CanTerraformLand(UUID user, Vector3 pos) { TerraformLandHandler handler = OnTerraformLand;