terraforming changes: support selected parcel edit; fix area smooth

0.9.1.1
UbitUmarov 2019-11-10 02:48:54 +00:00
parent f6ea22647d
commit b4d9f7ffe8
6 changed files with 68 additions and 26 deletions

View File

@ -61,7 +61,7 @@ namespace OpenSim.Framework
IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent); IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent);
public delegate void ModifyTerrain(UUID user, float height, float seconds, float brushSize, 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); public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);

View File

@ -8990,7 +8990,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OnModifyTerrain?.Invoke(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, OnModifyTerrain?.Invoke(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
modify.ModifyBlockExtended[i].BrushSize, modify.ModifyBlock.Action, modify.ModifyBlockExtended[i].BrushSize, modify.ModifyBlock.Action,
modify.ParcelData[i].North, modify.ParcelData[i].West, 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; return true;

View File

@ -2073,20 +2073,28 @@ namespace OpenSim.Region.CoreModules.World.Permissions
float X = position.X; float X = position.X;
float Y = position.Y; float Y = position.Y;
int id = (int)position.Z;
ILandObject parcel;
if (X > ((int)m_scene.RegionInfo.RegionSizeX - 1)) if(id >= 0 && X < 0 && Y < 0)
X = ((int)m_scene.RegionInfo.RegionSizeX - 1); parcel = m_scene.LandChannel.GetLandObject(id);
if (Y > ((int)m_scene.RegionInfo.RegionSizeY - 1)) else
Y = ((int)m_scene.RegionInfo.RegionSizeY - 1); {
if (X < 0) if (X < 0)
X = 0; X = 0;
if (Y < 0) else if (X > ((int)m_scene.RegionInfo.RegionSizeX - 1))
Y = 0; 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) if (parcel == null)
return false; return false;
LandData landdata = parcel.LandData; LandData landdata = parcel.LandData;
if (landdata == null) if (landdata == null)
return false; return false;

View File

@ -40,6 +40,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
double step = 1; double step = 1;
strength *= 0.002f; strength *= 0.002f;
if(strength > 1.0f)
strength = 1.0f;
double[,] manipulate = new double[map.Width,map.Height]; double[,] manipulate = new double[map.Width,map.Height];
int x, y; int x, y;
@ -54,10 +56,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
int avgsteps = 0; int avgsteps = 0;
double n; double n;
for (n = 0.0 - area; n < area; n += step) for (n = -area; n < area; n += step)
{ {
double l; double l;
for (l = 0.0 - area; l < area; l += step) for (l = -area; l < area; l += step)
{ {
avgsteps++; avgsteps++;
average += GetBilinearInterpolate(x + n, y + l, map); average += GetBilinearInterpolate(x + n, y + l, map);
@ -74,7 +76,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
if (!fillArea[x, y]) if (!fillArea[x, y])
continue; continue;
map[x, y] = strength * manipulate[x, y]; map[x, y] = (1.0 - strength) * map[x, y] + strength * manipulate[x, y];
} }
} }
} }

View File

@ -521,7 +521,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
if (brushSize > 2) if (brushSize > 2)
brushSize = 4; 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);
} }
/// <summary> /// <summary>
@ -1303,9 +1303,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
} }
private void client_OnModifyTerrain(UUID user, float height, float seconds, float brushSize, byte action, 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 god = m_scene.Permissions.IsGod(user);
bool allowed = false; bool allowed = false;
if (north == south && east == west) if (north == south && east == west)
@ -1313,6 +1313,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
if (m_painteffects.ContainsKey((StandardTerrainEffects)action)) if (m_painteffects.ContainsKey((StandardTerrainEffects)action))
{ {
bool[,] allowMask = new bool[m_channel.Width, m_channel.Height]; bool[,] allowMask = new bool[m_channel.Width, m_channel.Height];
allowMask.Initialize(); allowMask.Initialize();
int startX = (int)(west - brushSize + 0.5); int startX = (int)(west - brushSize + 0.5);
@ -1336,7 +1337,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
{ {
for (y = startY; y <= endY; y++) 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; allowMask[x, y] = true;
allowed = true; allowed = true;
@ -1392,20 +1393,48 @@ namespace OpenSim.Region.CoreModules.World.Terrain
else if (endY >= m_channel.Height) else if (endY >= m_channel.Height)
endY = m_channel.Height - 1; endY = m_channel.Height - 1;
int x, y; int x, y;
if (parcelLocalID == -1)
for (x = startX; x <= endX; x++)
{ {
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; if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, -1)))
allowed = true; {
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) if (allowed)
{ {

View File

@ -844,6 +844,8 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
#region TERRAFORM LAND #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) public bool CanTerraformLand(UUID user, Vector3 pos)
{ {
TerraformLandHandler handler = OnTerraformLand; TerraformLandHandler handler = OnTerraformLand;