From bd4ec5f26c8cc038e5155d6913e5a4601f724271 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 27 Aug 2015 22:36:14 +0100 Subject: restrict terrain PaintBrushes to the requested area --- .../CoreModules/World/Terrain/TerrainModule.cs | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs') diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index a5efeb8..7bae9ec 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -1128,20 +1128,32 @@ namespace OpenSim.Region.CoreModules.World.Terrain int zx = (int) (west + 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