From 8194d822301481c56c2e48857e6609409613dd6d Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Wed, 20 Jun 2007 21:57:22 +0000
Subject: * Terrain modification more robust, uses area sizes matching those
employed by the client display. * Terrain tools now account for the duration
the cursor was held for. * Terrain tools now support new brushes (completing
the common set) ** Smooth brush ** Flatten brush ** Revert brush ** Noise
brush
---
OpenSim/Examples/SimpleApp/Program.cs | 14 ++--
.../OpenSim.Region/Scenes/Scene.PacketHandlers.cs | 51 +++++++++++--
.../ClientView.ProcessPackets.cs | 3 +-
.../OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 83 ++++++++++++++++++++++
4 files changed, 136 insertions(+), 15 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Examples/SimpleApp/Program.cs b/OpenSim/Examples/SimpleApp/Program.cs
index 6d89cbe..de6e6d3 100644
--- a/OpenSim/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Examples/SimpleApp/Program.cs
@@ -19,13 +19,13 @@ namespace SimpleApp
{
class Program : IAssetReceiver, conscmd_callback
{
- private LogBase m_console;
+ private LogBase m_log;
AuthenticateSessionsBase m_circuitManager;
private void Run()
{
- m_console = new LogBase(null, "SimpleApp", this, false);
- MainLog.Instance = m_console;
+ m_log = new LogBase(null, "SimpleApp", this, false);
+ MainLog.Instance = m_log;
CheckSumServer checksumServer = new CheckSumServer(12036);
checksumServer.ServerListener();
@@ -47,7 +47,7 @@ namespace SimpleApp
AssetCache assetCache = new AssetCache(assetServer);
- UDPServer udpServer = new UDPServer(simPort, assetCache, inventoryCache, m_console, m_circuitManager );
+ UDPServer udpServer = new UDPServer(simPort, assetCache, inventoryCache, m_log, m_circuitManager );
PacketServer packetServer = new PacketServer( udpServer, (uint) simPort );
udpServer.ServerListener();
@@ -68,13 +68,13 @@ namespace SimpleApp
httpServer.AddXmlRPCHandler( "login_to_simulator", loginServer.XmlRpcLoginMethod );
httpServer.Start();
- m_console.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
- m_console.ReadLine();
+ m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
+ m_log.ReadLine();
}
private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
{
- m_console.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last);
+ m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last);
AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = loginData.Agent;
diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs b/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs
index 75fe779..01e38d5 100644
--- a/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs
@@ -41,25 +41,62 @@ namespace OpenSim.Region.Scenes
public partial class Scene
{
///
- ///
+ /// Modifies terrain using the specified information
///
- ///
- ///
- ///
- public void ModifyTerrain(byte action, float north, float west)
+ /// The height at which the user started modifying the terrain
+ /// The number of seconds the modify button was pressed
+ /// The size of the brush used
+ /// The action to be performed
+ /// Distance from the north border where the cursor is located
+ /// Distance from the west border where the cursor is located
+ public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west)
{
+ // Shiny.
+ double size = (double)(1 << brushsize);
+
switch (action)
{
+ case 0:
+ // flatten terrain
+ Terrain.flatten(north, west, size, (double)seconds / 100.0);
+ RegenerateTerrain(true, (int)north, (int)west);
+ break;
case 1:
// raise terrain
- Terrain.raise(north, west, 10.0, 0.001);
+ Terrain.raise(north, west, size, (double)seconds / 100.0);
RegenerateTerrain(true, (int)north, (int)west);
break;
case 2:
//lower terrain
- Terrain.lower(north, west, 10.0, 0.001);
+ Terrain.lower(north, west, size, (double)seconds / 100.0);
+ RegenerateTerrain(true, (int)north, (int)west);
+ break;
+ case 3:
+ // smooth terrain
+ Terrain.smooth(north, west, size, (double)seconds / 100.0);
+ RegenerateTerrain(true, (int)north, (int)west);
+ break;
+ case 4:
+ // noise
+ Terrain.noise(north, west, size, (double)seconds / 100.0);
+ RegenerateTerrain(true, (int)north, (int)west);
+ break;
+ case 5:
+ // revert
+ Terrain.revert(north, west, size, (double)seconds / 100.0);
RegenerateTerrain(true, (int)north, (int)west);
break;
+
+ // CLIENT EXTENSIONS GO HERE
+ case 128:
+ // erode-thermal
+ break;
+ case 129:
+ // erode-aerobic
+ break;
+ case 130:
+ // erode-hydraulic
+ break;
}
return;
}
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs
index d53832f..65066b8 100644
--- a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs
+++ b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs
@@ -130,7 +130,8 @@ namespace OpenSim
{
if (OnModifyTerrain != null)
{
- OnModifyTerrain(modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West);
+ OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize,
+ modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West);
}
}
break;
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
index 2d0fb30..d1d54ad 100644
--- a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
@@ -542,6 +542,89 @@ namespace OpenSim.Terrain
}
///
+ /// Flattens the land under the brush of specified coordinates (spherical mask)
+ ///
+ /// Center of sphere
+ /// Center of sphere
+ /// Radius of the sphere
+ /// Thickness of the mask (0..2 recommended)
+ public void flatten(double rx, double ry, double size, double amount)
+ {
+ lock (heightmap)
+ {
+ heightmap.flatten(rx, ry, size, amount);
+ }
+
+ tainted++;
+ }
+
+ ///
+ /// Creates noise within the specified bounds
+ ///
+ /// Center of the bounding sphere
+ /// Center of the bounding sphere
+ /// The radius of the sphere
+ /// Strength of the mask (0..2) recommended
+ public void noise(double rx, double ry, double size, double amount)
+ {
+ lock (heightmap)
+ {
+ Channel smoothed = new Channel();
+ smoothed.noise();
+
+ Channel mask = new Channel();
+ mask.raise(rx, ry, size, amount);
+
+ heightmap.blend(smoothed, mask);
+ }
+
+ tainted++;
+ }
+
+ ///
+ /// Reverts land within the specified bounds
+ ///
+ /// Center of the bounding sphere
+ /// Center of the bounding sphere
+ /// The radius of the sphere
+ /// Strength of the mask (0..2) recommended
+ public void revert(double rx, double ry, double size, double amount)
+ {
+ lock (heightmap)
+ {
+ Channel mask = new Channel();
+ mask.raise(rx, ry, size, amount);
+
+ heightmap.blend(revertmap, mask);
+ }
+
+ tainted++;
+ }
+
+ ///
+ /// Smooths land under the brush of specified coordinates (spherical mask)
+ ///
+ /// Center of the sphere
+ /// Center of the sphere
+ /// Radius of the sphere
+ /// Thickness of the mask (0..2 recommended)
+ public void smooth(double rx, double ry, double size, double amount)
+ {
+ lock (heightmap)
+ {
+ Channel smoothed = heightmap.copy();
+ smoothed.smooth(amount);
+
+ Channel mask = new Channel();
+ mask.raise(rx,ry,size,amount);
+
+ heightmap.blend(smoothed, mask);
+ }
+
+ tainted++;
+ }
+
+ ///
/// Generates a simple set of hills in the shape of an island
///
public void hills()
--
cgit v1.1