* Reimplementing Terrain as Region Modules

* New method involves interfaces for
** Terrain Paint Brushes (ie raise brush, lower brush, etc)
** Terrain Flood Brushes (ie raise area, lower area, etc)
** Terrain Effects (ie erosion, etc) [= W.I.P, not committed]
* Provided sample implementation for Raise Paint and Raise Area brushes.
0.6.0-stable
Adam Frisby 2008-02-26 14:51:13 +00:00
parent 9f5586890a
commit eae7be1e36
3 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Environment.Modules.Terrain;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
{
class RaiseArea : ITerrainFloodEffect
{
#region ITerrainFloodEffect Members
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
{
int x, y;
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
if (fillArea[x, y] == true)
{
map[x, y] += strength;
}
}
}
}
#endregion
}
}

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Environment.Modules.Terrain;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{
class RaiseSphere : ITerrainPaintableEffect
{
#region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
{
int x, y;
for (x = 0; x < map.Width; x++)
{
// Skip everything unlikely to be affected
if (Math.Abs(x - rx) > strength * 1.1)
continue;
for (y = 0; y < map.Height; y++)
{
// Skip everything unlikely to be affected
if (Math.Abs(y - ry) > strength * 1.1)
continue;
// Calculate a sphere and add it to the heighmap
double z = strength;
z *= z;
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
if (z > 0.0)
map[x, y] += z;
}
}
}
#endregion
}
}

View File

@ -39,6 +39,16 @@ using libsecondlife;
namespace OpenSim.Region.Environment.Modules.Terrain namespace OpenSim.Region.Environment.Modules.Terrain
{ {
public interface ITerrainPaintableEffect
{
void PaintEffect(ITerrainChannel map, double x, double y, double strength);
}
public interface ITerrainFloodEffect
{
void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength);
}
/// <summary> /// <summary>
/// A new version of the old Channel class, simplified /// A new version of the old Channel class, simplified
/// </summary> /// </summary>