Thank you kindly, Tglion for a patch that:

Support of strength-slider in latest sl-client (1.21.6)
Added a patch, which includes the support of strength-slider 
in latest sl-client (1.21.6) for Raise- and LowerSphere.
0.6.0-stable
Charles Krinke 2008-10-25 14:07:35 +00:00
parent c49e1b8fb6
commit 4e14aa44c7
2 changed files with 51 additions and 20 deletions

View File

@ -36,29 +36,43 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
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)
{ {
strength = TerrainUtil.MetersToSphericalStrength(strength); int s = (int) (Math.Pow(2, strength) + 0.5);
duration = 0.03; //MCP Should be read from ini file
int x; int x;
for (x = 0; x < map.Width; x++) 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)
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; int y;
for (y = 0; y < map.Height; y++) for (y = yFrom; y <= yTo; y++)
{ {
if (!mask[x,y]) if (!mask[x,y])
continue; continue;
// Calculate a sphere and add it to the heighmap // Calculate a cos-sphere and add it to the heighmap
double z = strength; double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry)));
z *= z; double z = Math.Cos(r * Math.PI / (s * 2));
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
if (z > 0.0) if (z > 0.0)
map[x, y] -= z * duration; map[x, y] -= z * duration;
} }
} }
}
}
#endregion #endregion
} }
} }

View File

@ -26,34 +26,51 @@
*/ */
using System; using System;
using System.Reflection;
using log4net;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
{ {
public class RaiseSphere : ITerrainPaintableEffect public class RaiseSphere : ITerrainPaintableEffect
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#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)
{ {
duration = 0.03; //MCP Should be read from ini file int s = (int) (Math.Pow(2, strength) + 0.5);
strength = TerrainUtil.MetersToSphericalStrength(strength);
int x; int x;
for (x = 0; x < map.Width; x++) 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)
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; int y;
for (y = 0; y < map.Height; y++) for (y = yFrom; y <= yTo; y++)
{ {
if (!mask[x,y]) if (!mask[x,y])
continue; continue;
// Calculate a sphere and add it to the heighmap // Calculate a cos-sphere and add it to the heighmap
double z = strength; double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry)));
z *= z; double z = Math.Cos(r * Math.PI / (s * 2));
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
if (z > 0.0) if (z > 0.0)
map[x, y] += z * duration; map[x, y] += z * duration;
} }