diff options
author | Charles Krinke | 2008-06-19 20:57:00 +0000 |
---|---|---|
committer | Charles Krinke | 2008-06-19 20:57:00 +0000 |
commit | 838ffd779280115dee2d24ddd9531728d7426942 (patch) | |
tree | 753ce7e8d03e83898cf07cac2c85ca8a382b0a67 /OpenSim/Region/Environment | |
parent | * Patch from Dahlia - 0001576: Exception of type 'System.OutOfMemoryException... (diff) | |
download | opensim-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/Environment')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs | 81 |
2 files changed, 81 insertions, 4 deletions
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 | } |