From cc992bf156ff9585e3a2f6a761711bf193d42eed Mon Sep 17 00:00:00 2001 From: Jak Daniels Date: Wed, 18 Nov 2015 18:18:30 +0000 Subject: [PATCH] Changes to TerrainModule/ITerrainModule to support importing OARs with different Region sizes to the destination region. Signed-off-by: UbitUmarov --- .../World/Terrain/TerrainModule.cs | 31 +++++++++++++++++++ .../Framework/Interfaces/ITerrainModule.cs | 2 ++ 2 files changed, 33 insertions(+) diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 5e35d95c0b..275aa2ab99 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -456,6 +456,37 @@ namespace OpenSim.Region.CoreModules.World.Terrain throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); } + public void LoadFromStream(string filename, Vector3 displacement, + float rotationDegrees, Vector2 boundingOrigin, Vector2 boundingSize, Stream stream) + { + foreach (KeyValuePair loader in m_loaders) + { + if (filename.EndsWith(loader.Key)) + { + lock (m_scene) + { + try + { + ITerrainChannel channel = loader.Value.LoadStream(stream); + m_channel.MergeWithBounding(channel, displacement, rotationDegrees, boundingOrigin, boundingSize); + UpdateBakedMap(); + } + catch (NotImplementedException) + { + m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value + + " parser does not support file loading. (May be save only)"); + throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value)); + } + } + + m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully"); + return; + } + } + m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader available for that format."); + throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); + } + private static Stream URIFetch(Uri uri) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs index b8c313ae9e..2d33f51324 100644 --- a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs @@ -60,6 +60,8 @@ namespace OpenSim.Region.Framework.Interfaces void LoadFromStream(string filename, System.Uri pathToTerrainHeightmap); void LoadFromStream(string filename, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement, Stream stream); + void LoadFromStream(string filename, Vector3 displacement, + float rotationDegress, Vector2 boundingOrigin, Vector2 boundingSize, Stream stream); /// /// Save a terrain to a stream. ///