diff options
Diffstat (limited to 'OpenSim/Region')
27 files changed, 1271 insertions, 287 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 12250df..e241274 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -781,8 +781,8 @@ namespace OpenSim | |||
781 | MainConsole.Instance.Output(String.Format( | 781 | MainConsole.Instance.Output(String.Format( |
782 | "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}, Estate Name: {4}", | 782 | "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}, Estate Name: {4}", |
783 | scene.RegionInfo.RegionName, | 783 | scene.RegionInfo.RegionName, |
784 | scene.RegionInfo.RegionLocX, | 784 | scene.RegionInfo.LegacyRegionLocX, |
785 | scene.RegionInfo.RegionLocY, | 785 | scene.RegionInfo.LegacyRegionLocY, |
786 | scene.RegionInfo.InternalEndPoint.Port, | 786 | scene.RegionInfo.InternalEndPoint.Port, |
787 | scene.RegionInfo.EstateSettings.EstateName)); | 787 | scene.RegionInfo.EstateSettings.EstateName)); |
788 | }); | 788 | }); |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index b032e7f..1e34a1e 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -742,7 +742,7 @@ namespace OpenSim | |||
742 | { | 742 | { |
743 | m_log.InfoFormat( | 743 | m_log.InfoFormat( |
744 | "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})", | 744 | "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})", |
745 | whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY); | 745 | whichRegion.RegionName, whichRegion.LegacyRegionLocX, whichRegion.LegacyRegionLocY); |
746 | 746 | ||
747 | ShutdownClientServer(whichRegion); | 747 | ShutdownClientServer(whichRegion); |
748 | IScene scene; | 748 | IScene scene; |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 6b58fb7..7984acc 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -34,11 +34,13 @@ using System.Text; | |||
34 | using System.Threading; | 34 | using System.Threading; |
35 | using System.Timers; | 35 | using System.Timers; |
36 | using System.Xml; | 36 | using System.Xml; |
37 | |||
37 | using log4net; | 38 | using log4net; |
38 | using OpenMetaverse; | 39 | using OpenMetaverse; |
39 | using OpenMetaverse.Packets; | 40 | using OpenMetaverse.Packets; |
40 | using OpenMetaverse.Messages.Linden; | 41 | using OpenMetaverse.Messages.Linden; |
41 | using OpenMetaverse.StructuredData; | 42 | using OpenMetaverse.StructuredData; |
43 | |||
42 | using OpenSim.Framework; | 44 | using OpenSim.Framework; |
43 | using OpenSim.Framework.Client; | 45 | using OpenSim.Framework.Client; |
44 | using OpenSim.Framework.Monitoring; | 46 | using OpenSim.Framework.Monitoring; |
@@ -48,7 +50,6 @@ using OpenSim.Services.Interfaces; | |||
48 | using Timer = System.Timers.Timer; | 50 | using Timer = System.Timers.Timer; |
49 | using AssetLandmark = OpenSim.Framework.AssetLandmark; | 51 | using AssetLandmark = OpenSim.Framework.AssetLandmark; |
50 | using RegionFlags = OpenMetaverse.RegionFlags; | 52 | using RegionFlags = OpenMetaverse.RegionFlags; |
51 | using Nini.Config; | ||
52 | 53 | ||
53 | using System.IO; | 54 | using System.IO; |
54 | using PermissionMask = OpenSim.Framework.PermissionMask; | 55 | using PermissionMask = OpenSim.Framework.PermissionMask; |
@@ -307,6 +308,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
307 | private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; | 308 | private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; |
308 | 309 | ||
309 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 310 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
311 | private static string LogHeader = "[LLCLIENTVIEW]"; | ||
310 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients | 312 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients |
311 | 313 | ||
312 | /// <summary> | 314 | /// <summary> |
@@ -447,7 +449,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
447 | 449 | ||
448 | // ~LLClientView() | 450 | // ~LLClientView() |
449 | // { | 451 | // { |
450 | // m_log.DebugFormat("[LLCLIENTVIEW]: Destructor called for {0}, circuit code {1}", Name, CircuitCode); | 452 | // m_log.DebugFormat("{0} Destructor called for {1}, circuit code {2}", LogHeader, Name, CircuitCode); |
451 | // } | 453 | // } |
452 | 454 | ||
453 | /// <summary> | 455 | /// <summary> |
@@ -513,9 +515,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
513 | // there is some unidentified connection problem, not where we have issues due to deadlock | 515 | // there is some unidentified connection problem, not where we have issues due to deadlock |
514 | if (!IsActive && !force) | 516 | if (!IsActive && !force) |
515 | { | 517 | { |
516 | m_log.DebugFormat( | 518 | m_log.DebugFormat( "{0} Not attempting to close inactive client {1} in {2} since force flag is not set", |
517 | "[CLIENT]: Not attempting to close inactive client {0} in {1} since force flag is not set", | 519 | LogHeader, Name, m_scene.Name); |
518 | Name, m_scene.Name); | ||
519 | 520 | ||
520 | return; | 521 | return; |
521 | } | 522 | } |
@@ -1162,10 +1163,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1162 | /// <param name="o"></param> | 1163 | /// <param name="o"></param> |
1163 | private void DoSendLayerData(object o) | 1164 | private void DoSendLayerData(object o) |
1164 | { | 1165 | { |
1165 | float[] map = LLHeightFieldMoronize((float[])o); | 1166 | float[] map = (float[])o; |
1166 | 1167 | ||
1167 | try | 1168 | try |
1168 | { | 1169 | { |
1170 | // Send LayerData in typerwriter pattern | ||
1169 | //for (int y = 0; y < 16; y++) | 1171 | //for (int y = 0; y < 16; y++) |
1170 | //{ | 1172 | //{ |
1171 | // for (int x = 0; x < 16; x++) | 1173 | // for (int x = 0; x < 16; x++) |
@@ -1230,7 +1232,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1230 | // } | 1232 | // } |
1231 | 1233 | ||
1232 | /// <summary> | 1234 | /// <summary> |
1233 | /// Sends a specified patch to a client | 1235 | /// Sends a terrain packet for the point specified. |
1236 | /// This is a legacy call that has refarbed the terrain into a flat map of floats. | ||
1237 | /// We just use the terrain from the region we know about. | ||
1234 | /// </summary> | 1238 | /// </summary> |
1235 | /// <param name="px">Patch coordinate (x) 0..15</param> | 1239 | /// <param name="px">Patch coordinate (x) 0..15</param> |
1236 | /// <param name="py">Patch coordinate (y) 0..15</param> | 1240 | /// <param name="py">Patch coordinate (y) 0..15</param> |
@@ -1239,12 +1243,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1239 | { | 1243 | { |
1240 | try | 1244 | try |
1241 | { | 1245 | { |
1242 | int[] patches = new int[] { py * 16 + px }; | 1246 | // For unknown reasons, after this point, patch numbers are swapped X for y. |
1243 | float[] heightmap = (map.Length == 65536) ? | 1247 | // That means, that for <patchNumX, patchNumY, the array location is computed as map[patchNumY * 16 + patchNumX]. |
1244 | map : | 1248 | // TODO: someday straighten the below implementation to keep the X row order for patch numbers. |
1245 | LLHeightFieldMoronize(map); | 1249 | // Since this is passing only one patch, we just swap the patch numbers. |
1246 | 1250 | LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLandPacket(m_scene.Heightmap.GetTerrainData(), px, py); | |
1247 | LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); | ||
1248 | 1251 | ||
1249 | // When a user edits the terrain, so much data is sent, the data queues up fast and presents a sub optimal editing experience. | 1252 | // When a user edits the terrain, so much data is sent, the data queues up fast and presents a sub optimal editing experience. |
1250 | // To alleviate this issue, when the user edits the terrain, we start skipping the queues until they're done editing the terrain. | 1253 | // To alleviate this issue, when the user edits the terrain, we start skipping the queues until they're done editing the terrain. |
@@ -1262,14 +1265,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1262 | if (m_justEditedTerrain) | 1265 | if (m_justEditedTerrain) |
1263 | { | 1266 | { |
1264 | layerpack.Header.Reliable = false; | 1267 | layerpack.Header.Reliable = false; |
1265 | OutPacket(layerpack, | 1268 | OutPacket(layerpack, ThrottleOutPacketType.Unknown ); |
1266 | ThrottleOutPacketType.Unknown ); | ||
1267 | } | 1269 | } |
1268 | else | 1270 | else |
1269 | { | 1271 | { |
1270 | layerpack.Header.Reliable = true; | 1272 | layerpack.Header.Reliable = true; |
1271 | OutPacket(layerpack, | 1273 | OutPacket(layerpack, ThrottleOutPacketType.Land); |
1272 | ThrottleOutPacketType.Land); | ||
1273 | } | 1274 | } |
1274 | } | 1275 | } |
1275 | catch (Exception e) | 1276 | catch (Exception e) |
@@ -1279,38 +1280,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1279 | } | 1280 | } |
1280 | 1281 | ||
1281 | /// <summary> | 1282 | /// <summary> |
1282 | /// Munges heightfield into the LLUDP backed in restricted heightfield. | ||
1283 | /// </summary> | ||
1284 | /// <param name="map">float array in the base; Constants.RegionSize</param> | ||
1285 | /// <returns>float array in the base 256</returns> | ||
1286 | internal float[] LLHeightFieldMoronize(float[] map) | ||
1287 | { | ||
1288 | if (map.Length == 65536) | ||
1289 | return map; | ||
1290 | else | ||
1291 | { | ||
1292 | float[] returnmap = new float[65536]; | ||
1293 | |||
1294 | if (map.Length < 65535) | ||
1295 | { | ||
1296 | // rebase the vector stride to 256 | ||
1297 | for (int i = 0; i < Constants.RegionSize; i++) | ||
1298 | Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, (int)Constants.RegionSize); | ||
1299 | } | ||
1300 | else | ||
1301 | { | ||
1302 | for (int i = 0; i < 256; i++) | ||
1303 | Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, 256); | ||
1304 | } | ||
1305 | |||
1306 | //Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536); | ||
1307 | |||
1308 | return returnmap; | ||
1309 | } | ||
1310 | |||
1311 | } | ||
1312 | |||
1313 | /// <summary> | ||
1314 | /// Send the wind matrix to the client | 1283 | /// Send the wind matrix to the client |
1315 | /// </summary> | 1284 | /// </summary> |
1316 | /// <param name="windSpeeds">16x16 array of wind speeds</param> | 1285 | /// <param name="windSpeeds">16x16 array of wind speeds</param> |
@@ -2782,8 +2751,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2782 | { | 2751 | { |
2783 | if (req.AssetInf.Data == null) | 2752 | if (req.AssetInf.Data == null) |
2784 | { | 2753 | { |
2785 | m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null", | 2754 | m_log.ErrorFormat("{0} Cannot send asset {1} ({2}), asset data is null", |
2786 | req.AssetInf.ID, req.AssetInf.Metadata.ContentType); | 2755 | LogHeader, req.AssetInf.ID, req.AssetInf.Metadata.ContentType); |
2787 | return; | 2756 | return; |
2788 | } | 2757 | } |
2789 | 2758 | ||
@@ -2910,8 +2879,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2910 | { | 2879 | { |
2911 | pos = (land.AABBMax + land.AABBMin) * 0.5f; | 2880 | pos = (land.AABBMax + land.AABBMin) * 0.5f; |
2912 | } | 2881 | } |
2913 | reply.Data.GlobalX = info.RegionLocX + x; | 2882 | reply.Data.GlobalX = info.LegacyRegionLocX + x; |
2914 | reply.Data.GlobalY = info.RegionLocY + y; | 2883 | reply.Data.GlobalY = info.LegacyRegionLocY + y; |
2915 | reply.Data.GlobalZ = pos.Z; | 2884 | reply.Data.GlobalZ = pos.Z; |
2916 | reply.Data.SimName = Utils.StringToBytes(info.RegionName); | 2885 | reply.Data.SimName = Utils.StringToBytes(info.RegionName); |
2917 | reply.Data.SnapshotID = land.SnapshotID; | 2886 | reply.Data.SnapshotID = land.SnapshotID; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 27ace68..db62b31 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -189,8 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
189 | string message = c.Message; | 189 | string message = c.Message; |
190 | Scene scene = (Scene)c.Scene; | 190 | Scene scene = (Scene)c.Scene; |
191 | Vector3 fromPos = c.Position; | 191 | Vector3 fromPos = c.Position; |
192 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, | 192 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionWorldLocX, scene.RegionInfo.RegionWorldLocY, 0); |
193 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | ||
194 | 193 | ||
195 | if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; | 194 | if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; |
196 | 195 | ||
@@ -342,8 +341,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
342 | { | 341 | { |
343 | Vector3 fromRegionPos = fromPos + regionPos; | 342 | Vector3 fromRegionPos = fromPos + regionPos; |
344 | Vector3 toRegionPos = presence.AbsolutePosition + | 343 | Vector3 toRegionPos = presence.AbsolutePosition + |
345 | new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, | 344 | new Vector3(presence.Scene.RegionInfo.RegionWorldLocX, presence.Scene.RegionInfo.RegionWorldLocY, 0); |
346 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | ||
347 | 345 | ||
348 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); | 346 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); |
349 | 347 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 56ff2bd..a982466 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | |||
@@ -663,8 +663,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles | |||
663 | 663 | ||
664 | Vector3 avaPos = p.AbsolutePosition; | 664 | Vector3 avaPos = p.AbsolutePosition; |
665 | // Getting the global position for the Avatar | 665 | // Getting the global position for the Avatar |
666 | Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.RegionLocX*Constants.RegionSize + avaPos.X, | 666 | Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.RegionWorldLocX + avaPos.X, |
667 | remoteClient.Scene.RegionInfo.RegionLocY*Constants.RegionSize + avaPos.Y, | 667 | remoteClient.Scene.RegionInfo.RegionWorldLocY + avaPos.Y, |
668 | avaPos.Z); | 668 | avaPos.Z); |
669 | 669 | ||
670 | string landOwnerName = string.Empty; | 670 | string landOwnerName = string.Empty; |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index aa8a4db..eb1b271 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -494,8 +494,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
494 | } | 494 | } |
495 | 495 | ||
496 | // Check that these are not the same coordinates | 496 | // Check that these are not the same coordinates |
497 | if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX && | 497 | if (finalDestination.RegionLocX == sp.Scene.RegionInfo.LegacyRegionLocX && |
498 | finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY) | 498 | finalDestination.RegionLocY == sp.Scene.RegionInfo.LegacyRegionLocY) |
499 | { | 499 | { |
500 | // Can't do. Viewer crashes | 500 | // Can't do. Viewer crashes |
501 | sp.ControllingClient.SendTeleportFailed("Space warp! You would crash. Move to a different region and try again."); | 501 | sp.ControllingClient.SendTeleportFailed("Space warp! You would crash. Move to a different region and try again."); |
@@ -567,8 +567,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
567 | // destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI); | 567 | // destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI); |
568 | 568 | ||
569 | // Insanely, RegionLoc on RegionInfo is the 256m map co-ord whilst GridRegion.RegionLoc is the raw meters position. | 569 | // Insanely, RegionLoc on RegionInfo is the 256m map co-ord whilst GridRegion.RegionLoc is the raw meters position. |
570 | return Math.Abs(sourceRegion.RegionLocX - destRegion.RegionCoordX) <= MaxTransferDistance | 570 | return Math.Abs(sourceRegion.LegacyRegionLocX - destRegion.RegionCoordX) <= MaxTransferDistance |
571 | && Math.Abs(sourceRegion.RegionLocY - destRegion.RegionCoordY) <= MaxTransferDistance; | 571 | && Math.Abs(sourceRegion.LegacyRegionLocY - destRegion.RegionCoordY) <= MaxTransferDistance; |
572 | } | 572 | } |
573 | 573 | ||
574 | /// <summary> | 574 | /// <summary> |
@@ -635,7 +635,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
635 | string.Format( | 635 | string.Format( |
636 | "Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way", | 636 | "Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way", |
637 | finalDestination.RegionName, finalDestination.RegionCoordX, finalDestination.RegionCoordY, | 637 | finalDestination.RegionName, finalDestination.RegionCoordX, finalDestination.RegionCoordY, |
638 | sourceRegion.RegionName, sourceRegion.RegionLocX, sourceRegion.RegionLocY, | 638 | sourceRegion.RegionName, sourceRegion.LegacyRegionLocX, sourceRegion.LegacyRegionLocY, |
639 | MaxTransferDistance)); | 639 | MaxTransferDistance)); |
640 | 640 | ||
641 | return; | 641 | return; |
@@ -1374,8 +1374,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1374 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); | 1374 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); |
1375 | 1375 | ||
1376 | Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); | 1376 | Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); |
1377 | uint neighbourx = scene.RegionInfo.RegionLocX; | 1377 | uint neighbourx = scene.RegionInfo.LegacyRegionLocX; |
1378 | uint neighboury = scene.RegionInfo.RegionLocY; | 1378 | uint neighboury = scene.RegionInfo.LegacyRegionLocY; |
1379 | const float boundaryDistance = 1.7f; | 1379 | const float boundaryDistance = 1.7f; |
1380 | Vector3 northCross = new Vector3(0, boundaryDistance, 0); | 1380 | Vector3 northCross = new Vector3(0, boundaryDistance, 0); |
1381 | Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); | 1381 | Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); |
@@ -1408,8 +1408,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1408 | neighbourx = b.TriggerRegionX; | 1408 | neighbourx = b.TriggerRegionX; |
1409 | 1409 | ||
1410 | Vector3 newposition = pos; | 1410 | Vector3 newposition = pos; |
1411 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | 1411 | newposition.X += (scene.RegionInfo.LegacyRegionLocX - neighbourx) * Constants.RegionSize; |
1412 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | 1412 | newposition.Y += (scene.RegionInfo.LegacyRegionLocY - neighboury) * Constants.RegionSize; |
1413 | agent.ControllingClient.SendAgentAlertMessage( | 1413 | agent.ControllingClient.SendAgentAlertMessage( |
1414 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | 1414 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); |
1415 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | 1415 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); |
@@ -1431,8 +1431,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1431 | neighbourx = ba.TriggerRegionX; | 1431 | neighbourx = ba.TriggerRegionX; |
1432 | 1432 | ||
1433 | Vector3 newposition = pos; | 1433 | Vector3 newposition = pos; |
1434 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | 1434 | newposition.X += (scene.RegionInfo.LegacyRegionLocX - neighbourx) * Constants.RegionSize; |
1435 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | 1435 | newposition.Y += (scene.RegionInfo.LegacyRegionLocY - neighboury) * Constants.RegionSize; |
1436 | agent.ControllingClient.SendAgentAlertMessage( | 1436 | agent.ControllingClient.SendAgentAlertMessage( |
1437 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | 1437 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); |
1438 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | 1438 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); |
@@ -1462,8 +1462,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1462 | neighboury = ba.TriggerRegionY; | 1462 | neighboury = ba.TriggerRegionY; |
1463 | neighbourx = ba.TriggerRegionX; | 1463 | neighbourx = ba.TriggerRegionX; |
1464 | Vector3 newposition = pos; | 1464 | Vector3 newposition = pos; |
1465 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | 1465 | newposition.X += (scene.RegionInfo.LegacyRegionLocX - neighbourx) * Constants.RegionSize; |
1466 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | 1466 | newposition.Y += (scene.RegionInfo.LegacyRegionLocY - neighboury) * Constants.RegionSize; |
1467 | agent.ControllingClient.SendAgentAlertMessage( | 1467 | agent.ControllingClient.SendAgentAlertMessage( |
1468 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | 1468 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); |
1469 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | 1469 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); |
@@ -1492,8 +1492,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1492 | neighboury = b.TriggerRegionY; | 1492 | neighboury = b.TriggerRegionY; |
1493 | neighbourx = b.TriggerRegionX; | 1493 | neighbourx = b.TriggerRegionX; |
1494 | Vector3 newposition = pos; | 1494 | Vector3 newposition = pos; |
1495 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | 1495 | newposition.X += (scene.RegionInfo.LegacyRegionLocX - neighbourx) * Constants.RegionSize; |
1496 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | 1496 | newposition.Y += (scene.RegionInfo.LegacyRegionLocY - neighboury) * Constants.RegionSize; |
1497 | agent.ControllingClient.SendAgentAlertMessage( | 1497 | agent.ControllingClient.SendAgentAlertMessage( |
1498 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | 1498 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); |
1499 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | 1499 | InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); |
@@ -1901,7 +1901,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1901 | 1901 | ||
1902 | if (m_regionInfo != null) | 1902 | if (m_regionInfo != null) |
1903 | { | 1903 | { |
1904 | neighbours = RequestNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); | 1904 | neighbours = RequestNeighbours(sp, m_regionInfo.LegacyRegionLocX, m_regionInfo.LegacyRegionLocY); |
1905 | } | 1905 | } |
1906 | else | 1906 | else |
1907 | { | 1907 | { |
@@ -2057,8 +2057,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2057 | 2057 | ||
2058 | Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour) | 2058 | Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour) |
2059 | { | 2059 | { |
2060 | int rRegionX = (int)sp.Scene.RegionInfo.RegionLocX; | 2060 | int rRegionX = (int)sp.Scene.RegionInfo.LegacyRegionLocX; |
2061 | int rRegionY = (int)sp.Scene.RegionInfo.RegionLocY; | 2061 | int rRegionY = (int)sp.Scene.RegionInfo.LegacyRegionLocY; |
2062 | int tRegionX = neighbour.RegionLocX / (int)Constants.RegionSize; | 2062 | int tRegionX = neighbour.RegionLocX / (int)Constants.RegionSize; |
2063 | int tRegionY = neighbour.RegionLocY / (int)Constants.RegionSize; | 2063 | int tRegionY = neighbour.RegionLocY / (int)Constants.RegionSize; |
2064 | int shiftx = (rRegionX - tRegionX) * (int)Constants.RegionSize; | 2064 | int shiftx = (rRegionX - tRegionX) * (int)Constants.RegionSize; |
@@ -2161,10 +2161,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2161 | extent.X = ((int)extent.X / (int)Constants.RegionSize); | 2161 | extent.X = ((int)extent.X / (int)Constants.RegionSize); |
2162 | extent.Y = ((int)extent.Y / (int)Constants.RegionSize); | 2162 | extent.Y = ((int)extent.Y / (int)Constants.RegionSize); |
2163 | 2163 | ||
2164 | swCorner.X = Scene.RegionInfo.RegionLocX - 1; | 2164 | swCorner.X = Scene.RegionInfo.LegacyRegionLocX - 1; |
2165 | swCorner.Y = Scene.RegionInfo.RegionLocY - 1; | 2165 | swCorner.Y = Scene.RegionInfo.LegacyRegionLocY - 1; |
2166 | neCorner.X = Scene.RegionInfo.RegionLocX + extent.X; | 2166 | neCorner.X = Scene.RegionInfo.LegacyRegionLocX + extent.X; |
2167 | neCorner.Y = Scene.RegionInfo.RegionLocY + extent.Y; | 2167 | neCorner.Y = Scene.RegionInfo.LegacyRegionLocY + extent.Y; |
2168 | } | 2168 | } |
2169 | 2169 | ||
2170 | /// <summary> | 2170 | /// <summary> |
@@ -2301,8 +2301,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2301 | return; | 2301 | return; |
2302 | } | 2302 | } |
2303 | 2303 | ||
2304 | int thisx = (int)scene.RegionInfo.RegionLocX; | 2304 | int thisx = (int)scene.RegionInfo.LegacyRegionLocX; |
2305 | int thisy = (int)scene.RegionInfo.RegionLocY; | 2305 | int thisy = (int)scene.RegionInfo.LegacyRegionLocY; |
2306 | Vector3 EastCross = new Vector3(0.1f, 0, 0); | 2306 | Vector3 EastCross = new Vector3(0.1f, 0, 0); |
2307 | Vector3 WestCross = new Vector3(-0.1f, 0, 0); | 2307 | Vector3 WestCross = new Vector3(-0.1f, 0, 0); |
2308 | Vector3 NorthCross = new Vector3(0, 0.1f, 0); | 2308 | Vector3 NorthCross = new Vector3(0, 0.1f, 0); |
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index d943b20..bf87392 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | |||
@@ -213,8 +213,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
213 | if (part != null) | 213 | if (part != null) |
214 | { | 214 | { |
215 | ObjectRegionName = s.RegionInfo.RegionName; | 215 | ObjectRegionName = s.RegionInfo.RegionName; |
216 | uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); | 216 | uint localX = s.RegionInfo.RegionWorldLocX; |
217 | uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); | 217 | uint localY = s.RegionInfo.RegionWorldLocY; |
218 | ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; | 218 | ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; |
219 | return part; | 219 | return part; |
220 | } | 220 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 26d22b8..c1f2f04 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -224,10 +224,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
224 | } | 224 | } |
225 | 225 | ||
226 | string reason = string.Empty; | 226 | string reason = string.Empty; |
227 | if (!m_MapService.AddMapTile((int)scene.RegionInfo.RegionLocX, (int)scene.RegionInfo.RegionLocY, jpgData, out reason)) | 227 | if (!m_MapService.AddMapTile((int)scene.RegionInfo.LegacyRegionLocX, (int)scene.RegionInfo.LegacyRegionLocY, jpgData, out reason)) |
228 | { | 228 | { |
229 | m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: Unable to upload tile image for {0} at {1}-{2}: {3}", | 229 | m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: Unable to upload tile image for {0} at {1}-{2}: {3}", |
230 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, reason); | 230 | scene.RegionInfo.RegionName, scene.RegionInfo.LegacyRegionLocX, scene.RegionInfo.LegacyRegionLocY, reason); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | } | 233 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs index d8dace2..9aa4243 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs | |||
@@ -71,8 +71,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
71 | 71 | ||
72 | public void AddScene(Scene scene) | 72 | public void AddScene(Scene scene) |
73 | { | 73 | { |
74 | uint x = scene.RegionInfo.RegionLocX; | 74 | uint x = scene.RegionInfo.LegacyRegionLocX; |
75 | uint y = scene.RegionInfo.RegionLocY; | 75 | uint y = scene.RegionInfo.LegacyRegionLocY; |
76 | 76 | ||
77 | SortedDictionary<uint, Scene> row; | 77 | SortedDictionary<uint, Scene> row; |
78 | if (!Regions.TryGetValue(y, out row)) | 78 | if (!Regions.TryGetValue(y, out row)) |
@@ -120,8 +120,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
120 | { | 120 | { |
121 | // We add the region's coordinates to ensure uniqueness even if multiple regions have the same name | 121 | // We add the region's coordinates to ensure uniqueness even if multiple regions have the same name |
122 | string path = string.Format("{0}_{1}_{2}", | 122 | string path = string.Format("{0}_{1}_{2}", |
123 | scene.RegionInfo.RegionLocX - Rect.X + 1, | 123 | scene.RegionInfo.LegacyRegionLocX - Rect.X + 1, |
124 | scene.RegionInfo.RegionLocY - Rect.Y + 1, | 124 | scene.RegionInfo.LegacyRegionLocY - Rect.Y + 1, |
125 | scene.RegionInfo.RegionName.Replace(' ', '_')); | 125 | scene.RegionInfo.RegionName.Replace(' ', '_')); |
126 | m_regionDirs[scene.RegionInfo.RegionID] = path; | 126 | m_regionDirs[scene.RegionInfo.RegionID] = path; |
127 | }); | 127 | }); |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/DearchiveScenesGroup.cs b/OpenSim/Region/CoreModules/World/Archiver/DearchiveScenesGroup.cs index 3dcc020..25f1e5c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/DearchiveScenesGroup.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/DearchiveScenesGroup.cs | |||
@@ -145,7 +145,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
145 | { | 145 | { |
146 | foreach (RegionInfo archivedRegion in m_directory2region.Values) | 146 | foreach (RegionInfo archivedRegion in m_directory2region.Values) |
147 | { | 147 | { |
148 | Point location = new Point((int)rootScene.RegionInfo.RegionLocX, (int)rootScene.RegionInfo.RegionLocY); | 148 | Point location = new Point((int)rootScene.RegionInfo.LegacyRegionLocX, (int)rootScene.RegionInfo.LegacyRegionLocY); |
149 | location.Offset(archivedRegion.Location); | 149 | location.Offset(archivedRegion.Location); |
150 | 150 | ||
151 | Scene scene; | 151 | Scene scene; |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs index 173b603..bc172a4 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | |||
@@ -96,9 +96,9 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
96 | int x = (args.Length > 5 ? int.Parse(args[5]) : -1); | 96 | int x = (args.Length > 5 ? int.Parse(args[5]) : -1); |
97 | int y = (args.Length > 6 ? int.Parse(args[6]) : -1); | 97 | int y = (args.Length > 6 ? int.Parse(args[6]) : -1); |
98 | 98 | ||
99 | if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x) | 99 | if (x == -1 || m_module.Scene.RegionInfo.LegacyRegionLocX == x) |
100 | { | 100 | { |
101 | if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y) | 101 | if (y == -1 || m_module.Scene.RegionInfo.LegacyRegionLocY == y) |
102 | { | 102 | { |
103 | int corner = int.Parse(num); | 103 | int corner = int.Parse(num); |
104 | UUID texture = UUID.Parse(uuid); | 104 | UUID texture = UUID.Parse(uuid); |
@@ -135,9 +135,9 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
135 | int x = (args.Length > 4 ? int.Parse(args[4]) : -1); | 135 | int x = (args.Length > 4 ? int.Parse(args[4]) : -1); |
136 | int y = (args.Length > 5 ? int.Parse(args[5]) : -1); | 136 | int y = (args.Length > 5 ? int.Parse(args[5]) : -1); |
137 | 137 | ||
138 | if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x) | 138 | if (x == -1 || m_module.Scene.RegionInfo.LegacyRegionLocX == x) |
139 | { | 139 | { |
140 | if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y) | 140 | if (y == -1 || m_module.Scene.RegionInfo.LegacyRegionLocY == y) |
141 | { | 141 | { |
142 | double selectedheight = double.Parse(heightstring); | 142 | double selectedheight = double.Parse(heightstring); |
143 | 143 | ||
@@ -159,9 +159,9 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
159 | int x = (args.Length > 6 ? int.Parse(args[6]) : -1); | 159 | int x = (args.Length > 6 ? int.Parse(args[6]) : -1); |
160 | int y = (args.Length > 7 ? int.Parse(args[7]) : -1); | 160 | int y = (args.Length > 7 ? int.Parse(args[7]) : -1); |
161 | 161 | ||
162 | if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x) | 162 | if (x == -1 || m_module.Scene.RegionInfo.LegacyRegionLocX == x) |
163 | { | 163 | { |
164 | if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y) | 164 | if (y == -1 || m_module.Scene.RegionInfo.LegacyRegionLocY == y) |
165 | { | 165 | { |
166 | int corner = int.Parse(num); | 166 | int corner = int.Parse(num); |
167 | float lowValue = float.Parse(min, Culture.NumberFormatInfo); | 167 | float lowValue = float.Parse(min, Culture.NumberFormatInfo); |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 1789d6d..51ed83f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -1717,8 +1717,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1717 | // HACK for now | 1717 | // HACK for now |
1718 | RegionInfo r = new RegionInfo(); | 1718 | RegionInfo r = new RegionInfo(); |
1719 | r.RegionName = info.RegionName; | 1719 | r.RegionName = info.RegionName; |
1720 | r.RegionLocX = (uint)info.RegionLocX; | 1720 | r.LegacyRegionLocX = (uint)info.RegionLocX; |
1721 | r.RegionLocY = (uint)info.RegionLocY; | 1721 | r.LegacyRegionLocY = (uint)info.RegionLocY; |
1722 | r.RegionSettings.Maturity = (int)Util.ConvertAccessLevelToMaturity(data.RegionAccess); | 1722 | r.RegionSettings.Maturity = (int)Util.ConvertAccessLevelToMaturity(data.RegionAccess); |
1723 | remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y); | 1723 | remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y); |
1724 | } | 1724 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index d78ade5..d5c77ec 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -67,7 +67,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
67 | { | 67 | { |
68 | using (Bitmap bitmap = new Bitmap(filename)) | 68 | using (Bitmap bitmap = new Bitmap(filename)) |
69 | { | 69 | { |
70 | ITerrainChannel retval = new TerrainChannel(true); | 70 | ITerrainChannel retval = new TerrainChannel(w, h); |
71 | 71 | ||
72 | for (int x = 0; x < retval.Width; x++) | 72 | for (int x = 0; x < retval.Width; x++) |
73 | { | 73 | { |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index fd30c46..459af73 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 | ||
@@ -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 | { |
@@ -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 | } |
@@ -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 | ||
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index cdf1467..8383f4e 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -249,7 +249,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
249 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is | 249 | // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is |
250 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. | 250 | // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. |
251 | 251 | ||
252 | if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) | 252 | if (m_scene.RegionInfo.LegacyRegionLocX >= 2048 || m_scene.RegionInfo.LegacyRegionLocY >= 2048) |
253 | { | 253 | { |
254 | ScenePresence avatarPresence = null; | 254 | ScenePresence avatarPresence = null; |
255 | 255 | ||
@@ -278,10 +278,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
278 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; | 278 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; |
279 | 279 | ||
280 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 280 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
281 | (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, | 281 | (int)(m_scene.RegionInfo.LegacyRegionLocX - 8) * (int)Constants.RegionSize, |
282 | (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, | 282 | (int)(m_scene.RegionInfo.LegacyRegionLocX + 8) * (int)Constants.RegionSize, |
283 | (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, | 283 | (int)(m_scene.RegionInfo.LegacyRegionLocY - 8) * (int)Constants.RegionSize, |
284 | (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); | 284 | (int)(m_scene.RegionInfo.LegacyRegionLocY + 8) * (int)Constants.RegionSize); |
285 | foreach (GridRegion r in regions) | 285 | foreach (GridRegion r in regions) |
286 | { | 286 | { |
287 | MapBlockData block = new MapBlockData(); | 287 | MapBlockData block = new MapBlockData(); |
@@ -1218,10 +1218,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1218 | 1218 | ||
1219 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); | 1219 | List<MapBlockData> mapBlocks = new List<MapBlockData>(); |
1220 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, | 1220 | List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, |
1221 | (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize, | 1221 | (int)(m_scene.RegionInfo.LegacyRegionLocX - 9) * (int)Constants.RegionSize, |
1222 | (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize, | 1222 | (int)(m_scene.RegionInfo.LegacyRegionLocX + 9) * (int)Constants.RegionSize, |
1223 | (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize, | 1223 | (int)(m_scene.RegionInfo.LegacyRegionLocY - 9) * (int)Constants.RegionSize, |
1224 | (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize); | 1224 | (int)(m_scene.RegionInfo.LegacyRegionLocY + 9) * (int)Constants.RegionSize); |
1225 | List<AssetBase> textures = new List<AssetBase>(); | 1225 | List<AssetBase> textures = new List<AssetBase>(); |
1226 | List<Image> bitImages = new List<Image>(); | 1226 | List<Image> bitImages = new List<Image>(); |
1227 | 1227 | ||
@@ -1262,8 +1262,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1262 | 1262 | ||
1263 | for (int i = 0; i < mapBlocks.Count; i++) | 1263 | for (int i = 0; i < mapBlocks.Count; i++) |
1264 | { | 1264 | { |
1265 | ushort x = (ushort)((mapBlocks[i].X - m_scene.RegionInfo.RegionLocX) + 10); | 1265 | ushort x = (ushort)((mapBlocks[i].X - m_scene.RegionInfo.LegacyRegionLocX) + 10); |
1266 | ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.RegionLocY) + 10); | 1266 | ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.LegacyRegionLocY) + 10); |
1267 | g.DrawImage(bitImages[i], (x * 128), 2560 - (y * 128), 128, 128); // y origin is top | 1267 | g.DrawImage(bitImages[i], (x * 128), 2560 - (y * 128), 128, 128); // y origin is top |
1268 | } | 1268 | } |
1269 | 1269 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs index 3787ca0..5ba5b31 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs | |||
@@ -135,4 +135,5 @@ namespace OpenSim.Region.Framework.Interfaces | |||
135 | 135 | ||
136 | void Shutdown(); | 136 | void Shutdown(); |
137 | } | 137 | } |
138 | |||
138 | } | 139 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs index e467701..cc8a236 100644 --- a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs +++ b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs | |||
@@ -25,13 +25,20 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework; | ||
29 | |||
28 | namespace OpenSim.Region.Framework.Interfaces | 30 | namespace OpenSim.Region.Framework.Interfaces |
29 | { | 31 | { |
30 | public interface ITerrainChannel | 32 | public interface ITerrainChannel |
31 | { | 33 | { |
32 | int Height { get; } | 34 | int Width { get;} // X dimension |
35 | int Height { get;} // Y dimension | ||
36 | int Altitude { get;} // Z dimension | ||
37 | |||
33 | double this[int x, int y] { get; set; } | 38 | double this[int x, int y] { get; set; } |
34 | int Width { get; } | 39 | |
40 | // Return the packaged terrain data for passing into lower levels of communication | ||
41 | TerrainData GetTerrainData(); | ||
35 | 42 | ||
36 | /// <summary> | 43 | /// <summary> |
37 | /// Squash the entire heightmap into a single dimensioned array | 44 | /// Squash the entire heightmap into a single dimensioned array |
@@ -40,7 +47,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
40 | float[] GetFloatsSerialised(); | 47 | float[] GetFloatsSerialised(); |
41 | 48 | ||
42 | double[,] GetDoubles(); | 49 | double[,] GetDoubles(); |
50 | |||
51 | // Check if a location has been updated. Clears the taint flag as a side effect. | ||
43 | bool Tainted(int x, int y); | 52 | bool Tainted(int x, int y); |
53 | |||
44 | ITerrainChannel MakeCopy(); | 54 | ITerrainChannel MakeCopy(); |
45 | string SaveToXmlString(); | 55 | string SaveToXmlString(); |
46 | void LoadFromXmlString(string data); | 56 | void LoadFromXmlString(string data); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7772f94..e2880e3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1107,8 +1107,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1107 | if (RegionInfo.RegionHandle != otherRegion.RegionHandle) | 1107 | if (RegionInfo.RegionHandle != otherRegion.RegionHandle) |
1108 | { | 1108 | { |
1109 | // If these are cast to INT because long + negative values + abs returns invalid data | 1109 | // If these are cast to INT because long + negative values + abs returns invalid data |
1110 | int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX); | 1110 | int resultX = Math.Abs((int)xcell - (int)RegionInfo.LegacyRegionLocX); |
1111 | int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY); | 1111 | int resultY = Math.Abs((int)ycell - (int)RegionInfo.LegacyRegionLocY); |
1112 | if (resultX <= 1 && resultY <= 1) | 1112 | if (resultX <= 1 && resultY <= 1) |
1113 | { | 1113 | { |
1114 | // Let the grid service module know, so this can be cached | 1114 | // Let the grid service module know, so this can be cached |
@@ -1183,8 +1183,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | /// </returns> | 1183 | /// </returns> |
1184 | public int HaveNeighbor(Cardinals car, ref int[] fix) | 1184 | public int HaveNeighbor(Cardinals car, ref int[] fix) |
1185 | { | 1185 | { |
1186 | uint neighbourx = RegionInfo.RegionLocX; | 1186 | uint neighbourx = RegionInfo.LegacyRegionLocX; |
1187 | uint neighboury = RegionInfo.RegionLocY; | 1187 | uint neighboury = RegionInfo.LegacyRegionLocY; |
1188 | 1188 | ||
1189 | int dir = (int)car; | 1189 | int dir = (int)car; |
1190 | 1190 | ||
@@ -1204,8 +1204,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1204 | 1204 | ||
1205 | if (neighbourRegion == null) | 1205 | if (neighbourRegion == null) |
1206 | { | 1206 | { |
1207 | fix[0] = (int)(RegionInfo.RegionLocX - neighbourx); | 1207 | fix[0] = (int)(RegionInfo.LegacyRegionLocX - neighbourx); |
1208 | fix[1] = (int)(RegionInfo.RegionLocY - neighboury); | 1208 | fix[1] = (int)(RegionInfo.LegacyRegionLocY - neighboury); |
1209 | return dir * (-1); | 1209 | return dir * (-1); |
1210 | } | 1210 | } |
1211 | else | 1211 | else |
@@ -1905,13 +1905,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1905 | m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); | 1905 | m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); |
1906 | 1906 | ||
1907 | m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); | 1907 | m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); |
1908 | Heightmap = new TerrainChannel(m_InitialTerrain); | 1908 | Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); |
1909 | 1909 | ||
1910 | SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); | 1910 | SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); |
1911 | } | 1911 | } |
1912 | else | 1912 | else |
1913 | { | 1913 | { |
1914 | Heightmap = new TerrainChannel(map); | 1914 | Heightmap = new TerrainChannel(map, RegionInfo.RegionSizeZ); |
1915 | } | 1915 | } |
1916 | } | 1916 | } |
1917 | catch (IOException e) | 1917 | catch (IOException e) |
@@ -4371,8 +4371,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4371 | { | 4371 | { |
4372 | uint rRegionX = (uint)(cAgentData.RegionHandle >> 40); | 4372 | uint rRegionX = (uint)(cAgentData.RegionHandle >> 40); |
4373 | uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8); | 4373 | uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8); |
4374 | uint tRegionX = RegionInfo.RegionLocX; | 4374 | uint tRegionX = RegionInfo.LegacyRegionLocX; |
4375 | uint tRegionY = RegionInfo.RegionLocY; | 4375 | uint tRegionY = RegionInfo.LegacyRegionLocY; |
4376 | //Send Data to ScenePresence | 4376 | //Send Data to ScenePresence |
4377 | childAgentUpdate.UpdateChildAgent(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); | 4377 | childAgentUpdate.UpdateChildAgent(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); |
4378 | // Not Implemented: | 4378 | // Not Implemented: |
@@ -4600,13 +4600,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
4600 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); | 4600 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); |
4601 | if (sp != null) | 4601 | if (sp != null) |
4602 | { | 4602 | { |
4603 | uint regionX = RegionInfo.RegionLocX; | 4603 | uint regionX = RegionInfo.LegacyRegionLocX; |
4604 | uint regionY = RegionInfo.RegionLocY; | 4604 | uint regionY = RegionInfo.LegacyRegionLocY; |
4605 | 4605 | ||
4606 | Utils.LongToUInts(regionHandle, out regionX, out regionY); | 4606 | Utils.LongToUInts(regionHandle, out regionX, out regionY); |
4607 | 4607 | ||
4608 | int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize; | 4608 | int shiftx = (int) regionX - (int) RegionInfo.LegacyRegionLocX * (int)Constants.RegionSize; |
4609 | int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize; | 4609 | int shifty = (int) regionY - (int) RegionInfo.LegacyRegionLocY * (int)Constants.RegionSize; |
4610 | 4610 | ||
4611 | position.X += shiftx; | 4611 | position.X += shiftx; |
4612 | position.Y += shifty; | 4612 | position.Y += shifty; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 28f7896..2677989 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -445,8 +445,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
445 | { | 445 | { |
446 | foreach (Scene mscene in m_localScenes) | 446 | foreach (Scene mscene in m_localScenes) |
447 | { | 447 | { |
448 | if (mscene.RegionInfo.RegionLocX == locX && | 448 | if (mscene.RegionInfo.LegacyRegionLocX == locX && |
449 | mscene.RegionInfo.RegionLocY == locY) | 449 | mscene.RegionInfo.LegacyRegionLocY == locY) |
450 | { | 450 | { |
451 | scene = mscene; | 451 | scene = mscene; |
452 | return true; | 452 | return true; |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7243db1..297ee5f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -710,7 +710,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
710 | Utils.LongToUInts(handle, out x, out y); | 710 | Utils.LongToUInts(handle, out x, out y); |
711 | x = x / Constants.RegionSize; | 711 | x = x / Constants.RegionSize; |
712 | y = y / Constants.RegionSize; | 712 | y = y / Constants.RegionSize; |
713 | if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) | 713 | if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.LegacyRegionLocX, y, Scene.RegionInfo.LegacyRegionLocY)) |
714 | { | 714 | { |
715 | old.Add(handle); | 715 | old.Add(handle); |
716 | } | 716 | } |
@@ -2094,8 +2094,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2094 | // } | 2094 | // } |
2095 | 2095 | ||
2096 | // Get terrain height for sub-region in a megaregion if necessary | 2096 | // Get terrain height for sub-region in a megaregion if necessary |
2097 | int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); | 2097 | int X = (int)((m_scene.RegionInfo.RegionWorldLocX) + pos.X); |
2098 | int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); | 2098 | int Y = (int)((m_scene.RegionInfo.RegionWorldLocY) + pos.Y); |
2099 | GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); | 2099 | GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); |
2100 | // If X and Y is NaN, target_region will be null | 2100 | // If X and Y is NaN, target_region will be null |
2101 | if (target_region == null) | 2101 | if (target_region == null) |
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 95f9caf..67998a0 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -437,7 +437,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
437 | 437 | ||
438 | SimStats simStats | 438 | SimStats simStats |
439 | = new SimStats( | 439 | = new SimStats( |
440 | ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity, | 440 | ReportingRegion.LegacyRegionLocX, ReportingRegion.LegacyRegionLocY, regionFlags, (uint)m_objectCapacity, |
441 | rb, sb, m_scene.RegionInfo.originRegionID); | 441 | rb, sb, m_scene.RegionInfo.originRegionID); |
442 | 442 | ||
443 | handlerSendStatResult = OnSendStatsResult; | 443 | handlerSendStatResult = OnSendStatsResult; |
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index c0ca48e..6d245cb 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs | |||
@@ -25,14 +25,19 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Framework; | ||
29 | using OpenSim.Region.Framework.Interfaces; | ||
30 | using System; | 28 | using System; |
29 | using System.IO; | ||
31 | using System.Text; | 30 | using System.Text; |
31 | using System.Reflection; | ||
32 | using System.Xml; | 32 | using System.Xml; |
33 | using System.IO; | ||
34 | using System.Xml.Serialization; | 33 | using System.Xml.Serialization; |
35 | 34 | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | |||
39 | using log4net; | ||
40 | |||
36 | namespace OpenSim.Region.Framework.Scenes | 41 | namespace OpenSim.Region.Framework.Scenes |
37 | { | 42 | { |
38 | /// <summary> | 43 | /// <summary> |
@@ -40,132 +45,115 @@ namespace OpenSim.Region.Framework.Scenes | |||
40 | /// </summary> | 45 | /// </summary> |
41 | public class TerrainChannel : ITerrainChannel | 46 | public class TerrainChannel : ITerrainChannel |
42 | { | 47 | { |
43 | private readonly bool[,] taint; | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | private double[,] map; | 49 | private static string LogHeader = "[TERRAIN CHANNEL]"; |
50 | |||
51 | protected TerrainData m_terrainData; | ||
45 | 52 | ||
53 | public int Width { get { return m_terrainData.SizeX; } } // X dimension | ||
54 | // Unfortunately, for historical reasons, in this module 'Width' is X and 'Height' is Y | ||
55 | public int Height { get { return m_terrainData.SizeY; } } // Y dimension | ||
56 | public int Altitude { get { return m_terrainData.SizeZ; } } // Y dimension | ||
57 | |||
58 | // Default, not-often-used builder | ||
46 | public TerrainChannel() | 59 | public TerrainChannel() |
47 | { | 60 | { |
48 | map = new double[Constants.RegionSize, Constants.RegionSize]; | 61 | m_terrainData = new HeightmapTerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); |
49 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; | 62 | FlatLand(); |
50 | 63 | // PinHeadIsland(); | |
51 | PinHeadIsland(); | ||
52 | } | 64 | } |
53 | 65 | ||
54 | public TerrainChannel(String type) | 66 | // Create terrain of given size |
67 | public TerrainChannel(int pX, int pY) | ||
55 | { | 68 | { |
56 | map = new double[Constants.RegionSize, Constants.RegionSize]; | 69 | m_terrainData = new HeightmapTerrainData(pX, pY, (int)Constants.RegionHeight); |
57 | taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; | 70 | } |
58 | 71 | ||
72 | // Create terrain of specified size and initialize with specified terrain. | ||
73 | // TODO: join this with the terrain initializers. | ||
74 | public TerrainChannel(String type, int pX, int pY, int pZ) | ||
75 | { | ||
76 | m_terrainData = new HeightmapTerrainData(pX, pY, pZ); | ||
59 | if (type.Equals("flat")) | 77 | if (type.Equals("flat")) |
60 | FlatLand(); | 78 | FlatLand(); |
61 | else | 79 | else |
62 | PinHeadIsland(); | 80 | PinHeadIsland(); |
63 | } | 81 | } |
64 | 82 | ||
65 | public TerrainChannel(double[,] import) | 83 | public TerrainChannel(double[,] pM, uint pAltitude) |
66 | { | ||
67 | map = import; | ||
68 | taint = new bool[import.GetLength(0),import.GetLength(1)]; | ||
69 | } | ||
70 | |||
71 | public TerrainChannel(bool createMap) | ||
72 | { | ||
73 | if (createMap) | ||
74 | { | ||
75 | map = new double[Constants.RegionSize,Constants.RegionSize]; | ||
76 | taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | public TerrainChannel(int w, int h) | ||
81 | { | 84 | { |
82 | map = new double[w,h]; | 85 | m_terrainData = new HeightmapTerrainData(pM); |
83 | taint = new bool[w / 16,h / 16]; | ||
84 | } | 86 | } |
85 | 87 | ||
86 | #region ITerrainChannel Members | 88 | #region ITerrainChannel Members |
87 | 89 | ||
88 | public int Width | 90 | // ITerrainChannel.MakeCopy() |
91 | public ITerrainChannel MakeCopy() | ||
89 | { | 92 | { |
90 | get { return map.GetLength(0); } | 93 | return this.Copy(); |
91 | } | 94 | } |
92 | 95 | ||
93 | public int Height | 96 | // ITerrainChannel.GetTerrainData() |
97 | public TerrainData GetTerrainData() | ||
94 | { | 98 | { |
95 | get { return map.GetLength(1); } | 99 | return m_terrainData; |
96 | } | 100 | } |
97 | 101 | ||
98 | public ITerrainChannel MakeCopy() | 102 | // ITerrainChannel.GetFloatsSerialized() |
103 | // NOTICE that the one dimensional form is ordered by Y!! | ||
104 | public float[] GetFloatsSerialised() | ||
99 | { | 105 | { |
100 | TerrainChannel copy = new TerrainChannel(false); | 106 | int points = Width * Height; |
101 | copy.map = (double[,]) map.Clone(); | 107 | float[] heights = new float[points]; |
102 | 108 | ||
103 | return copy; | 109 | int idx = 0; |
110 | for (int ii = 0; ii < Height; ii++) | ||
111 | for (int jj = 0; jj < Width; jj++) | ||
112 | heights[idx++] = m_terrainData[jj, ii]; | ||
113 | |||
114 | return heights; | ||
104 | } | 115 | } |
105 | 116 | ||
106 | public float[] GetFloatsSerialised() | 117 | // ITerrainChannel.GetDoubles() |
118 | public double[,] GetDoubles() | ||
107 | { | 119 | { |
108 | // Move the member variables into local variables, calling | ||
109 | // member variables 256*256 times gets expensive | ||
110 | int w = Width; | 120 | int w = Width; |
111 | int h = Height; | 121 | int l = Height; |
112 | float[] heights = new float[w * h]; | 122 | double[,] heights = new double[w, l]; |
113 | 123 | ||
114 | int i, j; // map coordinates | ||
115 | int idx = 0; // index into serialized array | 124 | int idx = 0; // index into serialized array |
116 | for (i = 0; i < h; i++) | 125 | for (int ii = 0; ii < w; ii++) |
117 | { | 126 | { |
118 | for (j = 0; j < w; j++) | 127 | for (int jj = 0; jj < l; jj++) |
119 | { | 128 | { |
120 | heights[idx++] = (float)map[j, i]; | 129 | heights[ii, jj] = (double)m_terrainData[ii, jj]; |
130 | idx++; | ||
121 | } | 131 | } |
122 | } | 132 | } |
123 | 133 | ||
124 | return heights; | 134 | return heights; |
125 | } | 135 | } |
126 | 136 | ||
127 | public double[,] GetDoubles() | 137 | // ITerrainChannel.this[x,y] |
128 | { | ||
129 | return map; | ||
130 | } | ||
131 | |||
132 | public double this[int x, int y] | 138 | public double this[int x, int y] |
133 | { | 139 | { |
134 | get { return map[x, y]; } | 140 | get { return (double)m_terrainData[x, y]; } |
135 | set | 141 | set |
136 | { | 142 | { |
137 | // Will "fix" terrain hole problems. Although not fantastically. | ||
138 | if (Double.IsNaN(value) || Double.IsInfinity(value)) | 143 | if (Double.IsNaN(value) || Double.IsInfinity(value)) |
139 | return; | 144 | return; |
140 | 145 | ||
141 | if (map[x, y] != value) | 146 | m_terrainData[x, y] = (float)value; |
142 | { | ||
143 | taint[x / 16, y / 16] = true; | ||
144 | map[x, y] = value; | ||
145 | } | ||
146 | } | 147 | } |
147 | } | 148 | } |
148 | 149 | ||
150 | // ITerrainChannel.Tainted() | ||
149 | public bool Tainted(int x, int y) | 151 | public bool Tainted(int x, int y) |
150 | { | 152 | { |
151 | if (taint[x / 16, y / 16]) | 153 | return m_terrainData.IsTaintedAt(x, y); |
152 | { | ||
153 | taint[x / 16, y / 16] = false; | ||
154 | return true; | ||
155 | } | ||
156 | return false; | ||
157 | } | ||
158 | |||
159 | #endregion | ||
160 | |||
161 | public TerrainChannel Copy() | ||
162 | { | ||
163 | TerrainChannel copy = new TerrainChannel(false); | ||
164 | copy.map = (double[,]) map.Clone(); | ||
165 | |||
166 | return copy; | ||
167 | } | 154 | } |
168 | 155 | ||
156 | // ITerrainChannel.SaveToXmlString() | ||
169 | public string SaveToXmlString() | 157 | public string SaveToXmlString() |
170 | { | 158 | { |
171 | XmlWriterSettings settings = new XmlWriterSettings(); | 159 | XmlWriterSettings settings = new XmlWriterSettings(); |
@@ -181,13 +169,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
181 | } | 169 | } |
182 | } | 170 | } |
183 | 171 | ||
184 | private void WriteXml(XmlWriter writer) | 172 | // ITerrainChannel.LoadFromXmlString() |
185 | { | ||
186 | writer.WriteStartElement(String.Empty, "TerrainMap", String.Empty); | ||
187 | ToXml(writer); | ||
188 | writer.WriteEndElement(); | ||
189 | } | ||
190 | |||
191 | public void LoadFromXmlString(string data) | 173 | public void LoadFromXmlString(string data) |
192 | { | 174 | { |
193 | StringReader sr = new StringReader(data); | 175 | StringReader sr = new StringReader(data); |
@@ -199,12 +181,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
199 | sr.Close(); | 181 | sr.Close(); |
200 | } | 182 | } |
201 | 183 | ||
184 | #endregion | ||
185 | |||
186 | public TerrainChannel Copy() | ||
187 | { | ||
188 | TerrainChannel copy = new TerrainChannel(); | ||
189 | copy.m_terrainData = m_terrainData.Clone(); | ||
190 | return copy; | ||
191 | } | ||
192 | |||
193 | private void WriteXml(XmlWriter writer) | ||
194 | { | ||
195 | if (Width == Constants.RegionSize && Height == Constants.RegionSize) | ||
196 | { | ||
197 | // Downward compatibility for legacy region terrain maps. | ||
198 | // If region is exactly legacy size, return the old format XML. | ||
199 | writer.WriteStartElement(String.Empty, "TerrainMap", String.Empty); | ||
200 | ToXml(writer); | ||
201 | writer.WriteEndElement(); | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | // New format XML that includes width and length. | ||
206 | writer.WriteStartElement(String.Empty, "TerrainMap2", String.Empty); | ||
207 | ToXml2(writer); | ||
208 | writer.WriteEndElement(); | ||
209 | } | ||
210 | } | ||
211 | |||
202 | private void ReadXml(XmlReader reader) | 212 | private void ReadXml(XmlReader reader) |
203 | { | 213 | { |
204 | reader.ReadStartElement("TerrainMap"); | 214 | // Check the first element. If legacy element, use the legacy reader. |
205 | FromXml(reader); | 215 | if (reader.IsStartElement("TerrainMap")) |
216 | { | ||
217 | reader.ReadStartElement("TerrainMap"); | ||
218 | FromXml(reader); | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | reader.ReadStartElement("TerrainMap2"); | ||
223 | FromXml2(reader); | ||
224 | } | ||
206 | } | 225 | } |
207 | 226 | ||
227 | // Write legacy terrain map. Presumed to be 256x256 of data encoded as floats in a byte array. | ||
208 | private void ToXml(XmlWriter xmlWriter) | 228 | private void ToXml(XmlWriter xmlWriter) |
209 | { | 229 | { |
210 | float[] mapData = GetFloatsSerialised(); | 230 | float[] mapData = GetFloatsSerialised(); |
@@ -218,12 +238,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
218 | serializer.Serialize(xmlWriter, buffer); | 238 | serializer.Serialize(xmlWriter, buffer); |
219 | } | 239 | } |
220 | 240 | ||
241 | // Read legacy terrain map. Presumed to be 256x256 of data encoded as floats in a byte array. | ||
221 | private void FromXml(XmlReader xmlReader) | 242 | private void FromXml(XmlReader xmlReader) |
222 | { | 243 | { |
223 | XmlSerializer serializer = new XmlSerializer(typeof(byte[])); | 244 | XmlSerializer serializer = new XmlSerializer(typeof(byte[])); |
224 | byte[] dataArray = (byte[])serializer.Deserialize(xmlReader); | 245 | byte[] dataArray = (byte[])serializer.Deserialize(xmlReader); |
225 | int index = 0; | 246 | int index = 0; |
226 | 247 | ||
248 | m_terrainData = new HeightmapTerrainData(Width, Height, Altitude); | ||
249 | |||
227 | for (int y = 0; y < Height; y++) | 250 | for (int y = 0; y < Height; y++) |
228 | { | 251 | { |
229 | for (int x = 0; x < Width; x++) | 252 | for (int x = 0; x < Width; x++) |
@@ -236,35 +259,65 @@ namespace OpenSim.Region.Framework.Scenes | |||
236 | } | 259 | } |
237 | } | 260 | } |
238 | 261 | ||
262 | private class TerrainChannelXMLPackage | ||
263 | { | ||
264 | public int Version; | ||
265 | public int SizeX; | ||
266 | public int SizeY; | ||
267 | public int SizeZ; | ||
268 | public float CompressionFactor; | ||
269 | public short[] Map; | ||
270 | public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, short[] pMap) | ||
271 | { | ||
272 | Version = 1; | ||
273 | SizeX = pX; | ||
274 | SizeY = pY; | ||
275 | SizeZ = pZ; | ||
276 | CompressionFactor = pCompressionFactor; | ||
277 | Map = pMap; | ||
278 | } | ||
279 | } | ||
280 | |||
281 | // New terrain serialization format that includes the width and length. | ||
282 | private void ToXml2(XmlWriter xmlWriter) | ||
283 | { | ||
284 | TerrainChannelXMLPackage package = new TerrainChannelXMLPackage(Width, Height, Altitude, m_terrainData.CompressionFactor, | ||
285 | m_terrainData.GetCompressedMap()); | ||
286 | XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage)); | ||
287 | serializer.Serialize(xmlWriter, package); | ||
288 | } | ||
289 | |||
290 | // New terrain serialization format that includes the width and length. | ||
291 | private void FromXml2(XmlReader xmlReader) | ||
292 | { | ||
293 | XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage)); | ||
294 | TerrainChannelXMLPackage package = (TerrainChannelXMLPackage)serializer.Deserialize(xmlReader); | ||
295 | m_terrainData = new HeightmapTerrainData(package.Map, package.CompressionFactor, package.SizeX, package.SizeY, package.SizeZ); | ||
296 | } | ||
297 | |||
298 | // Fill the heightmap with the center bump terrain | ||
239 | private void PinHeadIsland() | 299 | private void PinHeadIsland() |
240 | { | 300 | { |
241 | int x; | 301 | for (int x = 0; x < Width; x++) |
242 | for (x = 0; x < Constants.RegionSize; x++) | ||
243 | { | 302 | { |
244 | int y; | 303 | for (int y = 0; y < Height; y++) |
245 | for (y = 0; y < Constants.RegionSize; y++) | ||
246 | { | 304 | { |
247 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; | 305 | m_terrainData[x, y] = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; |
248 | double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01; | 306 | float spherFacA = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 50) * 0.01d); |
249 | double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001; | 307 | float spherFacB = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 100) * 0.001d); |
250 | if (map[x, y] < spherFacA) | 308 | if (m_terrainData[x, y]< spherFacA) |
251 | map[x, y] = spherFacA; | 309 | m_terrainData[x, y]= spherFacA; |
252 | if (map[x, y] < spherFacB) | 310 | if (m_terrainData[x, y]< spherFacB) |
253 | map[x, y] = spherFacB; | 311 | m_terrainData[x, y] = spherFacB; |
254 | } | 312 | } |
255 | } | 313 | } |
256 | } | 314 | } |
257 | 315 | ||
258 | private void FlatLand() | 316 | private void FlatLand() |
259 | { | 317 | { |
260 | int x; | 318 | for (int xx = 0; xx < Width; xx++) |
261 | for (x = 0; x < Constants.RegionSize; x++) | 319 | for (int yy = 0; yy < Height; yy++) |
262 | { | 320 | m_terrainData[xx, yy] = 21; |
263 | int y; | ||
264 | for (y = 0; y < Constants.RegionSize; y++) | ||
265 | map[x, y] = 21; | ||
266 | } | ||
267 | } | 321 | } |
268 | |||
269 | } | 322 | } |
270 | } | 323 | } |
diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs new file mode 100644 index 0000000..e91c959 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs | |||
@@ -0,0 +1,949 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | /* Freely adapted from the Aurora version of the terrain compressor. | ||
29 | * Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/ | ||
30 | */ | ||
31 | |||
32 | using System; | ||
33 | using System.Reflection; | ||
34 | |||
35 | using log4net; | ||
36 | |||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.Framework; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | |||
41 | using OpenMetaverse; | ||
42 | using OpenMetaverse.Packets; | ||
43 | |||
44 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
45 | { | ||
46 | public static class OpenSimTerrainCompressor | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | private static string LogHeader = "[TERRAIN COMPRESSOR]"; | ||
50 | |||
51 | public const int END_OF_PATCHES = 97; | ||
52 | |||
53 | private const float OO_SQRT2 = 0.7071067811865475244008443621049f; | ||
54 | private const int STRIDE = 264; | ||
55 | |||
56 | private const int ZERO_CODE = 0x0; | ||
57 | private const int ZERO_EOB = 0x2; | ||
58 | private const int POSITIVE_VALUE = 0x6; | ||
59 | private const int NEGATIVE_VALUE = 0x7; | ||
60 | |||
61 | private static readonly float[] DequantizeTable16 = | ||
62 | new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
63 | |||
64 | private static readonly float[] DequantizeTable32 = | ||
65 | new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
66 | |||
67 | private static readonly float[] CosineTable16 = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
68 | //private static readonly float[] CosineTable32 = new float[Constants.TerrainPatchSize * Constants.TerrainPatchSize]; | ||
69 | private static readonly int[] CopyMatrix16 = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
70 | private static readonly int[] CopyMatrix32 = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
71 | |||
72 | private static readonly float[] QuantizeTable16 = | ||
73 | new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
74 | |||
75 | static OpenSimTerrainCompressor() | ||
76 | { | ||
77 | // Initialize the decompression tables | ||
78 | BuildDequantizeTable16(); | ||
79 | SetupCosines16(); | ||
80 | BuildCopyMatrix16(); | ||
81 | BuildQuantizeTable16(); | ||
82 | } | ||
83 | |||
84 | // Unused: left for historical reference. | ||
85 | public static LayerDataPacket CreateLayerDataPacket(TerrainPatch[] patches, byte type, int pRegionSizeX, | ||
86 | int pRegionSizeY) | ||
87 | { | ||
88 | LayerDataPacket layer = new LayerDataPacket {LayerID = {Type = type}}; | ||
89 | |||
90 | TerrainPatch.GroupHeader header = new TerrainPatch.GroupHeader | ||
91 | {Stride = STRIDE, PatchSize = Constants.TerrainPatchSize}; | ||
92 | |||
93 | // Should be enough to fit even the most poorly packed data | ||
94 | byte[] data = new byte[patches.Length*Constants.TerrainPatchSize*Constants.TerrainPatchSize*2]; | ||
95 | BitPack bitpack = new BitPack(data, 0); | ||
96 | bitpack.PackBits(header.Stride, 16); | ||
97 | bitpack.PackBits(header.PatchSize, 8); | ||
98 | bitpack.PackBits(type, 8); | ||
99 | |||
100 | foreach (TerrainPatch t in patches) | ||
101 | CreatePatch(bitpack, t.Data, t.X, t.Y, pRegionSizeX, pRegionSizeY); | ||
102 | |||
103 | bitpack.PackBits(END_OF_PATCHES, 8); | ||
104 | |||
105 | layer.LayerData.Data = new byte[bitpack.BytePos + 1]; | ||
106 | Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.BytePos + 1); | ||
107 | |||
108 | return layer; | ||
109 | } | ||
110 | |||
111 | // Legacy land packet generation gluing old land representation (heights) to compressed representation. | ||
112 | // This is an intermediate step in converting terrain into a variable sized heightmap. Some of the | ||
113 | // routines (like IClientAPI) only pass the float array of heights around. This entry | ||
114 | // converts that legacy representation into the more compact represenation used in | ||
115 | // TerrainData. Someday fix the plumbing between here and the scene. | ||
116 | public static LayerDataPacket CreateLandPacket(TerrainData terrData, int patchX, int patchY) | ||
117 | { | ||
118 | int[] xPieces = new int[1]; | ||
119 | int[] yPieces = new int[1]; | ||
120 | xPieces[0] = patchX; // patch X dimension | ||
121 | yPieces[0] = patchY; | ||
122 | |||
123 | m_log.DebugFormat("{0} CreateLandPacket. patchX={1}, patchY={2}, sizeX={3}, sizeY={4}", | ||
124 | LogHeader, patchX, patchY, terrData.SizeX, terrData.SizeY); | ||
125 | |||
126 | return CreateLandPacket(terrData, xPieces, yPieces, (int)TerrainPatch.LayerType.Land); | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// Creates a LayerData packet for compressed land data given a full | ||
131 | /// simulator heightmap and an array of indices of patches to compress | ||
132 | /// </summary> | ||
133 | /// <param name="heightmap"> | ||
134 | /// A 256 * 256 array of floating point values | ||
135 | /// specifying the height at each meter in the simulator | ||
136 | /// </param> | ||
137 | /// <param name="x"> | ||
138 | /// Array of indexes in the 16x16 grid of patches | ||
139 | /// for this simulator. For example if 1 and 17 are specified, patches | ||
140 | /// x=1,y=0 and x=1,y=1 are sent | ||
141 | /// </param> | ||
142 | /// <param name="y"> | ||
143 | /// Array of indexes in the 16x16 grid of patches | ||
144 | /// for this simulator. For example if 1 and 17 are specified, patches | ||
145 | /// x=1,y=0 and x=1,y=1 are sent | ||
146 | /// </param> | ||
147 | /// <param name="type"></param> | ||
148 | /// <param name="pRegionSizeX"></param> | ||
149 | /// <param name="pRegionSizeY"></param> | ||
150 | /// <returns></returns> | ||
151 | public static LayerDataPacket CreateLandPacket(TerrainData terrData, int[] x, int[] y, byte type) | ||
152 | { | ||
153 | LayerDataPacket layer = new LayerDataPacket {LayerID = {Type = type}}; | ||
154 | |||
155 | TerrainPatch.GroupHeader header = new TerrainPatch.GroupHeader | ||
156 | {Stride = STRIDE, PatchSize = Constants.TerrainPatchSize}; | ||
157 | |||
158 | byte[] data = new byte[x.Length * Constants.TerrainPatchSize * Constants.TerrainPatchSize * 2]; | ||
159 | BitPack bitpack = new BitPack(data, 0); | ||
160 | bitpack.PackBits(header.Stride, 16); | ||
161 | bitpack.PackBits(header.PatchSize, 8); | ||
162 | bitpack.PackBits(type, 8); | ||
163 | |||
164 | for (int i = 0; i < x.Length; i++) | ||
165 | CreatePatchFromHeightmap(bitpack, terrData, x[i], y[i]); | ||
166 | |||
167 | bitpack.PackBits(END_OF_PATCHES, 8); | ||
168 | |||
169 | layer.LayerData.Data = new byte[bitpack.BytePos + 1]; | ||
170 | Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.BytePos + 1); | ||
171 | |||
172 | return layer; | ||
173 | } | ||
174 | |||
175 | // Unused: left for historical reference. | ||
176 | public static void CreatePatch(BitPack output, float[] patchData, int x, int y, int pRegionSizeX, int pRegionSizeY) | ||
177 | { | ||
178 | TerrainPatch.Header header = PrescanPatch(patchData); | ||
179 | header.QuantWBits = 136; | ||
180 | if (pRegionSizeX > Constants.RegionSize || pRegionSizeY > Constants.RegionSize) | ||
181 | { | ||
182 | header.PatchIDs = (y & 0xFFFF); | ||
183 | header.PatchIDs += (x << 16); | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | header.PatchIDs = (y & 0x1F); | ||
188 | header.PatchIDs += (x << 5); | ||
189 | } | ||
190 | |||
191 | // NOTE: No idea what prequant and postquant should be or what they do | ||
192 | |||
193 | int wbits; | ||
194 | int[] patch = CompressPatch(patchData, header, 10, out wbits); | ||
195 | wbits = EncodePatchHeader(output, header, patch, Constants.RegionSize, Constants.RegionSize, wbits); | ||
196 | EncodePatch(output, patch, 0, wbits); | ||
197 | } | ||
198 | |||
199 | /// <summary> | ||
200 | /// Add a patch of terrain to a BitPacker | ||
201 | /// </summary> | ||
202 | /// <param name="output">BitPacker to write the patch to</param> | ||
203 | /// <param name="heightmap"> | ||
204 | /// Heightmap of the simulator. Presumed to be an sizeX*sizeY array. | ||
205 | /// </param> | ||
206 | /// <param name="patchX"> | ||
207 | /// X offset of the patch to create. | ||
208 | /// </param> | ||
209 | /// <param name="patchY"> | ||
210 | /// Y offset of the patch to create. | ||
211 | /// </param> | ||
212 | /// <param name="pRegionSizeX"></param> | ||
213 | /// <param name="pRegionSizeY"></param> | ||
214 | public static void CreatePatchFromHeightmap(BitPack output, TerrainData terrData, int patchX, int patchY) | ||
215 | { | ||
216 | TerrainPatch.Header header = PrescanPatch(terrData, patchX, patchY); | ||
217 | header.QuantWBits = 136; | ||
218 | |||
219 | // If larger than legacy region size, pack patch X and Y info differently. | ||
220 | if (terrData.SizeX > Constants.RegionSize || terrData.SizeY > Constants.RegionSize) | ||
221 | { | ||
222 | header.PatchIDs = (patchY & 0xFFFF); | ||
223 | header.PatchIDs += (patchX << 16); | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | header.PatchIDs = (patchY & 0x1F); | ||
228 | header.PatchIDs += (patchX << 5); | ||
229 | } | ||
230 | |||
231 | // NOTE: No idea what prequant and postquant should be or what they do | ||
232 | int wbits; | ||
233 | int[] patch = CompressPatch(terrData, patchX, patchY, header, 10, out wbits); | ||
234 | wbits = EncodePatchHeader(output, header, patch, (uint)terrData.SizeX, (uint)terrData.SizeY, wbits); | ||
235 | EncodePatch(output, patch, 0, wbits); | ||
236 | } | ||
237 | |||
238 | private static TerrainPatch.Header PrescanPatch(float[] patch) | ||
239 | { | ||
240 | TerrainPatch.Header header = new TerrainPatch.Header(); | ||
241 | float zmax = -99999999.0f; | ||
242 | float zmin = 99999999.0f; | ||
243 | |||
244 | for (int i = 0; i < Constants.TerrainPatchSize*Constants.TerrainPatchSize; i++) | ||
245 | { | ||
246 | float val = patch[i]; | ||
247 | if (val > zmax) zmax = val; | ||
248 | if (val < zmin) zmin = val; | ||
249 | } | ||
250 | |||
251 | header.DCOffset = zmin; | ||
252 | header.Range = (int) ((zmax - zmin) + 1.0f); | ||
253 | |||
254 | return header; | ||
255 | } | ||
256 | |||
257 | // Scan the height info we're returning and return a patch packet header for this patch. | ||
258 | private static TerrainPatch.Header PrescanPatch(TerrainData terrData, int patchX, int patchY) | ||
259 | { | ||
260 | TerrainPatch.Header header = new TerrainPatch.Header(); | ||
261 | float zmax = -99999999.0f; | ||
262 | float zmin = 99999999.0f; | ||
263 | |||
264 | for (int j = patchY*16; j < (patchY + 1)*16; j++) | ||
265 | { | ||
266 | for (int i = patchX*16; i < (patchX + 1)*16; i++) | ||
267 | { | ||
268 | // short val = heightmap[j*pRegionSizeX + i]; | ||
269 | float val = terrData[j, i]; | ||
270 | if (val > zmax) zmax = val; | ||
271 | if (val < zmin) zmin = val; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | // Since the the min and max values are the shorts, rescale to be real values. | ||
276 | // TODO: all this logic should go into the class wrapping the short values. | ||
277 | header.DCOffset = zmin; | ||
278 | header.Range = (int)(zmax - zmin + 1.0f); | ||
279 | |||
280 | return header; | ||
281 | } | ||
282 | |||
283 | public static TerrainPatch.Header DecodePatchHeader(BitPack bitpack) | ||
284 | { | ||
285 | TerrainPatch.Header header = new TerrainPatch.Header {QuantWBits = bitpack.UnpackBits(8)}; | ||
286 | |||
287 | // Quantized word bits | ||
288 | if (header.QuantWBits == END_OF_PATCHES) | ||
289 | return header; | ||
290 | |||
291 | // DC offset | ||
292 | header.DCOffset = bitpack.UnpackFloat(); | ||
293 | |||
294 | // Range | ||
295 | header.Range = bitpack.UnpackBits(16); | ||
296 | |||
297 | // Patch IDs (10 bits) | ||
298 | header.PatchIDs = bitpack.UnpackBits(10); | ||
299 | |||
300 | // Word bits | ||
301 | header.WordBits = (uint) ((header.QuantWBits & 0x0f) + 2); | ||
302 | |||
303 | return header; | ||
304 | } | ||
305 | |||
306 | private static int EncodePatchHeader(BitPack output, TerrainPatch.Header header, int[] patch, uint pRegionSizeX, | ||
307 | uint pRegionSizeY, int wbits) | ||
308 | { | ||
309 | /* | ||
310 | int temp; | ||
311 | int wbits = (header.QuantWBits & 0x0f) + 2; | ||
312 | uint maxWbits = (uint)wbits + 5; | ||
313 | uint minWbits = ((uint)wbits >> 1); | ||
314 | int wbitsMaxValue; | ||
315 | */ | ||
316 | // goal is to determ minimum number of bits to use so all data fits | ||
317 | /* | ||
318 | wbits = (int)minWbits; | ||
319 | wbitsMaxValue = (1 << wbits); | ||
320 | |||
321 | for (int i = 0; i < patch.Length; i++) | ||
322 | { | ||
323 | temp = patch[i]; | ||
324 | if (temp != 0) | ||
325 | { | ||
326 | // Get the absolute value | ||
327 | if (temp < 0) temp *= -1; | ||
328 | |||
329 | no coments.. | ||
330 | |||
331 | for (int j = (int)maxWbits; j > (int)minWbits; j--) | ||
332 | { | ||
333 | if ((temp & (1 << j)) != 0) | ||
334 | { | ||
335 | if (j > wbits) wbits = j; | ||
336 | break; | ||
337 | } | ||
338 | } | ||
339 | |||
340 | while (temp > wbitsMaxValue) | ||
341 | { | ||
342 | wbits++; | ||
343 | if (wbits == maxWbits) | ||
344 | goto Done; | ||
345 | wbitsMaxValue = 1 << wbits; | ||
346 | } | ||
347 | } | ||
348 | } | ||
349 | |||
350 | Done: | ||
351 | |||
352 | // wbits += 1; | ||
353 | */ | ||
354 | // better check | ||
355 | if (wbits > 17) | ||
356 | wbits = 16; | ||
357 | else if (wbits < 3) | ||
358 | wbits = 3; | ||
359 | |||
360 | header.QuantWBits &= 0xf0; | ||
361 | |||
362 | header.QuantWBits |= (wbits - 2); | ||
363 | |||
364 | output.PackBits(header.QuantWBits, 8); | ||
365 | output.PackFloat(header.DCOffset); | ||
366 | output.PackBits(header.Range, 16); | ||
367 | if (pRegionSizeX > Constants.RegionSize || pRegionSizeY > Constants.RegionSize) | ||
368 | output.PackBits(header.PatchIDs, 32); | ||
369 | else | ||
370 | output.PackBits(header.PatchIDs, 10); | ||
371 | |||
372 | return wbits; | ||
373 | } | ||
374 | |||
375 | private static void IDCTColumn16(float[] linein, float[] lineout, int column) | ||
376 | { | ||
377 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
378 | { | ||
379 | float total = OO_SQRT2*linein[column]; | ||
380 | |||
381 | for (int u = 1; u < Constants.TerrainPatchSize; u++) | ||
382 | { | ||
383 | int usize = u*Constants.TerrainPatchSize; | ||
384 | total += linein[usize + column]*CosineTable16[usize + n]; | ||
385 | } | ||
386 | |||
387 | lineout[Constants.TerrainPatchSize*n + column] = total; | ||
388 | } | ||
389 | } | ||
390 | |||
391 | private static void IDCTLine16(float[] linein, float[] lineout, int line) | ||
392 | { | ||
393 | const float oosob = 2.0f/Constants.TerrainPatchSize; | ||
394 | int lineSize = line*Constants.TerrainPatchSize; | ||
395 | |||
396 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
397 | { | ||
398 | float total = OO_SQRT2*linein[lineSize]; | ||
399 | |||
400 | for (int u = 1; u < Constants.TerrainPatchSize; u++) | ||
401 | { | ||
402 | total += linein[lineSize + u]*CosineTable16[u*Constants.TerrainPatchSize + n]; | ||
403 | } | ||
404 | |||
405 | lineout[lineSize + n] = total*oosob; | ||
406 | } | ||
407 | } | ||
408 | |||
409 | /* | ||
410 | private static void DCTLine16(float[] linein, float[] lineout, int line) | ||
411 | { | ||
412 | float total = 0.0f; | ||
413 | int lineSize = line * Constants.TerrainPatchSize; | ||
414 | |||
415 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
416 | { | ||
417 | total += linein[lineSize + n]; | ||
418 | } | ||
419 | |||
420 | lineout[lineSize] = OO_SQRT2 * total; | ||
421 | |||
422 | int uptr = 0; | ||
423 | for (int u = 1; u < Constants.TerrainPatchSize; u++) | ||
424 | { | ||
425 | total = 0.0f; | ||
426 | uptr += Constants.TerrainPatchSize; | ||
427 | |||
428 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
429 | { | ||
430 | total += linein[lineSize + n] * CosineTable16[uptr + n]; | ||
431 | } | ||
432 | |||
433 | lineout[lineSize + u] = total; | ||
434 | } | ||
435 | } | ||
436 | */ | ||
437 | |||
438 | private static void DCTLine16(float[] linein, float[] lineout, int line) | ||
439 | { | ||
440 | // outputs transpose data (lines exchanged with coluns ) | ||
441 | // so to save a bit of cpu when doing coluns | ||
442 | float total = 0.0f; | ||
443 | int lineSize = line*Constants.TerrainPatchSize; | ||
444 | |||
445 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
446 | { | ||
447 | total += linein[lineSize + n]; | ||
448 | } | ||
449 | |||
450 | lineout[line] = OO_SQRT2*total; | ||
451 | |||
452 | for (int u = Constants.TerrainPatchSize; | ||
453 | u < Constants.TerrainPatchSize*Constants.TerrainPatchSize; | ||
454 | u += Constants.TerrainPatchSize) | ||
455 | { | ||
456 | total = 0.0f; | ||
457 | for (int ptrn = lineSize, ptru = u; ptrn < lineSize + Constants.TerrainPatchSize; ptrn++,ptru++) | ||
458 | { | ||
459 | total += linein[ptrn]*CosineTable16[ptru]; | ||
460 | } | ||
461 | |||
462 | lineout[line + u] = total; | ||
463 | } | ||
464 | } | ||
465 | |||
466 | |||
467 | /* | ||
468 | private static void DCTColumn16(float[] linein, int[] lineout, int column) | ||
469 | { | ||
470 | float total = 0.0f; | ||
471 | // const float oosob = 2.0f / Constants.TerrainPatchSize; | ||
472 | |||
473 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
474 | { | ||
475 | total += linein[Constants.TerrainPatchSize * n + column]; | ||
476 | } | ||
477 | |||
478 | // lineout[CopyMatrix16[column]] = (int)(OO_SQRT2 * total * oosob * QuantizeTable16[column]); | ||
479 | lineout[CopyMatrix16[column]] = (int)(OO_SQRT2 * total * QuantizeTable16[column]); | ||
480 | |||
481 | for (int uptr = Constants.TerrainPatchSize; uptr < Constants.TerrainPatchSize * Constants.TerrainPatchSize; uptr += Constants.TerrainPatchSize) | ||
482 | { | ||
483 | total = 0.0f; | ||
484 | |||
485 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
486 | { | ||
487 | total += linein[Constants.TerrainPatchSize * n + column] * CosineTable16[uptr + n]; | ||
488 | } | ||
489 | |||
490 | // lineout[CopyMatrix16[Constants.TerrainPatchSize * u + column]] = (int)(total * oosob * QuantizeTable16[Constants.TerrainPatchSize * u + column]); | ||
491 | lineout[CopyMatrix16[uptr + column]] = (int)(total * QuantizeTable16[uptr + column]); | ||
492 | } | ||
493 | } | ||
494 | */ | ||
495 | |||
496 | private static void DCTColumn16(float[] linein, int[] lineout, int column) | ||
497 | { | ||
498 | // input columns are in fact stored in lines now | ||
499 | |||
500 | float total = 0.0f; | ||
501 | // const float oosob = 2.0f / Constants.TerrainPatchSize; | ||
502 | int inlinesptr = Constants.TerrainPatchSize*column; | ||
503 | |||
504 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
505 | { | ||
506 | total += linein[inlinesptr + n]; | ||
507 | } | ||
508 | |||
509 | // lineout[CopyMatrix16[column]] = (int)(OO_SQRT2 * total * oosob * QuantizeTable16[column]); | ||
510 | lineout[CopyMatrix16[column]] = (int) (OO_SQRT2*total*QuantizeTable16[column]); | ||
511 | |||
512 | for (int uptr = Constants.TerrainPatchSize; | ||
513 | uptr < Constants.TerrainPatchSize*Constants.TerrainPatchSize; | ||
514 | uptr += Constants.TerrainPatchSize) | ||
515 | { | ||
516 | total = 0.0f; | ||
517 | |||
518 | for (int n = inlinesptr, ptru = uptr; n < inlinesptr + Constants.TerrainPatchSize; n++, ptru++) | ||
519 | { | ||
520 | total += linein[n]*CosineTable16[ptru]; | ||
521 | } | ||
522 | |||
523 | // lineout[CopyMatrix16[Constants.TerrainPatchSize * u + column]] = (int)(total * oosob * QuantizeTable16[Constants.TerrainPatchSize * u + column]); | ||
524 | lineout[CopyMatrix16[uptr + column]] = (int) (total*QuantizeTable16[uptr + column]); | ||
525 | } | ||
526 | } | ||
527 | |||
528 | private static int DCTColumn16Wbits(float[] linein, int[] lineout, int column, int wbits, int maxwbits) | ||
529 | { | ||
530 | // input columns are in fact stored in lines now | ||
531 | |||
532 | bool dowbits = wbits != maxwbits; | ||
533 | int wbitsMaxValue = 1 << wbits; | ||
534 | |||
535 | float total = 0.0f; | ||
536 | // const float oosob = 2.0f / Constants.TerrainPatchSize; | ||
537 | int inlinesptr = Constants.TerrainPatchSize*column; | ||
538 | |||
539 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
540 | { | ||
541 | total += linein[inlinesptr + n]; | ||
542 | } | ||
543 | |||
544 | // lineout[CopyMatrix16[column]] = (int)(OO_SQRT2 * total * oosob * QuantizeTable16[column]); | ||
545 | int tmp = (int) (OO_SQRT2*total*QuantizeTable16[column]); | ||
546 | lineout[CopyMatrix16[column]] = tmp; | ||
547 | |||
548 | if (dowbits) | ||
549 | { | ||
550 | if (tmp < 0) tmp *= -1; | ||
551 | while (tmp > wbitsMaxValue) | ||
552 | { | ||
553 | wbits++; | ||
554 | wbitsMaxValue = 1 << wbits; | ||
555 | if (wbits == maxwbits) | ||
556 | { | ||
557 | dowbits = false; | ||
558 | break; | ||
559 | } | ||
560 | } | ||
561 | } | ||
562 | |||
563 | for (int uptr = Constants.TerrainPatchSize; | ||
564 | uptr < Constants.TerrainPatchSize*Constants.TerrainPatchSize; | ||
565 | uptr += Constants.TerrainPatchSize) | ||
566 | { | ||
567 | total = 0.0f; | ||
568 | |||
569 | for (int n = inlinesptr, ptru = uptr; n < inlinesptr + Constants.TerrainPatchSize; n++, ptru++) | ||
570 | { | ||
571 | total += linein[n]*CosineTable16[ptru]; | ||
572 | } | ||
573 | |||
574 | tmp = (int) (total*QuantizeTable16[uptr + column]); | ||
575 | lineout[CopyMatrix16[uptr + column]] = tmp; | ||
576 | |||
577 | if (dowbits) | ||
578 | { | ||
579 | if (tmp < 0) tmp *= -1; | ||
580 | while (tmp > wbitsMaxValue) | ||
581 | { | ||
582 | wbits++; | ||
583 | wbitsMaxValue = 1 << wbits; | ||
584 | if (wbits == maxwbits) | ||
585 | { | ||
586 | dowbits = false; | ||
587 | break; | ||
588 | } | ||
589 | } | ||
590 | } | ||
591 | } | ||
592 | return wbits; | ||
593 | } | ||
594 | |||
595 | public static void DecodePatch(int[] patches, BitPack bitpack, TerrainPatch.Header header, int size) | ||
596 | { | ||
597 | for (int n = 0; n < size*size; n++) | ||
598 | { | ||
599 | // ? | ||
600 | int temp = bitpack.UnpackBits(1); | ||
601 | if (temp != 0) | ||
602 | { | ||
603 | // Value or EOB | ||
604 | temp = bitpack.UnpackBits(1); | ||
605 | if (temp != 0) | ||
606 | { | ||
607 | // Value | ||
608 | temp = bitpack.UnpackBits(1); | ||
609 | if (temp != 0) | ||
610 | { | ||
611 | // Negative | ||
612 | temp = bitpack.UnpackBits((int) header.WordBits); | ||
613 | patches[n] = temp*-1; | ||
614 | } | ||
615 | else | ||
616 | { | ||
617 | // Positive | ||
618 | temp = bitpack.UnpackBits((int) header.WordBits); | ||
619 | patches[n] = temp; | ||
620 | } | ||
621 | } | ||
622 | else | ||
623 | { | ||
624 | // Set the rest to zero | ||
625 | // TODO: This might not be necessary | ||
626 | for (int o = n; o < size*size; o++) | ||
627 | { | ||
628 | patches[o] = 0; | ||
629 | } | ||
630 | break; | ||
631 | } | ||
632 | } | ||
633 | else | ||
634 | { | ||
635 | patches[n] = 0; | ||
636 | } | ||
637 | } | ||
638 | } | ||
639 | |||
640 | private static void EncodePatch(BitPack output, int[] patch, int postquant, int wbits) | ||
641 | { | ||
642 | int maxwbitssize = (1 << wbits) - 1; | ||
643 | |||
644 | if (postquant > Constants.TerrainPatchSize*Constants.TerrainPatchSize || postquant < 0) | ||
645 | { | ||
646 | Logger.Log("Postquant is outside the range of allowed values in EncodePatch()", Helpers.LogLevel.Error); | ||
647 | return; | ||
648 | } | ||
649 | |||
650 | if (postquant != 0) patch[Constants.TerrainPatchSize*Constants.TerrainPatchSize - postquant] = 0; | ||
651 | |||
652 | for (int i = 0; i < Constants.TerrainPatchSize*Constants.TerrainPatchSize; i++) | ||
653 | { | ||
654 | int temp = patch[i]; | ||
655 | |||
656 | if (temp == 0) | ||
657 | { | ||
658 | bool eob = true; | ||
659 | |||
660 | for (int j = i; j < Constants.TerrainPatchSize*Constants.TerrainPatchSize - postquant; j++) | ||
661 | { | ||
662 | if (patch[j] != 0) | ||
663 | { | ||
664 | eob = false; | ||
665 | break; | ||
666 | } | ||
667 | } | ||
668 | |||
669 | if (eob) | ||
670 | { | ||
671 | output.PackBits(ZERO_EOB, 2); | ||
672 | return; | ||
673 | } | ||
674 | output.PackBits(ZERO_CODE, 1); | ||
675 | } | ||
676 | else | ||
677 | { | ||
678 | if (temp < 0) | ||
679 | { | ||
680 | temp *= -1; | ||
681 | |||
682 | if (temp > maxwbitssize) temp = maxwbitssize; | ||
683 | |||
684 | output.PackBits(NEGATIVE_VALUE, 3); | ||
685 | output.PackBits(temp, wbits); | ||
686 | } | ||
687 | else | ||
688 | { | ||
689 | if (temp > maxwbitssize) temp = maxwbitssize; | ||
690 | |||
691 | output.PackBits(POSITIVE_VALUE, 3); | ||
692 | output.PackBits(temp, wbits); | ||
693 | } | ||
694 | } | ||
695 | } | ||
696 | } | ||
697 | |||
698 | public static float[] DecompressPatch(int[] patches, TerrainPatch.Header header, TerrainPatch.GroupHeader group) | ||
699 | { | ||
700 | float[] block = new float[group.PatchSize*group.PatchSize]; | ||
701 | float[] output = new float[group.PatchSize*group.PatchSize]; | ||
702 | int prequant = (header.QuantWBits >> 4) + 2; | ||
703 | int quantize = 1 << prequant; | ||
704 | float ooq = 1.0f/quantize; | ||
705 | float mult = ooq*header.Range; | ||
706 | float addval = mult*(1 << (prequant - 1)) + header.DCOffset; | ||
707 | |||
708 | if (group.PatchSize == Constants.TerrainPatchSize) | ||
709 | { | ||
710 | for (int n = 0; n < Constants.TerrainPatchSize*Constants.TerrainPatchSize; n++) | ||
711 | { | ||
712 | block[n] = patches[CopyMatrix16[n]]*DequantizeTable16[n]; | ||
713 | } | ||
714 | |||
715 | float[] ftemp = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
716 | |||
717 | for (int o = 0; o < Constants.TerrainPatchSize; o++) | ||
718 | IDCTColumn16(block, ftemp, o); | ||
719 | for (int o = 0; o < Constants.TerrainPatchSize; o++) | ||
720 | IDCTLine16(ftemp, block, o); | ||
721 | } | ||
722 | else | ||
723 | { | ||
724 | for (int n = 0; n < Constants.TerrainPatchSize*2*Constants.TerrainPatchSize*2; n++) | ||
725 | { | ||
726 | block[n] = patches[CopyMatrix32[n]]*DequantizeTable32[n]; | ||
727 | } | ||
728 | |||
729 | Logger.Log("Implement IDCTPatchLarge", Helpers.LogLevel.Error); | ||
730 | } | ||
731 | |||
732 | for (int j = 0; j < block.Length; j++) | ||
733 | { | ||
734 | output[j] = block[j]*mult + addval; | ||
735 | } | ||
736 | |||
737 | return output; | ||
738 | } | ||
739 | |||
740 | private static int[] CompressPatch(float[] patchData, TerrainPatch.Header header, int prequant, out int wbits) | ||
741 | { | ||
742 | float[] block = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
743 | int wordsize = (prequant - 2) & 0x0f; | ||
744 | float oozrange = 1.0f/header.Range; | ||
745 | float range = (1 << prequant); | ||
746 | float premult = oozrange*range; | ||
747 | float sub = (1 << (prequant - 1)) + header.DCOffset*premult; | ||
748 | |||
749 | header.QuantWBits = wordsize; | ||
750 | header.QuantWBits |= wordsize << 4; | ||
751 | |||
752 | int k = 0; | ||
753 | for (int j = 0; j < Constants.TerrainPatchSize; j++) | ||
754 | { | ||
755 | for (int i = 0; i < Constants.TerrainPatchSize; i++) | ||
756 | block[k++] = patchData[j*Constants.TerrainPatchSize + i]*premult - sub; | ||
757 | } | ||
758 | |||
759 | float[] ftemp = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
760 | int[] itemp = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
761 | |||
762 | |||
763 | int maxWbits = prequant + 5; | ||
764 | wbits = (prequant >> 1); | ||
765 | |||
766 | for (int o = 0; o < Constants.TerrainPatchSize; o++) | ||
767 | DCTLine16(block, ftemp, o); | ||
768 | for (int o = 0; o < Constants.TerrainPatchSize; o++) | ||
769 | wbits = DCTColumn16Wbits(ftemp, itemp, o, wbits, maxWbits); | ||
770 | |||
771 | return itemp; | ||
772 | } | ||
773 | |||
774 | private static int[] CompressPatch(float[,] patchData, TerrainPatch.Header header, int prequant, out int wbits) | ||
775 | { | ||
776 | float[] block = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
777 | float oozrange = 1.0f/header.Range; | ||
778 | float range = (1 << prequant); | ||
779 | float premult = oozrange*range; | ||
780 | float sub = (1 << (prequant - 1)) + header.DCOffset*premult; | ||
781 | int wordsize = (prequant - 2) & 0x0f; | ||
782 | |||
783 | header.QuantWBits = wordsize; | ||
784 | header.QuantWBits |= wordsize << 4; | ||
785 | |||
786 | int k = 0; | ||
787 | for (int j = 0; j < Constants.TerrainPatchSize; j++) | ||
788 | { | ||
789 | for (int i = 0; i < Constants.TerrainPatchSize; i++) | ||
790 | block[k++] = patchData[j, i]*premult - sub; | ||
791 | } | ||
792 | |||
793 | float[] ftemp = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
794 | int[] itemp = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
795 | |||
796 | int maxWbits = prequant + 5; | ||
797 | wbits = (prequant >> 1); | ||
798 | |||
799 | for (int o = 0; o < Constants.TerrainPatchSize; o++) | ||
800 | DCTLine16(block, ftemp, o); | ||
801 | for (int o = 0; o < Constants.TerrainPatchSize; o++) | ||
802 | wbits = DCTColumn16Wbits(ftemp, itemp, o, wbits, maxWbits); | ||
803 | |||
804 | return itemp; | ||
805 | } | ||
806 | |||
807 | private static int[] CompressPatch(TerrainData terrData, int patchX, int patchY, TerrainPatch.Header header, | ||
808 | int prequant, out int wbits) | ||
809 | { | ||
810 | float[] block = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
811 | int wordsize = prequant; | ||
812 | float oozrange = 1.0f/header.Range; | ||
813 | float range = (1 << prequant); | ||
814 | float premult = oozrange*range; | ||
815 | float sub = (1 << (prequant - 1)) + header.DCOffset*premult; | ||
816 | |||
817 | header.QuantWBits = wordsize - 2; | ||
818 | header.QuantWBits |= (prequant - 2) << 4; | ||
819 | |||
820 | int k = 0; | ||
821 | |||
822 | int jPatchLimit = patchY; | ||
823 | if (patchY >= (terrData.SizeY / Constants.TerrainPatchSize)) | ||
824 | { | ||
825 | jPatchLimit = (int)(terrData.SizeY - Constants.TerrainPatchSize) / Constants.TerrainPatchSize; | ||
826 | } | ||
827 | jPatchLimit = (jPatchLimit + 1) * Constants.TerrainPatchSize; | ||
828 | |||
829 | int iPatchLimit = patchX; | ||
830 | if (patchX >= (terrData.SizeX / Constants.TerrainPatchSize)) | ||
831 | { | ||
832 | iPatchLimit = (int)(terrData.SizeX - Constants.TerrainPatchSize) / Constants.TerrainPatchSize; | ||
833 | } | ||
834 | iPatchLimit = (iPatchLimit + 1) * Constants.TerrainPatchSize; | ||
835 | |||
836 | for (int j = patchY * Constants.TerrainPatchSize; j < jPatchLimit; j++) | ||
837 | { | ||
838 | for (int i = patchX * Constants.TerrainPatchSize; i < iPatchLimit; i++) | ||
839 | { | ||
840 | // block[k++] = (heightmap[j*pRegionSizeX + i])*premult - sub; | ||
841 | block[k++] = terrData[j, i] - sub; | ||
842 | } | ||
843 | } | ||
844 | |||
845 | float[] ftemp = new float[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
846 | int[] itemp = new int[Constants.TerrainPatchSize*Constants.TerrainPatchSize]; | ||
847 | |||
848 | int maxWbits = prequant + 5; | ||
849 | wbits = (prequant >> 1); | ||
850 | |||
851 | for (int o = 0; o < Constants.TerrainPatchSize; o++) | ||
852 | DCTLine16(block, ftemp, o); | ||
853 | for (int o = 0; o < Constants.TerrainPatchSize; o++) | ||
854 | wbits = DCTColumn16Wbits(ftemp, itemp, o, wbits, maxWbits); | ||
855 | |||
856 | return itemp; | ||
857 | } | ||
858 | |||
859 | #region Initialization | ||
860 | |||
861 | private static void BuildDequantizeTable16() | ||
862 | { | ||
863 | for (int j = 0; j < Constants.TerrainPatchSize; j++) | ||
864 | { | ||
865 | for (int i = 0; i < Constants.TerrainPatchSize; i++) | ||
866 | { | ||
867 | DequantizeTable16[j*Constants.TerrainPatchSize + i] = 1.0f + 2.0f*(i + j); | ||
868 | } | ||
869 | } | ||
870 | } | ||
871 | |||
872 | private static void BuildQuantizeTable16() | ||
873 | { | ||
874 | const float oosob = 2.0f/Constants.TerrainPatchSize; | ||
875 | for (int j = 0; j < Constants.TerrainPatchSize; j++) | ||
876 | { | ||
877 | for (int i = 0; i < Constants.TerrainPatchSize; i++) | ||
878 | { | ||
879 | // QuantizeTable16[j * Constants.TerrainPatchSize + i] = 1.0f / (1.0f + 2.0f * ((float)i + (float)j)); | ||
880 | QuantizeTable16[j*Constants.TerrainPatchSize + i] = oosob/(1.0f + 2.0f*(i + (float) j)); | ||
881 | } | ||
882 | } | ||
883 | } | ||
884 | |||
885 | private static void SetupCosines16() | ||
886 | { | ||
887 | const float hposz = (float) Math.PI*0.5f/Constants.TerrainPatchSize; | ||
888 | |||
889 | for (int u = 0; u < Constants.TerrainPatchSize; u++) | ||
890 | { | ||
891 | for (int n = 0; n < Constants.TerrainPatchSize; n++) | ||
892 | { | ||
893 | CosineTable16[u*Constants.TerrainPatchSize + n] = (float) Math.Cos((2.0f*n + 1.0f)*u*hposz); | ||
894 | } | ||
895 | } | ||
896 | } | ||
897 | |||
898 | private static void BuildCopyMatrix16() | ||
899 | { | ||
900 | bool diag = false; | ||
901 | bool right = true; | ||
902 | int i = 0; | ||
903 | int j = 0; | ||
904 | int count = 0; | ||
905 | |||
906 | while (i < Constants.TerrainPatchSize && j < Constants.TerrainPatchSize) | ||
907 | { | ||
908 | CopyMatrix16[j*Constants.TerrainPatchSize + i] = count++; | ||
909 | |||
910 | if (!diag) | ||
911 | { | ||
912 | if (right) | ||
913 | { | ||
914 | if (i < Constants.TerrainPatchSize - 1) i++; | ||
915 | else j++; | ||
916 | |||
917 | right = false; | ||
918 | diag = true; | ||
919 | } | ||
920 | else | ||
921 | { | ||
922 | if (j < Constants.TerrainPatchSize - 1) j++; | ||
923 | else i++; | ||
924 | |||
925 | right = true; | ||
926 | diag = true; | ||
927 | } | ||
928 | } | ||
929 | else | ||
930 | { | ||
931 | if (right) | ||
932 | { | ||
933 | i++; | ||
934 | j--; | ||
935 | if (i == Constants.TerrainPatchSize - 1 || j == 0) diag = false; | ||
936 | } | ||
937 | else | ||
938 | { | ||
939 | i--; | ||
940 | j++; | ||
941 | if (j == Constants.TerrainPatchSize - 1 || i == 0) diag = false; | ||
942 | } | ||
943 | } | ||
944 | } | ||
945 | } | ||
946 | |||
947 | #endregion Initialization | ||
948 | } | ||
949 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs index d4fe5e0..cbc538e 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs | |||
@@ -84,8 +84,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
84 | 84 | ||
85 | Region = scene.RegionInfo.RegionName; | 85 | Region = scene.RegionInfo.RegionName; |
86 | Host = scene.RegionInfo.ExternalHostName; | 86 | Host = scene.RegionInfo.ExternalHostName; |
87 | LocX = Convert.ToString(scene.RegionInfo.RegionLocX); | 87 | LocX = Convert.ToString(scene.RegionInfo.LegacyRegionLocX); |
88 | LocY = Convert.ToString(scene.RegionInfo.RegionLocY); | 88 | LocY = Convert.ToString(scene.RegionInfo.LegacyRegionLocY); |
89 | IDK = Convert.ToString(_idk_++); | 89 | IDK = Convert.ToString(_idk_++); |
90 | 90 | ||
91 | showAlert = config.GetBoolean("alert_show", false); | 91 | showAlert = config.GetBoolean("alert_show", false); |
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs index 83732e2..7f616bb 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs | |||
@@ -100,8 +100,8 @@ namespace OpenSim.Region.RegionCombinerModule | |||
100 | UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, | 100 | UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, |
101 | UUID fromtaskid) | 101 | UUID fromtaskid) |
102 | { | 102 | { |
103 | int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; | 103 | int differenceX = (int)m_virtScene.RegionInfo.LegacyRegionLocX - (int)m_rootScene.RegionInfo.LegacyRegionLocX; |
104 | int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; | 104 | int differenceY = (int)m_virtScene.RegionInfo.LegacyRegionLocY - (int)m_rootScene.RegionInfo.LegacyRegionLocY; |
105 | rayend.X += differenceX * (int)Constants.RegionSize; | 105 | rayend.X += differenceX * (int)Constants.RegionSize; |
106 | rayend.Y += differenceY * (int)Constants.RegionSize; | 106 | rayend.Y += differenceY * (int)Constants.RegionSize; |
107 | raystart.X += differenceX * (int)Constants.RegionSize; | 107 | raystart.X += differenceX * (int)Constants.RegionSize; |
@@ -126,8 +126,8 @@ namespace OpenSim.Region.RegionCombinerModule | |||
126 | PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, | 126 | PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, |
127 | byte rayendisintersection) | 127 | byte rayendisintersection) |
128 | { | 128 | { |
129 | int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; | 129 | int differenceX = (int)m_virtScene.RegionInfo.LegacyRegionLocX - (int)m_rootScene.RegionInfo.LegacyRegionLocX; |
130 | int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; | 130 | int differenceY = (int)m_virtScene.RegionInfo.LegacyRegionLocY - (int)m_rootScene.RegionInfo.LegacyRegionLocY; |
131 | rayend.X += differenceX * (int)Constants.RegionSize; | 131 | rayend.X += differenceX * (int)Constants.RegionSize; |
132 | rayend.Y += differenceY * (int)Constants.RegionSize; | 132 | rayend.Y += differenceY * (int)Constants.RegionSize; |
133 | raystart.X += differenceX * (int)Constants.RegionSize; | 133 | raystart.X += differenceX * (int)Constants.RegionSize; |
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 7127c73..3f835a4 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | |||
@@ -246,8 +246,8 @@ namespace OpenSim.Region.RegionCombinerModule | |||
246 | newConn.RegionScene = scene; | 246 | newConn.RegionScene = scene; |
247 | newConn.RegionLandChannel = scene.LandChannel; | 247 | newConn.RegionLandChannel = scene.LandChannel; |
248 | newConn.RegionId = scene.RegionInfo.originRegionID; | 248 | newConn.RegionId = scene.RegionInfo.originRegionID; |
249 | newConn.X = scene.RegionInfo.RegionLocX; | 249 | newConn.X = scene.RegionInfo.LegacyRegionLocX; |
250 | newConn.Y = scene.RegionInfo.RegionLocY; | 250 | newConn.Y = scene.RegionInfo.LegacyRegionLocY; |
251 | newConn.XEnd = (int)Constants.RegionSize; | 251 | newConn.XEnd = (int)Constants.RegionSize; |
252 | newConn.YEnd = (int)Constants.RegionSize; | 252 | newConn.YEnd = (int)Constants.RegionSize; |
253 | 253 | ||
@@ -502,11 +502,11 @@ namespace OpenSim.Region.RegionCombinerModule | |||
502 | 502 | ||
503 | lock (scene.WestBorders) | 503 | lock (scene.WestBorders) |
504 | { | 504 | { |
505 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | 505 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.LegacyRegionLocX - rootConn.RegionScene.RegionInfo.LegacyRegionLocX) * (int)Constants.RegionSize); //auto teleport West |
506 | 506 | ||
507 | // Trigger auto teleport to root region | 507 | // Trigger auto teleport to root region |
508 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; | 508 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.LegacyRegionLocX; |
509 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; | 509 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.LegacyRegionLocY; |
510 | } | 510 | } |
511 | 511 | ||
512 | // Reset Terrain.. since terrain loads before we get here, we need to load | 512 | // Reset Terrain.. since terrain loads before we get here, we need to load |
@@ -564,9 +564,9 @@ namespace OpenSim.Region.RegionCombinerModule | |||
564 | 564 | ||
565 | lock (scene.SouthBorders) | 565 | lock (scene.SouthBorders) |
566 | { | 566 | { |
567 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | 567 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.LegacyRegionLocY - rootConn.RegionScene.RegionInfo.LegacyRegionLocY) * (int)Constants.RegionSize); //auto teleport south |
568 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; | 568 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.LegacyRegionLocX; |
569 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; | 569 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.LegacyRegionLocY; |
570 | } | 570 | } |
571 | 571 | ||
572 | // Reset Terrain.. since terrain normally loads first. | 572 | // Reset Terrain.. since terrain normally loads first. |
@@ -636,9 +636,9 @@ namespace OpenSim.Region.RegionCombinerModule | |||
636 | 636 | ||
637 | lock (scene.SouthBorders) | 637 | lock (scene.SouthBorders) |
638 | { | 638 | { |
639 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | 639 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.LegacyRegionLocY - rootConn.RegionScene.RegionInfo.LegacyRegionLocY) * (int)Constants.RegionSize); //auto teleport south |
640 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; | 640 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.LegacyRegionLocX; |
641 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; | 641 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.LegacyRegionLocY; |
642 | } | 642 | } |
643 | 643 | ||
644 | lock (rootConn.RegionScene.EastBorders) | 644 | lock (rootConn.RegionScene.EastBorders) |
@@ -657,9 +657,9 @@ namespace OpenSim.Region.RegionCombinerModule | |||
657 | 657 | ||
658 | lock (scene.WestBorders) | 658 | lock (scene.WestBorders) |
659 | { | 659 | { |
660 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | 660 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.LegacyRegionLocX - rootConn.RegionScene.RegionInfo.LegacyRegionLocX) * (int)Constants.RegionSize); //auto teleport West |
661 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; | 661 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.LegacyRegionLocX; |
662 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; | 662 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.LegacyRegionLocY; |
663 | } | 663 | } |
664 | 664 | ||
665 | /* | 665 | /* |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b19ed0a..e03cf17 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -4244,10 +4244,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4244 | DataserverPlugin.RegisterRequest(m_host.LocalId, | 4244 | DataserverPlugin.RegisterRequest(m_host.LocalId, |
4245 | m_item.ItemID, item.AssetID.ToString()); | 4245 | m_item.ItemID, item.AssetID.ToString()); |
4246 | 4246 | ||
4247 | Vector3 region = new Vector3( | 4247 | Vector3 region = new Vector3(World.RegionInfo.RegionWorldLocX, World.RegionInfo.RegionWorldLocY, 0); |
4248 | World.RegionInfo.RegionLocX * Constants.RegionSize, | ||
4249 | World.RegionInfo.RegionLocY * Constants.RegionSize, | ||
4250 | 0); | ||
4251 | 4248 | ||
4252 | World.AssetService.Get(item.AssetID.ToString(), this, | 4249 | World.AssetService.Get(item.AssetID.ToString(), this, |
4253 | delegate(string i, object sender, AssetBase a) | 4250 | delegate(string i, object sender, AssetBase a) |
@@ -5481,7 +5478,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5481 | public LSL_Vector llGetRegionCorner() | 5478 | public LSL_Vector llGetRegionCorner() |
5482 | { | 5479 | { |
5483 | m_host.AddScriptLPS(1); | 5480 | m_host.AddScriptLPS(1); |
5484 | return new LSL_Vector(World.RegionInfo.RegionLocX * Constants.RegionSize, World.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 5481 | return new LSL_Vector(World.RegionInfo.RegionWorldLocX, World.RegionInfo.RegionWorldLocY, 0); |
5485 | } | 5482 | } |
5486 | 5483 | ||
5487 | /// <summary> | 5484 | /// <summary> |
@@ -5654,8 +5651,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5654 | 5651 | ||
5655 | List<GridRegion> neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID); | 5652 | List<GridRegion> neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID); |
5656 | 5653 | ||
5657 | uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x; | 5654 | uint neighborX = World.RegionInfo.LegacyRegionLocX + (uint)dir.x; |
5658 | uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y; | 5655 | uint neighborY = World.RegionInfo.LegacyRegionLocY + (uint)dir.y; |
5659 | 5656 | ||
5660 | foreach (GridRegion sri in neighbors) | 5657 | foreach (GridRegion sri in neighbors) |
5661 | { | 5658 | { |
@@ -10740,7 +10737,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10740 | httpHeaders["X-SecondLife-Shard"] = shard; | 10737 | httpHeaders["X-SecondLife-Shard"] = shard; |
10741 | httpHeaders["X-SecondLife-Object-Name"] = m_host.Name; | 10738 | httpHeaders["X-SecondLife-Object-Name"] = m_host.Name; |
10742 | httpHeaders["X-SecondLife-Object-Key"] = m_host.UUID.ToString(); | 10739 | httpHeaders["X-SecondLife-Object-Key"] = m_host.UUID.ToString(); |
10743 | httpHeaders["X-SecondLife-Region"] = string.Format("{0} ({1}, {2})", regionInfo.RegionName, regionInfo.RegionLocX, regionInfo.RegionLocY); | 10740 | httpHeaders["X-SecondLife-Region"] = string.Format("{0} ({1}, {2})", regionInfo.RegionName, regionInfo.LegacyRegionLocX, regionInfo.LegacyRegionLocY); |
10744 | httpHeaders["X-SecondLife-Local-Position"] = string.Format("({0:0.000000}, {1:0.000000}, {2:0.000000})", position.X, position.Y, position.Z); | 10741 | httpHeaders["X-SecondLife-Local-Position"] = string.Format("({0:0.000000}, {1:0.000000}, {2:0.000000})", position.X, position.Y, position.Z); |
10745 | httpHeaders["X-SecondLife-Local-Velocity"] = string.Format("({0:0.000000}, {1:0.000000}, {2:0.000000})", velocity.X, velocity.Y, velocity.Z); | 10742 | httpHeaders["X-SecondLife-Local-Velocity"] = string.Format("({0:0.000000}, {1:0.000000}, {2:0.000000})", velocity.X, velocity.Y, velocity.Z); |
10746 | httpHeaders["X-SecondLife-Local-Rotation"] = string.Format("({0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000})", rotation.X, rotation.Y, rotation.Z, rotation.W); | 10743 | httpHeaders["X-SecondLife-Local-Rotation"] = string.Format("({0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000})", rotation.X, rotation.Y, rotation.Z, rotation.W); |