diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index fd30c46..d991a30 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -30,10 +30,14 @@ using System.Collections.Generic; | |||
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Net; | 32 | using System.Net; |
33 | |||
33 | using log4net; | 34 | using log4net; |
34 | using Nini.Config; | 35 | using Nini.Config; |
36 | |||
35 | using OpenMetaverse; | 37 | using OpenMetaverse; |
36 | using Mono.Addins; | 38 | using Mono.Addins; |
39 | |||
40 | using OpenSim.Data; | ||
37 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
38 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; | 42 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; |
39 | using OpenSim.Region.CoreModules.World.Terrain.FileLoaders; | 43 | using OpenSim.Region.CoreModules.World.Terrain.FileLoaders; |
@@ -70,6 +74,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
70 | #endregion | 74 | #endregion |
71 | 75 | ||
72 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
77 | private static readonly string LogHeader = "[TERRAIN MODULE]"; | ||
73 | 78 | ||
74 | private readonly Commander m_commander = new Commander("terrain"); | 79 | private readonly Commander m_commander = new Commander("terrain"); |
75 | 80 | ||
@@ -130,15 +135,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
130 | { | 135 | { |
131 | if (m_scene.Heightmap == null) | 136 | if (m_scene.Heightmap == null) |
132 | { | 137 | { |
133 | m_channel = new TerrainChannel(m_InitialTerrain); | 138 | m_channel = new TerrainChannel(m_InitialTerrain, (int)m_scene.RegionInfo.RegionSizeX, |
139 | (int)m_scene.RegionInfo.RegionSizeY, | ||
140 | (int)m_scene.RegionInfo.RegionSizeZ); | ||
134 | m_scene.Heightmap = m_channel; | 141 | m_scene.Heightmap = m_channel; |
135 | m_revert = new TerrainChannel(); | ||
136 | UpdateRevertMap(); | 142 | UpdateRevertMap(); |
137 | } | 143 | } |
138 | else | 144 | else |
139 | { | 145 | { |
140 | m_channel = m_scene.Heightmap; | 146 | m_channel = m_scene.Heightmap; |
141 | m_revert = new TerrainChannel(); | ||
142 | UpdateRevertMap(); | 147 | UpdateRevertMap(); |
143 | } | 148 | } |
144 | 149 | ||
@@ -230,11 +235,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
230 | try | 235 | try |
231 | { | 236 | { |
232 | ITerrainChannel channel = loader.Value.LoadFile(filename); | 237 | ITerrainChannel channel = loader.Value.LoadFile(filename); |
233 | if (channel.Width != Constants.RegionSize || channel.Height != Constants.RegionSize) | 238 | if (channel.Width != m_scene.RegionInfo.RegionSizeX || channel.Height != m_scene.RegionInfo.RegionSizeY) |
234 | { | 239 | { |
235 | // TerrainChannel expects a RegionSize x RegionSize map, currently | 240 | // TerrainChannel expects a RegionSize x RegionSize map, currently |
236 | throw new ArgumentException(String.Format("wrong size, use a file with size {0} x {1}", | 241 | throw new ArgumentException(String.Format("wrong size, use a file with size {0} x {1}", |
237 | Constants.RegionSize, Constants.RegionSize)); | 242 | m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY)); |
238 | } | 243 | } |
239 | m_log.DebugFormat("[TERRAIN]: Loaded terrain, wd/ht: {0}/{1}", channel.Width, channel.Height); | 244 | m_log.DebugFormat("[TERRAIN]: Loaded terrain, wd/ht: {0}/{1}", channel.Width, channel.Height); |
240 | m_scene.Heightmap = channel; | 245 | m_scene.Heightmap = channel; |
@@ -532,6 +537,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
532 | /// </summary> | 537 | /// </summary> |
533 | public void UpdateRevertMap() | 538 | public void UpdateRevertMap() |
534 | { | 539 | { |
540 | /* | ||
535 | int x; | 541 | int x; |
536 | for (x = 0; x < m_channel.Width; x++) | 542 | for (x = 0; x < m_channel.Width; x++) |
537 | { | 543 | { |
@@ -541,6 +547,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
541 | m_revert[x, y] = m_channel[x, y]; | 547 | m_revert[x, y] = m_channel[x, y]; |
542 | } | 548 | } |
543 | } | 549 | } |
550 | */ | ||
551 | m_revert = m_channel.MakeCopy(); | ||
544 | } | 552 | } |
545 | 553 | ||
546 | /// <summary> | 554 | /// <summary> |
@@ -553,8 +561,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
553 | /// <param name="fileStartY">Where to begin our slice</param> | 561 | /// <param name="fileStartY">Where to begin our slice</param> |
554 | public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) | 562 | public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) |
555 | { | 563 | { |
556 | int offsetX = (int) m_scene.RegionInfo.RegionLocX - fileStartX; | 564 | int offsetX = (int) m_scene.RegionInfo.LegacyRegionLocX - fileStartX; |
557 | int offsetY = (int) m_scene.RegionInfo.RegionLocY - fileStartY; | 565 | int offsetY = (int) m_scene.RegionInfo.LegacyRegionLocY - fileStartY; |
558 | 566 | ||
559 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) | 567 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) |
560 | { | 568 | { |
@@ -567,8 +575,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
567 | { | 575 | { |
568 | ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY, | 576 | ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY, |
569 | fileWidth, fileHeight, | 577 | fileWidth, fileHeight, |
570 | (int) Constants.RegionSize, | 578 | (int) m_scene.RegionInfo.RegionSizeX, |
571 | (int) Constants.RegionSize); | 579 | (int) m_scene.RegionInfo.RegionSizeY); |
572 | m_scene.Heightmap = channel; | 580 | m_scene.Heightmap = channel; |
573 | m_channel = channel; | 581 | m_channel = channel; |
574 | UpdateRevertMap(); | 582 | UpdateRevertMap(); |
@@ -594,14 +602,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
594 | /// <param name="fileStartY">The may y co-ordinate at which to begin the save.</param> | 602 | /// <param name="fileStartY">The may y co-ordinate at which to begin the save.</param> |
595 | public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) | 603 | public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) |
596 | { | 604 | { |
597 | int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; | 605 | int offsetX = (int)m_scene.RegionInfo.LegacyRegionLocX - fileStartX; |
598 | int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; | 606 | int offsetY = (int)m_scene.RegionInfo.LegacyRegionLocY - fileStartY; |
599 | 607 | ||
600 | if (offsetX < 0 || offsetX >= fileWidth || offsetY < 0 || offsetY >= fileHeight) | 608 | if (offsetX < 0 || offsetX >= fileWidth || offsetY < 0 || offsetY >= fileHeight) |
601 | { | 609 | { |
602 | MainConsole.Instance.OutputFormat( | 610 | MainConsole.Instance.OutputFormat( |
603 | "ERROR: file width + minimum X tile and file height + minimum Y tile must incorporate the current region at ({0},{1}). File width {2} from {3} and file height {4} from {5} does not.", | 611 | "ERROR: file width + minimum X tile and file height + minimum Y tile must incorporate the current region at ({0},{1}). File width {2} from {3} and file height {4} from {5} does not.", |
604 | m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, fileWidth, fileStartX, fileHeight, fileStartY); | 612 | m_scene.RegionInfo.LegacyRegionLocX, m_scene.RegionInfo.LegacyRegionLocY, fileWidth, fileStartX, fileHeight, fileStartY); |
605 | 613 | ||
606 | return; | 614 | return; |
607 | } | 615 | } |
@@ -615,8 +623,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
615 | { | 623 | { |
616 | loader.Value.SaveFile(m_channel, filename, offsetX, offsetY, | 624 | loader.Value.SaveFile(m_channel, filename, offsetX, offsetY, |
617 | fileWidth, fileHeight, | 625 | fileWidth, fileHeight, |
618 | (int)Constants.RegionSize, | 626 | (int)m_scene.RegionInfo.RegionSizeX, |
619 | (int)Constants.RegionSize); | 627 | (int)m_scene.RegionInfo.RegionSizeY); |
620 | 628 | ||
621 | MainConsole.Instance.OutputFormat( | 629 | MainConsole.Instance.OutputFormat( |
622 | "Saved terrain from ({0},{1}) to ({2},{3}) from {4} to {5}", | 630 | "Saved terrain from ({0},{1}) to ({2},{3}) from {4} to {5}", |
@@ -705,7 +713,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
705 | private void CheckForTerrainUpdates(bool respectEstateSettings) | 713 | private void CheckForTerrainUpdates(bool respectEstateSettings) |
706 | { | 714 | { |
707 | bool shouldTaint = false; | 715 | bool shouldTaint = false; |
708 | float[] serialised = m_channel.GetFloatsSerialised(); | 716 | float[] terrHeights = m_channel.GetFloatsSerialised(); |
709 | int x; | 717 | int x; |
710 | for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize) | 718 | for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize) |
711 | { | 719 | { |
@@ -714,16 +722,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
714 | { | 722 | { |
715 | if (m_channel.Tainted(x, y)) | 723 | if (m_channel.Tainted(x, y)) |
716 | { | 724 | { |
717 | // if we should respect the estate settings then | 725 | // If we should respect the estate settings then |
718 | // fixup and height deltas that don't respect them | 726 | // fixup and height deltas that don't respect them. |
727 | // Note that LimitChannelChanges() modifies the TerrainChannel with the limited height values. | ||
719 | if (respectEstateSettings && LimitChannelChanges(x, y)) | 728 | if (respectEstateSettings && LimitChannelChanges(x, y)) |
720 | { | 729 | { |
721 | // this has been vetoed, so update | 730 | // Terrain heights were modified. Refetch the terrain info. |
722 | // what we are going to send to the client | 731 | terrHeights = m_channel.GetFloatsSerialised(); |
723 | serialised = m_channel.GetFloatsSerialised(); | ||
724 | } | 732 | } |
725 | 733 | ||
726 | SendToClients(serialised, x, y); | 734 | // m_log.DebugFormat("{0} Patch modified. Sending (x,y) = ({1},{2})", LogHeader, x, y); |
735 | SendToClients(terrHeights, x, y); | ||
727 | shouldTaint = true; | 736 | shouldTaint = true; |
728 | } | 737 | } |
729 | } | 738 | } |
@@ -792,13 +801,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
792 | /// <param name="serialised">A copy of the terrain as a 1D float array of size w*h</param> | 801 | /// <param name="serialised">A copy of the terrain as a 1D float array of size w*h</param> |
793 | /// <param name="x">The patch corner to send</param> | 802 | /// <param name="x">The patch corner to send</param> |
794 | /// <param name="y">The patch corner to send</param> | 803 | /// <param name="y">The patch corner to send</param> |
795 | private void SendToClients(float[] serialised, int x, int y) | 804 | private void SendToClients(float[] heightMap, int x, int y) |
796 | { | 805 | { |
797 | m_scene.ForEachClient( | 806 | m_scene.ForEachClient( |
798 | delegate(IClientAPI controller) | 807 | delegate(IClientAPI controller) |
799 | { controller.SendLayerData( | 808 | { controller.SendLayerData( x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, heightMap); } |
800 | x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised); | ||
801 | } | ||
802 | ); | 809 | ); |
803 | } | 810 | } |
804 | 811 | ||
@@ -984,28 +991,28 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
984 | 991 | ||
985 | if (direction.ToLower().StartsWith("y")) | 992 | if (direction.ToLower().StartsWith("y")) |
986 | { | 993 | { |
987 | for (int x = 0; x < Constants.RegionSize; x++) | 994 | for (int x = 0; x < m_channel.Width; x++) |
988 | { | 995 | { |
989 | for (int y = 0; y < Constants.RegionSize / 2; y++) | 996 | for (int y = 0; y < m_channel.Height / 2; y++) |
990 | { | 997 | { |
991 | double height = m_channel[x, y]; | 998 | double height = m_channel[x, y]; |
992 | double flippedHeight = m_channel[x, (int)Constants.RegionSize - 1 - y]; | 999 | double flippedHeight = m_channel[x, (int)m_channel.Height - 1 - y]; |
993 | m_channel[x, y] = flippedHeight; | 1000 | m_channel[x, y] = flippedHeight; |
994 | m_channel[x, (int)Constants.RegionSize - 1 - y] = height; | 1001 | m_channel[x, (int)m_channel.Height - 1 - y] = height; |
995 | 1002 | ||
996 | } | 1003 | } |
997 | } | 1004 | } |
998 | } | 1005 | } |
999 | else if (direction.ToLower().StartsWith("x")) | 1006 | else if (direction.ToLower().StartsWith("x")) |
1000 | { | 1007 | { |
1001 | for (int y = 0; y < Constants.RegionSize; y++) | 1008 | for (int y = 0; y < m_channel.Height; y++) |
1002 | { | 1009 | { |
1003 | for (int x = 0; x < Constants.RegionSize / 2; x++) | 1010 | for (int x = 0; x < m_channel.Width / 2; x++) |
1004 | { | 1011 | { |
1005 | double height = m_channel[x, y]; | 1012 | double height = m_channel[x, y]; |
1006 | double flippedHeight = m_channel[(int)Constants.RegionSize - 1 - x, y]; | 1013 | double flippedHeight = m_channel[(int)m_channel.Width - 1 - x, y]; |
1007 | m_channel[x, y] = flippedHeight; | 1014 | m_channel[x, y] = flippedHeight; |
1008 | m_channel[(int)Constants.RegionSize - 1 - x, y] = height; | 1015 | m_channel[(int)m_channel.Width - 1 - x, y] = height; |
1009 | 1016 | ||
1010 | } | 1017 | } |
1011 | } | 1018 | } |