aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorCharles Krinke2008-06-19 20:57:00 +0000
committerCharles Krinke2008-06-19 20:57:00 +0000
commit838ffd779280115dee2d24ddd9531728d7426942 (patch)
tree753ce7e8d03e83898cf07cac2c85ca8a382b0a67 /OpenSim/Region
parent* Patch from Dahlia - 0001576: Exception of type 'System.OutOfMemoryException... (diff)
downloadopensim-SC_OLD-838ffd779280115dee2d24ddd9531728d7426942.zip
opensim-SC_OLD-838ffd779280115dee2d24ddd9531728d7426942.tar.gz
opensim-SC_OLD-838ffd779280115dee2d24ddd9531728d7426942.tar.bz2
opensim-SC_OLD-838ffd779280115dee2d24ddd9531728d7426942.tar.xz
Mantis#1543. Thank you kindly, Jonc for a patch that:
Implements terrain bake from Region/Estate dialog and respects estate settings during terraforming
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs13
-rw-r--r--OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs81
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs1
4 files changed, 95 insertions, 4 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index b298578..3dddbfb 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -159,6 +159,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
159 private RezObject handlerRezObject = null; //OnRezObject; 159 private RezObject handlerRezObject = null; //OnRezObject;
160 private GenericCall4 handlerDeRezObject = null; //OnDeRezObject; 160 private GenericCall4 handlerDeRezObject = null; //OnDeRezObject;
161 private ModifyTerrain handlerModifyTerrain = null; 161 private ModifyTerrain handlerModifyTerrain = null;
162 private BakeTerrain handlerBakeTerrain = null;
162 private Action<IClientAPI> handlerRegionHandShakeReply = null; //OnRegionHandShakeReply; 163 private Action<IClientAPI> handlerRegionHandShakeReply = null; //OnRegionHandShakeReply;
163 private GenericCall2 handlerRequestWearables = null; //OnRequestWearables; 164 private GenericCall2 handlerRequestWearables = null; //OnRequestWearables;
164 private Action<IClientAPI> handlerRequestAvatarsData = null; //OnRequestAvatarsData; 165 private Action<IClientAPI> handlerRequestAvatarsData = null; //OnRequestAvatarsData;
@@ -893,6 +894,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
893 public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights; 894 public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
894 public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest; 895 public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
895 public event SetRegionTerrainSettings OnSetRegionTerrainSettings; 896 public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
897 public event BakeTerrain OnBakeTerrain;
896 public event EstateRestartSimRequest OnEstateRestartSimRequest; 898 public event EstateRestartSimRequest OnEstateRestartSimRequest;
897 public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; 899 public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
898 public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; 900 public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
@@ -5846,6 +5848,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5846 handlerLandStatRequest(0, 0, 0, "", this); 5848 handlerLandStatRequest(0, 0, 0, "", this);
5847 } 5849 }
5848 break; 5850 break;
5851 case "terrain":
5852 if (((Scene)m_scene).ExternalChecks.ExternalChecksCanIssueEstateCommand(this.AgentId))
5853 {
5854 handlerBakeTerrain = OnBakeTerrain;
5855 if (handlerBakeTerrain != null)
5856 {
5857 handlerBakeTerrain(this);
5858 }
5859 }
5860 break;
5861
5849 default: 5862 default:
5850 m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket.ToString()); 5863 m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket.ToString());
5851 break; 5864 break;
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
index 4935672..a242ebe 100644
--- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
@@ -281,6 +281,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
281 public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights; 281 public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
282 public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest; 282 public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
283 public event SetRegionTerrainSettings OnSetRegionTerrainSettings; 283 public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
284 public event BakeTerrain OnBakeTerrain;
284 public event EstateRestartSimRequest OnEstateRestartSimRequest; 285 public event EstateRestartSimRequest OnEstateRestartSimRequest;
285 public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; 286 public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
286 public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; 287 public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
@@ -776,5 +777,6 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
776 { 777 {
777 } 778 }
778 #endregion 779 #endregion
779 } 780
781 }
780} 782}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
index 9d8bbfc..49347b2 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
@@ -419,13 +419,28 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
419 private void EventManager_OnNewClient(IClientAPI client) 419 private void EventManager_OnNewClient(IClientAPI client)
420 { 420 {
421 client.OnModifyTerrain += client_OnModifyTerrain; 421 client.OnModifyTerrain += client_OnModifyTerrain;
422 client.OnBakeTerrain += client_OnBakeTerrain;
422 } 423 }
423 424
424 /// <summary> 425 /// <summary>
425 /// Checks to see if the terrain has been modified since last check 426 /// Checks to see if the terrain has been modified since last check
427 /// but won't attempt to limit those changes to the limits specified in the estate settings
428 /// currently invoked by the command line operations in the region server only
426 /// </summary> 429 /// </summary>
427 private void CheckForTerrainUpdates() 430 private void CheckForTerrainUpdates()
428 { 431 {
432 CheckForTerrainUpdates(false);
433 }
434
435 /// <summary>
436 /// Checks to see if the terrain has been modified since last check
437 /// if the call is asked to respect the estate settings for terrain_raise_limit and
438 /// terrain_lower_limit, it will clamp terrain updates between these values
439 /// currently invoked by client_OnModifyTerrain only and not the Commander interfaces
440 /// <param name="respectEstateSettings">should height map deltas be limited to the estate settings limits</param>
441 /// </summary>
442 private void CheckForTerrainUpdates(bool respectEstateSettings)
443 {
429 bool shouldTaint = false; 444 bool shouldTaint = false;
430 float[] serialised = m_channel.GetFloatsSerialised(); 445 float[] serialised = m_channel.GetFloatsSerialised();
431 int x; 446 int x;
@@ -436,6 +451,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
436 { 451 {
437 if (m_channel.Tainted(x, y)) 452 if (m_channel.Tainted(x, y))
438 { 453 {
454 // if we should respect the estate settings then
455 // fixup and height deltas that don't respect them
456 if (respectEstateSettings && LimitChannelChanges(x, y))
457 {
458 // this has been vetoed, so update
459 // what we are going to send to the client
460 serialised = m_channel.GetFloatsSerialised();
461 }
439 SendToClients(serialised, x, y); 462 SendToClients(serialised, x, y);
440 shouldTaint = true; 463 shouldTaint = true;
441 } 464 }
@@ -447,6 +470,46 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
447 } 470 }
448 } 471 }
449 472
473
474 /// <summary>
475 /// Checks to see height deltas in the tainted terrain patch at xStart ,yStart
476 /// are all within the current estate limits
477 /// <returns>true if changes were limited, false otherwise</returns>
478 /// </summary>
479 private bool LimitChannelChanges(int xStart, int yStart)
480 {
481 bool changesLimited = false;
482 double minDelta = m_scene.RegionInfo.EstateSettings.terrainLowerLimit;
483 double maxDelta = m_scene.RegionInfo.EstateSettings.terrainRaiseLimit;
484
485 // loop through the height map for this patch and compare it against
486 // the revert map
487 for (int x = xStart; x < xStart + Constants.TerrainPatchSize; x++)
488 {
489 for (int y = yStart; y < yStart + Constants.TerrainPatchSize; y++)
490 {
491
492 double requestedHeight = m_channel[x, y];
493 double bakedHeight = m_revert[x, y];
494 double requestedDelta = requestedHeight - bakedHeight;
495
496 if (requestedDelta > maxDelta )
497 {
498 m_channel[x, y] = bakedHeight + maxDelta;
499 changesLimited = true;
500 }
501 else if (requestedDelta < minDelta)
502 {
503 m_channel[x, y] = bakedHeight + minDelta; //as lower is a -ve delta
504 changesLimited = true;
505 }
506 }
507 }
508
509 return changesLimited;
510 }
511
512
450 /// <summary> 513 /// <summary>
451 /// Sends a copy of the current terrain to the scenes clients 514 /// Sends a copy of the current terrain to the scenes clients
452 /// </summary> 515 /// </summary>
@@ -472,7 +535,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
472 m_painteffects[(StandardTerrainEffects) action].PaintEffect( 535 m_painteffects[(StandardTerrainEffects) action].PaintEffect(
473 m_channel, west, south, size, seconds); 536 m_channel, west, south, size, seconds);
474 537
475 CheckForTerrainUpdates(); 538 CheckForTerrainUpdates(true); //revert changes outside estate limits
476 } 539 }
477 else 540 else
478 { 541 {
@@ -505,7 +568,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
505 m_floodeffects[(StandardTerrainEffects) action].FloodEffect( 568 m_floodeffects[(StandardTerrainEffects) action].FloodEffect(
506 m_channel, fillArea, size); 569 m_channel, fillArea, size);
507 570
508 CheckForTerrainUpdates(); 571 CheckForTerrainUpdates(true); //revert changes outside estate limits
509 } 572 }
510 else 573 else
511 { 574 {
@@ -515,6 +578,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
515 } 578 }
516 } 579 }
517 580
581 private void client_OnBakeTerrain(IClientAPI remoteClient)
582 {
583 // Not a good permissions check (see client_OnModifyTerrain above), need to check the entire area.
584 // for now check a point in the centre of the region
585
586 if (m_scene.ExternalChecks.ExternalChecksCanTerraformLand(remoteClient.AgentId, new LLVector3(127, 127, 0)))
587 {
588 InterfaceBakeTerrain(null); //bake terrain does not use the passed in parameter
589 }
590 }
591
592
518 #region Console Commands 593 #region Console Commands
519 594
520 private void InterfaceLoadFile(Object[] args) 595 private void InterfaceLoadFile(Object[] args)
@@ -745,4 +820,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
745 820
746 #endregion 821 #endregion
747 } 822 }
748} \ No newline at end of file 823}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 6ff600f..0f7a057 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Region.Examples.SimpleModule
57 public event TextureRequest OnRequestTexture; 57 public event TextureRequest OnRequestTexture;
58 public event RezObject OnRezObject; 58 public event RezObject OnRezObject;
59 public event ModifyTerrain OnModifyTerrain; 59 public event ModifyTerrain OnModifyTerrain;
60 public event BakeTerrain OnBakeTerrain;
60 public event SetAppearance OnSetAppearance; 61 public event SetAppearance OnSetAppearance;
61 public event AvatarNowWearing OnAvatarNowWearing; 62 public event AvatarNowWearing OnAvatarNowWearing;
62 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; 63 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;