aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
diff options
context:
space:
mode:
authorRobert Adams2014-02-02 11:17:49 -0800
committerRobert Adams2014-02-02 11:17:49 -0800
commit9c97fb8e127e91d48cf92eeed238cf80878e2286 (patch)
treea0d00a1707f45121137d210f18b8b9525cc3ab48 /OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
parentOverload INPCModule.CreateNPC() to allow agentID to be specified. Note: this ... (diff)
downloadopensim-SC_OLD-9c97fb8e127e91d48cf92eeed238cf80878e2286.zip
opensim-SC_OLD-9c97fb8e127e91d48cf92eeed238cf80878e2286.tar.gz
opensim-SC_OLD-9c97fb8e127e91d48cf92eeed238cf80878e2286.tar.bz2
opensim-SC_OLD-9c97fb8e127e91d48cf92eeed238cf80878e2286.tar.xz
Implement terrain merging in TerrainChannel.
Modify archiver to use terrain merging when loading oars. This makes displacement AND rotation properly work on terrain when loading oars. Especially useful when loading legacy region oars into large varregions.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs35
1 files changed, 4 insertions, 31 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 7bc5e88..08891d9 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -316,8 +316,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
316 316
317 public void LoadFromStream(string filename, Stream stream) 317 public void LoadFromStream(string filename, Stream stream)
318 { 318 {
319 Vector2 defaultDisplacement = new Vector2(0f, 0f); 319 LoadFromStream(filename, Vector3.Zero, 0f, Vector2.Zero, stream);
320 LoadFromStream(filename, defaultDisplacement, stream);
321 } 320 }
322 321
323 /// <summary> 322 /// <summary>
@@ -325,7 +324,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
325 /// </summary> 324 /// </summary>
326 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> 325 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param>
327 /// <param name="stream"></param> 326 /// <param name="stream"></param>
328 public void LoadFromStream(string filename, Vector2 displacement, Stream stream) 327 public void LoadFromStream(string filename, Vector3 displacement,
328 float radianRotation, Vector2 rotationDisplacement, Stream stream)
329 { 329 {
330 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) 330 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
331 { 331 {
@@ -336,7 +336,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
336 try 336 try
337 { 337 {
338 ITerrainChannel channel = loader.Value.LoadStream(stream); 338 ITerrainChannel channel = loader.Value.LoadStream(stream);
339 MergeTerrainIntoExisting(channel, displacement); 339 m_channel.Merge(channel, displacement, radianRotation, rotationDisplacement);
340 UpdateRevertMap(); 340 UpdateRevertMap();
341 } 341 }
342 catch (NotImplementedException) 342 catch (NotImplementedException)
@@ -356,33 +356,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
356 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));
357 } 357 }
358 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
386 private static Stream URIFetch(Uri uri) 359 private static Stream URIFetch(Uri uri)
387 { 360 {
388 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); 361 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);