* Implemented 'Revert' channel in Terrain Module.
* Added Revert Area, flood brush. * Added Revert Sphere, paint brush.0.6.0-stable
parent
3151e302ca
commit
8f6f85e530
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
|
||||||
|
{
|
||||||
|
public class RevertArea : ITerrainFloodEffect
|
||||||
|
{
|
||||||
|
ITerrainChannel m_revertmap;
|
||||||
|
|
||||||
|
public RevertArea(ITerrainChannel revertmap)
|
||||||
|
{
|
||||||
|
m_revertmap = revertmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
|
||||||
|
{
|
||||||
|
public class RevertSphere : ITerrainPaintableEffect
|
||||||
|
{
|
||||||
|
ITerrainChannel m_revertmap;
|
||||||
|
|
||||||
|
public RevertSphere(ITerrainChannel revertmap)
|
||||||
|
{
|
||||||
|
m_revertmap = revertmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region ITerrainPaintableEffect Members
|
||||||
|
|
||||||
|
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
z *= duration;
|
||||||
|
map[x, y] += (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -190,6 +190,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
private Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
|
private Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
|
||||||
Scene m_scene;
|
Scene m_scene;
|
||||||
ITerrainChannel m_channel;
|
ITerrainChannel m_channel;
|
||||||
|
ITerrainChannel m_revert;
|
||||||
bool m_tainted = false;
|
bool m_tainted = false;
|
||||||
private IConfigSource m_gConfig;
|
private IConfigSource m_gConfig;
|
||||||
|
|
||||||
|
@ -201,6 +202,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
m_painteffects[StandardTerrainEffects.Smooth] = new PaintBrushes.SmoothSphere();
|
m_painteffects[StandardTerrainEffects.Smooth] = new PaintBrushes.SmoothSphere();
|
||||||
m_painteffects[StandardTerrainEffects.Noise] = new PaintBrushes.NoiseSphere();
|
m_painteffects[StandardTerrainEffects.Noise] = new PaintBrushes.NoiseSphere();
|
||||||
m_painteffects[StandardTerrainEffects.Flatten] = new PaintBrushes.FlattenSphere();
|
m_painteffects[StandardTerrainEffects.Flatten] = new PaintBrushes.FlattenSphere();
|
||||||
|
m_painteffects[StandardTerrainEffects.Revert] = new PaintBrushes.RevertSphere(m_revert);
|
||||||
|
|
||||||
// Area of effect selection effects
|
// Area of effect selection effects
|
||||||
m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea();
|
m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea();
|
||||||
|
@ -208,6 +210,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
m_floodeffects[StandardTerrainEffects.Smooth] = new FloodBrushes.SmoothArea();
|
m_floodeffects[StandardTerrainEffects.Smooth] = new FloodBrushes.SmoothArea();
|
||||||
m_floodeffects[StandardTerrainEffects.Noise] = new FloodBrushes.NoiseArea();
|
m_floodeffects[StandardTerrainEffects.Noise] = new FloodBrushes.NoiseArea();
|
||||||
m_floodeffects[StandardTerrainEffects.Flatten] = new FloodBrushes.FlattenArea();
|
m_floodeffects[StandardTerrainEffects.Flatten] = new FloodBrushes.FlattenArea();
|
||||||
|
m_floodeffects[StandardTerrainEffects.Revert] = new FloodBrushes.RevertArea(m_revert);
|
||||||
|
|
||||||
// Filesystem load/save loaders
|
// Filesystem load/save loaders
|
||||||
m_loaders[".r32"] = new FileLoaders.RAW32();
|
m_loaders[".r32"] = new FileLoaders.RAW32();
|
||||||
|
@ -218,6 +221,18 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
m_loaders[".jpeg"] = m_loaders[".jpg"];
|
m_loaders[".jpeg"] = m_loaders[".jpg"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateRevertMap()
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
for (x = 0; x < m_channel.Width; x++)
|
||||||
|
{
|
||||||
|
for (y = 0; y < m_channel.Height; y++)
|
||||||
|
{
|
||||||
|
m_revert[x, y] = m_channel[x, y];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadFromFile(string filename)
|
public void LoadFromFile(string filename)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
|
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
|
||||||
|
@ -229,6 +244,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
ITerrainChannel channel = loader.Value.LoadFile(filename);
|
ITerrainChannel channel = loader.Value.LoadFile(filename);
|
||||||
m_scene.Heightmap = channel;
|
m_scene.Heightmap = channel;
|
||||||
m_channel = channel;
|
m_channel = channel;
|
||||||
|
UpdateRevertMap();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -266,11 +282,15 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
{
|
{
|
||||||
m_channel = new TerrainChannel();
|
m_channel = new TerrainChannel();
|
||||||
m_scene.Heightmap = m_channel;
|
m_scene.Heightmap = m_channel;
|
||||||
|
m_revert = new TerrainChannel();
|
||||||
|
UpdateRevertMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_channel = m_scene.Heightmap;
|
m_channel = m_scene.Heightmap;
|
||||||
|
m_revert = new TerrainChannel();
|
||||||
|
UpdateRevertMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
|
m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
|
||||||
|
|
Loading…
Reference in New Issue