restrict terrain PaintBrushes to the requested area
parent
f9efa23d5e
commit
bd4ec5f26c
|
@ -31,6 +31,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
{
|
{
|
||||||
public interface ITerrainPaintableEffect
|
public interface ITerrainPaintableEffect
|
||||||
{
|
{
|
||||||
void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z, double strength, double duration);
|
void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
|
|
||||||
#region ITerrainPaintableEffect Members
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
|
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY)
|
||||||
{
|
{
|
||||||
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
||||||
|
|
||||||
|
@ -163,16 +164,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height);
|
ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height);
|
||||||
|
|
||||||
// Fill with rain
|
// Fill with rain
|
||||||
for (x = 0; x < water.Width; x++)
|
for (x = startX; x <= endX; x++)
|
||||||
for (y = 0; y < water.Height; y++)
|
{
|
||||||
|
for (y = startY; y <= endY; y++)
|
||||||
|
{
|
||||||
|
if (mask[x, y])
|
||||||
water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration);
|
water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < rounds; i++)
|
for (int i = 0; i < rounds; i++)
|
||||||
{
|
{
|
||||||
// Erode underlying terrain
|
// Erode underlying terrain
|
||||||
for (x = 0; x < water.Width; x++)
|
for (x = startX; x <= endX; x++)
|
||||||
{
|
{
|
||||||
for (y = 0; y < water.Height; y++)
|
for (y = startY; y <= endY; y++)
|
||||||
{
|
{
|
||||||
if (mask[x, y])
|
if (mask[x, y])
|
||||||
{
|
{
|
||||||
|
@ -185,9 +191,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move water
|
// Move water
|
||||||
for (x = 0; x < water.Width; x++)
|
for (x = startX; x <= endX; x++)
|
||||||
{
|
{
|
||||||
for (y = 0; y < water.Height; y++)
|
for (y = startY; y <= endY; y++)
|
||||||
{
|
{
|
||||||
if (water[x, y] <= 0)
|
if (water[x, y] <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -312,7 +318,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
if (mask[x, y] && sediment[x, y] > 0)
|
if (mask[x, y] && sediment[x, y] > 0)
|
||||||
map[x, y] += sediment[x, y];
|
map[x, y] += sediment[x, y];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
{
|
{
|
||||||
#region ITerrainPaintableEffect Members
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
|
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY)
|
||||||
{
|
{
|
||||||
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
||||||
|
|
||||||
|
|
|
@ -34,32 +34,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
{
|
{
|
||||||
#region ITerrainPaintableEffect Members
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
|
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY)
|
||||||
{
|
{
|
||||||
int s = (int) (Math.Pow(2, strength) + 0.5);
|
int s = (int) (Math.Pow(2, strength) + 0.5);
|
||||||
|
|
||||||
int x;
|
int x, y;
|
||||||
int xFrom = (int)(rx-s+0.5);
|
|
||||||
int xTo = (int)(rx+s+0.5) + 1;
|
|
||||||
int yFrom = (int)(ry-s+0.5);
|
|
||||||
int yTo = (int)(ry+s+0.5) + 1;
|
|
||||||
|
|
||||||
if (xFrom < 0)
|
for (x = startX; x <= endX; x++)
|
||||||
xFrom = 0;
|
|
||||||
|
|
||||||
if (yFrom < 0)
|
|
||||||
yFrom = 0;
|
|
||||||
|
|
||||||
if (xTo > map.Width)
|
|
||||||
xTo = map.Width;
|
|
||||||
|
|
||||||
if (yTo > map.Width)
|
|
||||||
yTo = map.Width;
|
|
||||||
|
|
||||||
for (x = xFrom; x < xTo; x++)
|
|
||||||
{
|
{
|
||||||
int y;
|
for (y = startY; y <= endY; y++)
|
||||||
for (y = yFrom; y < yTo; y++)
|
|
||||||
{
|
{
|
||||||
if (!mask[x, y])
|
if (!mask[x, y])
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -35,15 +35,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
{
|
{
|
||||||
#region ITerrainPaintableEffect Members
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
|
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY)
|
||||||
{
|
{
|
||||||
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
||||||
|
|
||||||
int x;
|
int x, y;
|
||||||
for (x = 0; x < map.Width; x++)
|
|
||||||
|
for (x = startX; x <= endX; x++)
|
||||||
{
|
{
|
||||||
int y;
|
for (y = startY; y <= endY; y++)
|
||||||
for (y = 0; y < map.Height; y++)
|
|
||||||
{
|
{
|
||||||
if (!mask[x, y])
|
if (!mask[x, y])
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -152,16 +152,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
|
|
||||||
#region ITerrainPaintableEffect Members
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
|
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY)
|
||||||
{
|
{
|
||||||
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
||||||
|
|
||||||
int x;
|
int x, y;
|
||||||
|
|
||||||
for (x = 0; x < map.Width; x++)
|
for (x = startX; x <= endX; x++)
|
||||||
{
|
{
|
||||||
int y;
|
for (y = startY; y <= endY; y++)
|
||||||
for (y = 0; y < map.Height; y++)
|
|
||||||
{
|
{
|
||||||
if (!mask[x, y])
|
if (!mask[x, y])
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -35,32 +35,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
#region ITerrainPaintableEffect Members
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
|
|
||||||
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
|
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY)
|
||||||
{
|
{
|
||||||
int s = (int) (Math.Pow(2, strength) + 0.5);
|
int s = (int) (Math.Pow(2, strength) + 0.5);
|
||||||
|
|
||||||
int x;
|
int x,y;
|
||||||
int xFrom = (int)(rx-s+0.5);
|
|
||||||
int xTo = (int)(rx+s+0.5) + 1;
|
|
||||||
int yFrom = (int)(ry-s+0.5);
|
|
||||||
int yTo = (int)(ry+s+0.5) + 1;
|
|
||||||
|
|
||||||
if (xFrom < 0)
|
for (x = startX; x <= endX; x++)
|
||||||
xFrom = 0;
|
|
||||||
|
|
||||||
if (yFrom < 0)
|
|
||||||
yFrom = 0;
|
|
||||||
|
|
||||||
if (xTo > map.Width)
|
|
||||||
xTo = map.Width;
|
|
||||||
|
|
||||||
if (yTo > map.Width)
|
|
||||||
yTo = map.Width;
|
|
||||||
|
|
||||||
for (x = xFrom; x < xTo; x++)
|
|
||||||
{
|
{
|
||||||
int y;
|
for (y = startY; y <= endY; y++)
|
||||||
for (y = yFrom; y < yTo; y++)
|
|
||||||
{
|
{
|
||||||
if (!mask[x, y])
|
if (!mask[x, y])
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -41,7 +41,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
|
|
||||||
#region ITerrainPaintableEffect Members
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
|
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY)
|
||||||
{
|
{
|
||||||
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
||||||
duration = 0.03; //MCP Should be read from ini file
|
duration = 0.03; //MCP Should be read from ini file
|
||||||
|
@ -51,11 +52,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
if (duration < 0)
|
if (duration < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int x;
|
int x,y;
|
||||||
for (x = 0; x < map.Width; x++)
|
for (x = startX; x <= endX; x++)
|
||||||
{
|
{
|
||||||
int y;
|
for (y = startY; y < endY; y++)
|
||||||
for (y = 0; y < map.Height; y++)
|
|
||||||
{
|
{
|
||||||
if (!mask[x, y])
|
if (!mask[x, y])
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -34,7 +34,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
{
|
{
|
||||||
#region ITerrainPaintableEffect Members
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
|
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY)
|
||||||
{
|
{
|
||||||
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
||||||
|
|
||||||
|
@ -47,10 +48,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
|
|
||||||
|
|
||||||
// compute delta map
|
// compute delta map
|
||||||
for (x = 0; x < map.Width; x++)
|
for (x = startX; x <= endX; x++)
|
||||||
{
|
{
|
||||||
for (y = 0; y < map.Height; y++)
|
for (y = startY; y < endY; y++)
|
||||||
{
|
{
|
||||||
|
if (!mask[x, y])
|
||||||
|
continue;
|
||||||
|
|
||||||
double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
|
double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
|
||||||
|
|
||||||
if (z > 0) // add in non-zero amount
|
if (z > 0) // add in non-zero amount
|
||||||
|
@ -73,9 +77,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// blend in map
|
// blend in map
|
||||||
for (x = 0; x < map.Width; x++)
|
for (x = startX; x <= endX; x++)
|
||||||
{
|
{
|
||||||
for (y = 0; y < map.Height; y++)
|
for (y = startY; y < endY; y++)
|
||||||
{
|
{
|
||||||
if (!mask[x, y])
|
if (!mask[x, y])
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -148,16 +148,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
|
|
||||||
#region ITerrainPaintableEffect Members
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
|
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
|
||||||
|
double strength, double duration, int startX, int endX, int startY, int endY)
|
||||||
{
|
{
|
||||||
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
strength = TerrainUtil.MetersToSphericalStrength(strength);
|
||||||
|
|
||||||
int x;
|
int x,y;
|
||||||
|
|
||||||
for (x = 0; x < map.Width; x++)
|
for (x = startX; x <= endX; x++)
|
||||||
{
|
{
|
||||||
int y;
|
for (y = startY; y < endY; y++)
|
||||||
for (y = 0; y < map.Height; y++)
|
|
||||||
{
|
{
|
||||||
if (!mask[x,y])
|
if (!mask[x,y])
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1128,14 +1128,27 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
int zx = (int) (west + 0.5);
|
int zx = (int) (west + 0.5);
|
||||||
int zy = (int) (north + 0.5);
|
int zy = (int) (north + 0.5);
|
||||||
|
|
||||||
int dx,dy;
|
|
||||||
for (dx=-n; dx<=n; dx++)
|
int startX = zx - n;
|
||||||
|
if (startX < 0)
|
||||||
|
startX = 0;
|
||||||
|
|
||||||
|
int startY = zy - n;
|
||||||
|
if (startY < 0)
|
||||||
|
startY = 0;
|
||||||
|
|
||||||
|
int endX = zx + n;
|
||||||
|
if (endX >= m_channel.Width)
|
||||||
|
endX = m_channel.Width - 1;
|
||||||
|
int endY = zy + n;
|
||||||
|
if (endY >= m_channel.Height)
|
||||||
|
endY = m_channel.Height - 1;
|
||||||
|
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
for (x = startX; x <= endX; x++)
|
||||||
{
|
{
|
||||||
for (dy=-n; dy<=n; dy++)
|
for (y = startY; y <= endY; y++)
|
||||||
{
|
|
||||||
int x = zx + dx;
|
|
||||||
int y = zy + dy;
|
|
||||||
if (x>=0 && y>=0 && x<m_channel.Width && y<m_channel.Height)
|
|
||||||
{
|
{
|
||||||
if (m_scene.Permissions.CanTerraformLand(agentId, new Vector3(x, y, 0)))
|
if (m_scene.Permissions.CanTerraformLand(agentId, new Vector3(x, y, 0)))
|
||||||
{
|
{
|
||||||
|
@ -1144,12 +1157,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (allowed)
|
if (allowed)
|
||||||
{
|
{
|
||||||
StoreUndoState();
|
StoreUndoState();
|
||||||
m_painteffects[(StandardTerrainEffects) action].PaintEffect(
|
m_painteffects[(StandardTerrainEffects) action].PaintEffect(
|
||||||
m_channel, allowMask, west, south, height, size, seconds);
|
m_channel, allowMask, west, south, height, size, seconds,
|
||||||
|
startX, endX, startY, endY);
|
||||||
|
|
||||||
//block changes outside estate limits
|
//block changes outside estate limits
|
||||||
if (!god)
|
if (!god)
|
||||||
|
|
|
@ -60,7 +60,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
|
||||||
TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
|
TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
|
||||||
ITerrainPaintableEffect effect = new RaiseSphere();
|
ITerrainPaintableEffect effect = new RaiseSphere();
|
||||||
|
|
||||||
effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
|
effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0,
|
||||||
|
0, midRegion - 1,0, (int)Constants.RegionSize -1);
|
||||||
Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
|
Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
|
||||||
Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
|
Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
|
||||||
Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128).");
|
Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128).");
|
||||||
|
@ -79,7 +80,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
|
||||||
}
|
}
|
||||||
effect = new LowerSphere();
|
effect = new LowerSphere();
|
||||||
|
|
||||||
effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
|
effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0,
|
||||||
|
0, (int)Constants.RegionSize -1,0, (int)Constants.RegionSize -1);
|
||||||
Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
|
Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
|
||||||
Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
|
Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
|
||||||
Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128).");
|
Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128).");
|
||||||
|
|
Loading…
Reference in New Issue