From 7fa6646d6f75585d6ad3bd2a7c1c0e873e2fc2a6 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Wed, 16 Jan 2008 21:21:31 +0000 Subject: Added (experimental) terrain elevate command to allow whole terrain to be elevated with positive or negative values --- OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | 15 +++++++++++++++ .../Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'OpenSim/Region/Terrain.BasicTerrain') diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index 2405e86..fdbbb5e 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs @@ -477,6 +477,7 @@ namespace OpenSim.Region.Terrain resultText += "terrain erode thermal \n"; resultText += "terrain erode hydraulic \n"; resultText += "terrain multiply - multiplies a terrain by \n"; + resultText += "terrain elevate - elevates a terrain by \n"; resultText += "terrain revert - reverts the terrain to the stored original\n"; resultText += "terrain bake - saves the current terrain into the revert map\n"; resultText += @@ -524,6 +525,10 @@ namespace OpenSim.Region.Terrain SetRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); break; + case "elevate": + Elevate(Convert.ToSingle(args[1])); + break; + case "fill": heightmap.Fill(Convert.ToDouble(args[1])); tainted++; @@ -766,6 +771,16 @@ namespace OpenSim.Region.Terrain } /// + /// Adds meters (positive or negative) to terrain height + /// + /// Positive or negative value to add to new array + public void Elevate(float meters) + { + heightmap.Elevate((double)meters); + tainted++; + } + + /// /// Loads a file consisting of 256x256 doubles and imports it as an array into the map. /// /// TODO: Move this to libTerrain itself diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs index 4ff8e78..1a86572 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs @@ -96,6 +96,24 @@ namespace libTerrain return this; } + public Channel Elevate(double meters) + { + SetDiff(); + + int x, y; + + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + map[x, y] += meters; + } + } + + return this; + } + + public Channel Clip() { int x, y; -- cgit v1.1