* New Terrain Module (disabled, search for 'usingTerrainModule = false' to reenable)

* *Much* faster terraforming (woot!)
* New "Brushes" design, so you can create custom terraforming brushes then apply those inplace of the standard tools. (ie an Erode Brush for example)
* New specialised "Flood Brushes" to do large area effects, ie, raise-area, now takes a bitmap rather than repeats the ordinary raise brush a thousand times.
* New modular file Load/Save systems -- write importers/exporters for multiple formats without having to hard code the whole thing in.
* Coming soon - effects system, ie the old Erosion functions, etc. for one-shot effects.
0.6.0-stable
Adam Frisby 2008-03-05 00:52:35 +00:00
parent 0926239541
commit f64611862a
10 changed files with 56 additions and 18 deletions

View File

@ -34,5 +34,6 @@ namespace OpenSim.Region.Environment.Interfaces
double this[int x, int y] { get; set; } double this[int x, int y] { get; set; }
int Width { get; } int Width { get; }
float[] GetFloatsSerialised(); float[] GetFloatsSerialised();
bool Tainted(int x, int y);
} }
} }

View File

@ -72,7 +72,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
#region ITerrainPaintableEffect Members #region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
{ {
int x, y; int x, y;
double[,] tweak = new double[map.Width, map.Height]; double[,] tweak = new double[map.Width, map.Height];
@ -106,7 +106,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{ {
for (y = 0; y < map.Height; y++) for (y = 0; y < map.Height; y++)
{ {
double z = SphericalFactor(x, y, rx, ry, strength); double z = SphericalFactor(x, y, rx, ry, strength) * duration;
if (z > 0) // add in non-zero amount if (z > 0) // add in non-zero amount
{ {

View File

@ -34,7 +34,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{ {
#region ITerrainPaintableEffect Members #region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
{ {
int x, y; int x, y;
for (x = 0; x < map.Width; x++) for (x = 0; x < map.Width; x++)
@ -55,7 +55,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
if (z > 0.0) if (z > 0.0)
map[x, y] -= z; map[x, y] -= z * duration;
} }
} }
} }

View File

@ -35,7 +35,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{ {
#region ITerrainPaintableEffect Members #region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
{ {
int x, y; int x, y;
for (x = 0; x < map.Width; x++) for (x = 0; x < map.Width; x++)
@ -63,7 +63,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
} }
if (z > 0.0) if (z > 0.0)
map[x, y] += (noise - 0.5) * z; map[x, y] += (noise - 0.5) * z * duration;
} }
} }
} }

View File

@ -34,7 +34,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{ {
#region ITerrainPaintableEffect Members #region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
{ {
int x, y; int x, y;
for (x = 0; x < map.Width; x++) for (x = 0; x < map.Width; x++)
@ -55,7 +55,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
if (z > 0.0) if (z > 0.0)
map[x, y] += z; map[x, y] += z * duration;
} }
} }
} }

View File

@ -72,7 +72,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
#region ITerrainPaintableEffect Members #region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength) public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
{ {
int x, y; int x, y;
double[,] tweak = new double[map.Width, map.Height]; double[,] tweak = new double[map.Width, map.Height];
@ -116,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{ {
double da = z; double da = z;
double a = (map[x, y] - tweak[x, y]) * da; double a = (map[x, y] - tweak[x, y]) * da;
double newz = map[x, y] - a; double newz = map[x, y] - (a * duration);
if (newz > 0.0) if (newz > 0.0)
map[x, y] = newz; map[x, y] = newz;

View File

@ -38,7 +38,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
{ {
public interface ITerrainPaintableEffect public interface ITerrainPaintableEffect
{ {
void PaintEffect(ITerrainChannel map, double x, double y, double strength); void PaintEffect(ITerrainChannel map, double x, double y, double strength, double duration);
} }
public interface ITerrainFloodEffect public interface ITerrainFloodEffect
@ -63,6 +63,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
public class TerrainChannel : ITerrainChannel public class TerrainChannel : ITerrainChannel
{ {
private double[,] map; private double[,] map;
private bool[,] taint;
public int Width public int Width
{ {
@ -103,29 +104,41 @@ namespace OpenSim.Region.Environment.Modules.Terrain
} }
set set
{ {
taint[x / 16, y / 16] = true;
map[x, y] = value; map[x, y] = value;
} }
} }
public bool Tainted(int x, int y)
{
return taint[x / 16, y / 16];
}
public TerrainChannel() public TerrainChannel()
{ {
map = new double[Constants.RegionSize, Constants.RegionSize]; map = new double[Constants.RegionSize, Constants.RegionSize];
taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16];
} }
public TerrainChannel(double[,] import) public TerrainChannel(double[,] import)
{ {
map = import; map = import;
taint = new bool[import.GetLength(0), import.GetLength(1)];
} }
public TerrainChannel(bool createMap) public TerrainChannel(bool createMap)
{ {
if (createMap) if (createMap)
{
map = new double[Constants.RegionSize, Constants.RegionSize]; map = new double[Constants.RegionSize, Constants.RegionSize];
taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16];
}
} }
public TerrainChannel(int w, int h) public TerrainChannel(int w, int h)
{ {
map = new double[w, h]; map = new double[w, h];
taint = new bool[w / 16, h / 16];
} }
} }
@ -246,7 +259,14 @@ namespace OpenSim.Region.Environment.Modules.Terrain
if (m_painteffects.ContainsKey((StandardTerrainEffects)action)) if (m_painteffects.ContainsKey((StandardTerrainEffects)action))
{ {
m_painteffects[(StandardTerrainEffects)action].PaintEffect( m_painteffects[(StandardTerrainEffects)action].PaintEffect(
m_channel, west, south, Math.Pow(size, 2.0)); m_channel, west, south, Math.Pow(size, 2.0), seconds);
bool usingTerrainModule = false;
if (usingTerrainModule)
{
remoteClient.SendLayerData(m_channel.GetFloatsSerialised());
}
} }
else else
{ {
@ -258,20 +278,32 @@ namespace OpenSim.Region.Environment.Modules.Terrain
if (m_floodeffects.ContainsKey((StandardTerrainEffects)action)) if (m_floodeffects.ContainsKey((StandardTerrainEffects)action))
{ {
bool[,] fillArea = new bool[m_channel.Width, m_channel.Height]; bool[,] fillArea = new bool[m_channel.Width, m_channel.Height];
fillArea.Initialize(); fillArea.Initialize();
int x, y; int x, y;
for (x = 0; x < m_channel.Width; x++) for (x = 0; x < m_channel.Width; x++)
{ {
for (y = 0; y < m_channel.Height; y++) for (y = 0; y < m_channel.Height; y++)
{ {
fillArea[x, y] = true; if (x < east && x > west)
{
if (y < south && y > north)
{
fillArea[x, y] = true;
}
}
} }
} }
m_floodeffects[(StandardTerrainEffects)action].FloodEffect( m_floodeffects[(StandardTerrainEffects)action].FloodEffect(
m_channel, fillArea, Math.Pow(size, 2.0)); m_channel, fillArea, Math.Pow(size, 2.0));
bool usingTerrainModule = false;
if (usingTerrainModule)
{
remoteClient.SendLayerData(m_channel.GetFloatsSerialised());
}
} }
else else
{ {

View File

@ -869,7 +869,7 @@ namespace OpenSim.Region.Environment.Scenes
public void SendTerrainUpdate(bool checkForTainted) public void SendTerrainUpdate(bool checkForTainted)
{ {
float[] terData = Terrain.GetHeights1D(); float[] terData = Heightmap.GetFloatsSerialised();
Broadcast(delegate(IClientAPI client) Broadcast(delegate(IClientAPI client)
{ {

View File

@ -112,7 +112,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="RemoteClient">Client to send to</param> /// <param name="RemoteClient">Client to send to</param>
public virtual void SendLayerData(IClientAPI RemoteClient) public virtual void SendLayerData(IClientAPI RemoteClient)
{ {
bool usingTerrainModule = true; bool usingTerrainModule = false;
if (usingTerrainModule) if (usingTerrainModule)
{ {

View File

@ -297,9 +297,14 @@ namespace OpenSim.Region.Terrain
{ {
for (int y = 0; y < 16; y++) for (int y = 0; y < 16; y++)
{ {
if (IsTainted(x*16, y*16)) if (IsTainted(x * 16, y * 16))
{ {
remoteUser.SendLayerData(x, y, GetHeights1D()); bool usingTerrainModule = false;
if (!usingTerrainModule)
{
remoteUser.SendLayerData(x, y, GetHeights1D());
}
} }
} }
} }