aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorRobert Adams2014-01-19 10:09:43 -0800
committerRobert Adams2014-01-19 10:09:43 -0800
commitdd6db7293975bffc3693e0164dda8307a4e4bcf7 (patch)
treecfd275e8cbc9e64913b1dbf033164956b37098c5 /OpenSim/Region/CoreModules
parentMerge branch 'master' into varregion (diff)
downloadopensim-SC-dd6db7293975bffc3693e0164dda8307a4e4bcf7.zip
opensim-SC-dd6db7293975bffc3693e0164dda8307a4e4bcf7.tar.gz
opensim-SC-dd6db7293975bffc3693e0164dda8307a4e4bcf7.tar.bz2
opensim-SC-dd6db7293975bffc3693e0164dda8307a4e4bcf7.tar.xz
varregion: add --displacement parameter to 'load oar'.
Adds displacment to all objects and terrain loaded from the oar. As an example, if you have a 512x512 region and an old 256x256 oar, doing load oar --displacement "<128,128,0>" oarFile.oar will load the object (and terrain) into the middle of the 512x512 region. If displacement is not specified, 'load oar' works like it always has. If you have a 5
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs22
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs34
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs38
4 files changed, 81 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index d451b9e..d249129 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -104,6 +104,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
104 /// </value> 104 /// </value>
105 protected bool m_skipAssets; 105 protected bool m_skipAssets;
106 106
107 /// <value>
108 /// Displacement added to each object as it is added to the world
109 /// </value>
110 protected Vector3 m_displacement = new Vector3(0f, 0f, 0f);
111
107 /// <summary> 112 /// <summary>
108 /// Used to cache lookups for valid uuids. 113 /// Used to cache lookups for valid uuids.
109 /// </summary> 114 /// </summary>
@@ -132,7 +137,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
132 private IAssetService m_assetService = null; 137 private IAssetService m_assetService = null;
133 138
134 139
135 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) 140 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId)
136 { 141 {
137 m_rootScene = scene; 142 m_rootScene = scene;
138 143
@@ -153,6 +158,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
153 m_merge = merge; 158 m_merge = merge;
154 m_skipAssets = skipAssets; 159 m_skipAssets = skipAssets;
155 m_requestId = requestId; 160 m_requestId = requestId;
161 m_displacement = displacement;
156 162
157 // Zero can never be a valid user id 163 // Zero can never be a valid user id
158 m_validUserUuids[UUID.Zero] = false; 164 m_validUserUuids[UUID.Zero] = false;
@@ -445,6 +451,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
445 451
446 SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); 452 SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject);
447 453
454 // Happily this does not do much to the object since it hasn't been added to the scene yet
455 sceneObject.AbsolutePosition += m_displacement;
456
457
448 bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID != UUID.Zero); 458 bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID != UUID.Zero);
449 459
450 // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned 460 // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned
@@ -809,7 +819,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
809 ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); 819 ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
810 820
811 MemoryStream ms = new MemoryStream(data); 821 MemoryStream ms = new MemoryStream(data);
812 terrainModule.LoadFromStream(terrainPath, ms); 822 if (m_displacement != Vector3.Zero)
823 {
824 Vector2 terrainDisplacement = new Vector2(m_displacement.X, m_displacement.Y);
825 terrainModule.LoadFromStream(terrainPath, terrainDisplacement, ms);
826 }
827 else
828 {
829 terrainModule.LoadFromStream(terrainPath, ms);
830 }
813 ms.Close(); 831 ms.Close();
814 832
815 m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath); 833 m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index 1be6386..fb694de 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -33,11 +33,14 @@ using log4net;
33using NDesk.Options; 33using NDesk.Options;
34using Nini.Config; 34using Nini.Config;
35using Mono.Addins; 35using Mono.Addins;
36
36using OpenSim.Framework; 37using OpenSim.Framework;
37using OpenSim.Framework.Console; 38using OpenSim.Framework.Console;
38using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
40 41
42using OpenMetaverse;
43
41namespace OpenSim.Region.CoreModules.World.Archiver 44namespace OpenSim.Region.CoreModules.World.Archiver
42{ 45{
43 /// <summary> 46 /// <summary>
@@ -101,9 +104,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
101 { 104 {
102 bool mergeOar = false; 105 bool mergeOar = false;
103 bool skipAssets = false; 106 bool skipAssets = false;
107 Vector3 displacement = new Vector3(0f, 0f, 0f);
104 108
105 OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); 109 OptionSet options = new OptionSet();
106 options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; }); 110 options.Add("m|merge", delegate (string v) { mergeOar = (v != null); });
111 options.Add("s|skip-assets", delegate (string v) { skipAssets = (v != null); });
112 options.Add("displacement=", delegate (string v) {
113 try
114 {
115 displacement = v == null ? new Vector3(0f, 0f, 0f) : Vector3.Parse(v);
116 }
117 catch (Exception e)
118 {
119 m_log.ErrorFormat("[ARCHIVER MODULE] failure parsing displacement");
120 displacement = new Vector3(0f, 0f, 0f);
121 }
122 });
107 123
108 // Send a message to the region ready module 124 // Send a message to the region ready module
109 /* bluewall* Disable this for the time being 125 /* bluewall* Disable this for the time being
@@ -124,11 +140,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
124 140
125 if (mainParams.Count > 2) 141 if (mainParams.Count > 2)
126 { 142 {
127 DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty); 143 DearchiveRegion(mainParams[2], mergeOar, skipAssets, displacement, Guid.Empty);
128 } 144 }
129 else 145 else
130 { 146 {
131 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, Guid.Empty); 147 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, displacement, Guid.Empty);
132 } 148 }
133 } 149 }
134 150
@@ -198,23 +214,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver
198 214
199 public void DearchiveRegion(string loadPath) 215 public void DearchiveRegion(string loadPath)
200 { 216 {
201 DearchiveRegion(loadPath, false, false, Guid.Empty); 217 DearchiveRegion(loadPath, false, false, new Vector3(0f, 0f, 0f), Guid.Empty);
202 } 218 }
203 219
204 public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId) 220 public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId)
205 { 221 {
206 m_log.InfoFormat( 222 m_log.InfoFormat(
207 "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath); 223 "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
208 224
209 new ArchiveReadRequest(Scene, loadPath, merge, skipAssets, requestId).DearchiveRegion(); 225 new ArchiveReadRequest(Scene, loadPath, merge, skipAssets, displacement, requestId).DearchiveRegion();
210 } 226 }
211 227
212 public void DearchiveRegion(Stream loadStream) 228 public void DearchiveRegion(Stream loadStream)
213 { 229 {
214 DearchiveRegion(loadStream, false, false, Guid.Empty); 230 DearchiveRegion(loadStream, false, false, new Vector3(0f, 0f, 0f), Guid.Empty);
215 } 231 }
216 232
217 public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId) 233 public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Vector3 displacement, Guid requestId)
218 { 234 {
219 new ArchiveReadRequest(Scene, loadStream, merge, skipAssets, requestId).DearchiveRegion(); 235 new ArchiveReadRequest(Scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
220 } 236 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index eec1cec..c412acb 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -752,7 +752,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
752 byte[] archive = archiveWriteStream.ToArray(); 752 byte[] archive = archiveWriteStream.ToArray();
753 MemoryStream archiveReadStream = new MemoryStream(archive); 753 MemoryStream archiveReadStream = new MemoryStream(archive);
754 754
755 m_archiverModule.DearchiveRegion(archiveReadStream, true, false, Guid.Empty); 755 m_archiverModule.DearchiveRegion(archiveReadStream, true, false, new Vector3(0f, 0f, 0f), Guid.Empty);
756 756
757 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); 757 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
758 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); 758 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 9766bfe..7bc5e88 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -314,12 +314,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain
314 LoadFromStream(filename, URIFetch(pathToTerrainHeightmap)); 314 LoadFromStream(filename, URIFetch(pathToTerrainHeightmap));
315 } 315 }
316 316
317 public void LoadFromStream(string filename, Stream stream)
318 {
319 Vector2 defaultDisplacement = new Vector2(0f, 0f);
320 LoadFromStream(filename, defaultDisplacement, stream);
321 }
322
317 /// <summary> 323 /// <summary>
318 /// Loads a terrain file from a stream and installs it in the scene. 324 /// Loads a terrain file from a stream and installs it in the scene.
319 /// </summary> 325 /// </summary>
320 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> 326 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param>
321 /// <param name="stream"></param> 327 /// <param name="stream"></param>
322 public void LoadFromStream(string filename, Stream stream) 328 public void LoadFromStream(string filename, Vector2 displacement, Stream stream)
323 { 329 {
324 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) 330 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
325 { 331 {
@@ -330,8 +336,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
330 try 336 try
331 { 337 {
332 ITerrainChannel channel = loader.Value.LoadStream(stream); 338 ITerrainChannel channel = loader.Value.LoadStream(stream);
333 m_scene.Heightmap = channel; 339 MergeTerrainIntoExisting(channel, displacement);
334 m_channel = channel;
335 UpdateRevertMap(); 340 UpdateRevertMap();
336 } 341 }
337 catch (NotImplementedException) 342 catch (NotImplementedException)
@@ -351,6 +356,33 @@ namespace OpenSim.Region.CoreModules.World.Terrain
351 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); 356 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
352 } 357 }
353 358
359 private void MergeTerrainIntoExisting(ITerrainChannel channel, Vector2 displacement)
360 {
361 if (displacement == Vector2.Zero)
362 {
363 // If there is no displacement, just use this channel as the new heightmap
364 m_scene.Heightmap = channel;
365 m_channel = channel;
366 }
367 else
368 {
369 // If there is a displacement, we copy the loaded heightmap into the overall region
370 for (int xx = 0; xx < channel.Width; xx++)
371 {
372 for (int yy = 0; yy < channel.Height; yy++)
373 {
374 int dispX = xx + (int)displacement.X;
375 int dispY = yy + (int)displacement.Y;
376 if (dispX >= 0 && dispX < m_channel.Width
377 && dispY >= 0 && dispY < m_channel.Height)
378 {
379 m_channel[dispX, dispY] = channel[xx, yy];
380 }
381 }
382 }
383 }
384 }
385
354 private static Stream URIFetch(Uri uri) 386 private static Stream URIFetch(Uri uri)
355 { 387 {
356 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); 388 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);