From 7c3bfdd8c902375981892ff364b34e68c5344f91 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 9 Dec 2008 17:00:42 +0000 Subject: * Apply terrain flip patch from http://opensimulator.org/mantis/view.php?id=2315 * This allows terrain to be flipped on the x or y axis with the command "terrain flip x" (or y) * See terrain help from the command prompt * This is in anticipation of change the way around in which terrain raw files are imported to match that of Second Life (to reduce user confusion and improve useability) * Thanks jonc! --- .../Modules/World/Terrain/TerrainModule.cs | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'OpenSim/Region/Environment/Modules') diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs index 5646de1..c1d6ab2 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs @@ -753,6 +753,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; @@ -911,6 +952,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, @@ -938,6 +983,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); -- cgit v1.1