From 64d05bab0fe9e12038309275a677e68518fb9b15 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Aug 2015 13:36:45 +0100 Subject: terrain stored as ushorts with gzip compression --- .../CoreModules/World/Terrain/TerrainModule.cs | 49 +++++++++++++++++++--- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 6 ++- 2 files changed, 48 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 118c8f8..135fe50 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -1349,6 +1349,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain double desiredMin = (double)args[0]; double desiredMax = (double)args[1]; + if (desiredMin < 0 || desiredMin > 655.35 + || desiredMax < 0 || desiredMax > 655.35) + { + m_log.Error("desired Min and Max must be in range 0.0 to 655.0m"); + return; + } + // determine desired scaling factor double desiredRange = desiredMax - desiredMin; //m_log.InfoFormat("Desired {0}, {1} = {2}", new Object[] { desiredMin, desiredMax, desiredRange }); @@ -1405,45 +1412,69 @@ namespace OpenSim.Region.CoreModules.World.Terrain private void InterfaceElevateTerrain(Object[] args) { + double val = (double)args[0]; + if (val < 0 || val > 655.35) + { + m_log.Error("elevation must be in range 0.0 to 655.0m"); + return; + } + int x, y; for (x = 0; x < m_channel.Width; x++) for (y = 0; y < m_channel.Height; y++) - m_channel[x, y] += (double) args[0]; + m_channel[x, y] += val; } private void InterfaceMultiplyTerrain(Object[] args) { int x, y; + double val = (double)args[0]; + for (x = 0; x < m_channel.Width; x++) for (y = 0; y < m_channel.Height; y++) - m_channel[x, y] *= (double) args[0]; + m_channel[x, y] *= val; } private void InterfaceLowerTerrain(Object[] args) { int x, y; + double val = (double)args[0]; + if (val < 0 || val > 655.35) + for (x = 0; x < m_channel.Width; x++) for (y = 0; y < m_channel.Height; y++) - m_channel[x, y] -= (double) args[0]; + m_channel[x, y] -= val; } public void InterfaceFillTerrain(Object[] args) { int x, y; + double val = (double)args[0]; + if (val < 0 || val > 655.35) + { + m_log.Error("height must be in range 0.0 to 655.0m"); + return; + } for (x = 0; x < m_channel.Width; x++) for (y = 0; y < m_channel.Height; y++) - m_channel[x, y] = (double) args[0]; + m_channel[x, y] = val; } private void InterfaceMinTerrain(Object[] args) { int x, y; + double val = (double)args[0]; + if (val < 0 || val > 655.35) + { + m_log.Error("minimum must be in range 0.0 to 655.0m"); + return; + } for (x = 0; x < m_channel.Width; x++) { for (y = 0; y < m_channel.Height; y++) { - m_channel[x, y] = Math.Max((double)args[0], m_channel[x, y]); + m_channel[x, y] = Math.Max(val, m_channel[x, y]); } } } @@ -1451,11 +1482,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain private void InterfaceMaxTerrain(Object[] args) { int x, y; + double val = (double)args[0]; + if (val < 0 || val > 655.35) + { + m_log.Error("maximum must be in range 0.0 to 655.0m"); + return; + } for (x = 0; x < m_channel.Width; x++) { for (y = 0; y < m_channel.Height; y++) { - m_channel[x, y] = Math.Min((double)args[0], m_channel[x, y]); + m_channel[x, y] = Math.Min(val, m_channel[x, y]); } } } diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 2dab246..75c3a3b 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -157,7 +157,11 @@ namespace OpenSim.Region.Framework.Scenes { if (Double.IsNaN(value) || Double.IsInfinity(value)) return; - + if (value < 0) + value = 0; + else + if (value > 655.35) + value = 655.35; m_terrainData[x, y] = (float)value; } } -- cgit v1.1