From 8c19809ed2d9c25408e831808f2891bcb374dcce Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 16 Dec 2008 13:57:48 +0000 Subject: [PATCH] Merged Revision 7650 from Trunk to 0.6.0-stable branch. A patch from jonc to add a "terrain flip x/y" command. --- CONTRIBUTORS.txt | 3 +- .../Modules/World/Terrain/TerrainModule.cs | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 228f09c0db..7d79c9fec6 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -54,6 +54,7 @@ Patches * jhurliman * jimbo2120 (IBM) * John R Sohn (XenReborn) +* jonc * Junta Kohime * Kayne * Kevin Cozens @@ -63,6 +64,7 @@ Patches * M.Igarashi * Mic Bowman * mikkopa/_someone - RealXtend +* Mircea Kitsune * nlin * nornalbion * openlifegrid.com @@ -79,7 +81,6 @@ Patches * Y. Nitta * YZh * Zha Ewry -* Mircea Kitsune LSL Devs diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs index c49b0b9ebe..bfdff96d3c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs @@ -752,6 +752,47 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain CheckForTerrainUpdates(); } + private void InterfaceFlipTerrain(Object[] args) + { + String direction = (String)args[0]; + + if( direction.ToLower().StartsWith("y")) + { + for (int x = 0; x < Constants.RegionSize; x++) + { + for (int y = 0; y < Constants.RegionSize / 2; y++) + { + double height = m_channel[x, y]; + double flippedHeight = m_channel[x, (int)Constants.RegionSize - 1 - y]; + m_channel[x, y] = flippedHeight; + m_channel[x, (int)Constants.RegionSize - 1 - y] = height; + + } + } + } + else if (direction.ToLower().StartsWith("x")) + { + for (int y = 0; y < Constants.RegionSize; y++) + { + for (int x = 0; x < Constants.RegionSize / 2; x++) + { + double height = m_channel[x, y]; + double flippedHeight = m_channel[(int)Constants.RegionSize - 1 - x, y]; + m_channel[x, y] = flippedHeight; + m_channel[(int)Constants.RegionSize - 1 - x, y] = height; + + } + } + } + else + { + m_log.Error("Unrecognised direction - need x or y"); + } + + + CheckForTerrainUpdates(); + } + private void InterfaceElevateTerrain(Object[] args) { int x, y; @@ -910,6 +951,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain Command revertRegionCommand = new Command("revert", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap."); + Command flipCommand = + new Command("flip", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFlipTerrain, "Flips the current terrain about the X or Y axis"); + flipCommand.AddArgument("direction", "[x|y] the direction to flip the terrain in", "String"); + // Debug Command showDebugStatsCommand = new Command("stats", CommandIntentions.COMMAND_STATISTICAL, InterfaceShowDebugStats, @@ -937,6 +982,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand); m_commander.RegisterCommand("stats", showDebugStatsCommand); m_commander.RegisterCommand("effect", pluginRunCommand); + m_commander.RegisterCommand("flip", flipCommand); // Add this to our scene so scripts can call these functions m_scene.RegisterModuleCommander("Terrain", m_commander);