aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs248
1 files changed, 193 insertions, 55 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
index 5c5f164..91d736b 100644
--- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
@@ -32,6 +32,7 @@ using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Client;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
37 38
@@ -71,6 +72,18 @@ namespace OpenSim.Region.CoreModules.World.Land
71 public void AddRegion(Scene scene) 72 public void AddRegion(Scene scene)
72 { 73 {
73 74
75
76
77 }
78
79 public void RemoveRegion(Scene scene)
80 {
81
82
83 }
84
85 public void RegionLoaded(Scene scene)
86 {
74 if (!enabledYN) 87 if (!enabledYN)
75 return; 88 return;
76 89
@@ -295,8 +308,8 @@ namespace OpenSim.Region.CoreModules.World.Land
295 m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", 308 m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}",
296 conn.RegionScene.RegionInfo.RegionName, 309 conn.RegionScene.RegionInfo.RegionName,
297 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); 310 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
298 311
299 312
300 scene.BordersLocked = true; 313 scene.BordersLocked = true;
301 conn.RegionScene.BordersLocked = true; 314 conn.RegionScene.BordersLocked = true;
302 315
@@ -325,9 +338,11 @@ namespace OpenSim.Region.CoreModules.World.Land
325 // 338 //
326 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); 339 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
327 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 340 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
328 341
329 conn.RegionScene.BordersLocked = false; 342 conn.RegionScene.BordersLocked = false;
330 scene.BordersLocked = false; 343 scene.BordersLocked = false;
344 if (conn.ClientEventForwarder != null)
345 conn.ClientEventForwarder.AddSceneToEventForwarding(scene);
331 connectedYN = true; 346 connectedYN = true;
332 break; 347 break;
333 } 348 }
@@ -367,7 +382,7 @@ namespace OpenSim.Region.CoreModules.World.Land
367 m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", 382 m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}",
368 conn.RegionScene.RegionInfo.RegionName, 383 conn.RegionScene.RegionInfo.RegionName,
369 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); 384 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
370 conn.RegionScene.PhysicsScene.Combine(null,Vector3.Zero,extents); 385 conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
371 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); 386 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero);
372 387
373 lock (conn.RegionScene.NorthBorders) 388 lock (conn.RegionScene.NorthBorders)
@@ -386,7 +401,8 @@ namespace OpenSim.Region.CoreModules.World.Land
386 401
387 scene.BordersLocked = false; 402 scene.BordersLocked = false;
388 conn.RegionScene.BordersLocked = false; 403 conn.RegionScene.BordersLocked = false;
389 404 if (conn.ClientEventForwarder != null)
405 conn.ClientEventForwarder.AddSceneToEventForwarding(scene);
390 connectedYN = true; 406 connectedYN = true;
391 break; 407 break;
392 } 408 }
@@ -424,52 +440,52 @@ namespace OpenSim.Region.CoreModules.World.Land
424 m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", 440 m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}",
425 conn.RegionScene.RegionInfo.RegionName, 441 conn.RegionScene.RegionInfo.RegionName,
426 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); 442 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
427 443
428 conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); 444 conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
429 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); 445 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero);
430 lock (conn.RegionScene.NorthBorders) 446 lock (conn.RegionScene.NorthBorders)
431 if (conn.RegionScene.NorthBorders.Count == 1)// && 2) 447 if (conn.RegionScene.NorthBorders.Count == 1)// && 2)
432 { 448 {
433 //compound border 449 //compound border
434 // already locked above 450 // already locked above
435 conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; 451 conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize;
436 452
437 lock (conn.RegionScene.EastBorders) 453 lock (conn.RegionScene.EastBorders)
438 conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; 454 conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize;
439 lock (conn.RegionScene.WestBorders) 455 lock (conn.RegionScene.WestBorders)
440 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; 456 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
441 457
442
443 458
444 } 459
460 }
445 lock (scene.SouthBorders) 461 lock (scene.SouthBorders)
446 scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south 462 scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south
447 463
448 lock (conn.RegionScene.EastBorders) 464 lock (conn.RegionScene.EastBorders)
449 if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) 465 if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2)
450 { 466 {
451 467
452 conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; 468 conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize;
453 lock (conn.RegionScene.NorthBorders) 469 lock (conn.RegionScene.NorthBorders)
454 conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; 470 conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
455 lock (conn.RegionScene.SouthBorders) 471 lock (conn.RegionScene.SouthBorders)
456 conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; 472 conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
457 473
458 474
459 } 475 }
460 476
461 lock (scene.WestBorders) 477 lock (scene.WestBorders)
462 scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West 478 scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West
463/* 479 /*
464 else 480 else
465 { 481 {
466 conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; 482 conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize;
467 conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; 483 conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize;
468 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; 484 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
469 scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south 485 scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south
470 } 486 }
471*/ 487 */
472 488
473 489
474 // Reset Terrain.. since terrain normally loads first. 490 // Reset Terrain.. since terrain normally loads first.
475 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 491 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
@@ -478,6 +494,9 @@ namespace OpenSim.Region.CoreModules.World.Land
478 scene.BordersLocked = false; 494 scene.BordersLocked = false;
479 conn.RegionScene.BordersLocked = false; 495 conn.RegionScene.BordersLocked = false;
480 496
497 if (conn.ClientEventForwarder != null)
498 conn.ClientEventForwarder.AddSceneToEventForwarding(scene);
499
481 connectedYN = true; 500 connectedYN = true;
482 501
483 //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); 502 //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents);
@@ -495,7 +514,7 @@ namespace OpenSim.Region.CoreModules.World.Land
495 rdata.RegionScene = scene; 514 rdata.RegionScene = scene;
496 regionConnections.RegionLandChannel = scene.LandChannel; 515 regionConnections.RegionLandChannel = scene.LandChannel;
497 516
498 RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata,scene.LandChannel,regionConnections.ConnectedRegions); 517 RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, regionConnections.ConnectedRegions);
499 scene.LandChannel = lnd; 518 scene.LandChannel = lnd;
500 lock (m_regions) 519 lock (m_regions)
501 { 520 {
@@ -504,24 +523,14 @@ namespace OpenSim.Region.CoreModules.World.Land
504 ForwardPermissionRequests(regionConnections, r.RegionScene); 523 ForwardPermissionRequests(regionConnections, r.RegionScene);
505 } 524 }
506 } 525 }
507 526
508 m_regions.Add(scene.RegionInfo.originRegionID,regionConnections); 527 regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections);
528
529 m_regions.Add(scene.RegionInfo.originRegionID, regionConnections);
509 } 530 }
510 531
511 } 532 }
512 AdjustLargeRegionBounds(); 533 AdjustLargeRegionBounds();
513
514 }
515
516 public void RemoveRegion(Scene scene)
517 {
518
519
520 }
521
522 public void RegionLoaded(Scene scene)
523 {
524
525 } 534 }
526 535
527 public void PostInitialise() 536 public void PostInitialise()
@@ -733,6 +742,7 @@ namespace OpenSim.Region.CoreModules.World.Land
733 public int YEnd; 742 public int YEnd;
734 public List<RegionData> ConnectedRegions; 743 public List<RegionData> ConnectedRegions;
735 public RegionCombinerPermissionModule PermissionModule; 744 public RegionCombinerPermissionModule PermissionModule;
745 public RegionCombinerClientEventForwarder ClientEventForwarder;
736 public void UpdateExtents(Vector3 extents) 746 public void UpdateExtents(Vector3 extents)
737 { 747 {
738 XEnd = (int)extents.X; 748 XEnd = (int)extents.X;
@@ -790,7 +800,7 @@ namespace OpenSim.Region.CoreModules.World.Land
790 else 800 else
791 { 801 {
792 int offsetX = (x / (int)Constants.RegionSize); 802 int offsetX = (x / (int)Constants.RegionSize);
793 int offsetY = (x / (int)Constants.RegionSize); 803 int offsetY = (y / (int)Constants.RegionSize);
794 offsetX *= (int)Constants.RegionSize; 804 offsetX *= (int)Constants.RegionSize;
795 offsetY *= (int)Constants.RegionSize; 805 offsetY *= (int)Constants.RegionSize;
796 806
@@ -823,7 +833,7 @@ namespace OpenSim.Region.CoreModules.World.Land
823 else 833 else
824 { 834 {
825 int offsetX = (int)(x/(int) Constants.RegionSize); 835 int offsetX = (int)(x/(int) Constants.RegionSize);
826 int offsetY = (int)(x/(int) Constants.RegionSize); 836 int offsetY = (int)(y/(int) Constants.RegionSize);
827 offsetX *= (int) Constants.RegionSize; 837 offsetX *= (int) Constants.RegionSize;
828 offsetY *= (int) Constants.RegionSize; 838 offsetY *= (int) Constants.RegionSize;
829 839
@@ -886,6 +896,7 @@ namespace OpenSim.Region.CoreModules.World.Land
886 m_rootScene = RootScene; 896 m_rootScene = RootScene;
887 } 897 }
888 898
899 #region Permission Override
889 public bool BypassPermissions() 900 public bool BypassPermissions()
890 { 901 {
891 return m_rootScene.Permissions.BypassPermissions(); 902 return m_rootScene.Permissions.BypassPermissions();
@@ -1110,5 +1121,132 @@ namespace OpenSim.Region.CoreModules.World.Land
1110 { 1121 {
1111 return m_rootScene.Permissions.CanUseObjectReturn(landdata, type, client, retlist); 1122 return m_rootScene.Permissions.CanUseObjectReturn(landdata, type, client, retlist);
1112 } 1123 }
1124 #endregion
1125 }
1126
1127 public class RegionCombinerClientEventForwarder
1128 {
1129 private Scene m_rootScene;
1130 private Dictionary<UUID, Scene> m_virtScene = new Dictionary<UUID, Scene>();
1131 private Dictionary<UUID,RegionCombinerModuleIndividualForwarder> m_forwarders = new Dictionary<UUID, RegionCombinerModuleIndividualForwarder>();
1132 public RegionCombinerClientEventForwarder(RegionConnections rootScene)
1133 {
1134 m_rootScene = rootScene.RegionScene;
1135
1136
1137 }
1138
1139 public void AddSceneToEventForwarding( Scene virtualScene )
1140 {
1141 lock (m_virtScene)
1142 {
1143 if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID))
1144 {
1145 m_virtScene[virtualScene.RegionInfo.originRegionID] = virtualScene;
1146 }
1147 else
1148 {
1149 m_virtScene.Add(virtualScene.RegionInfo.originRegionID, virtualScene);
1150 }
1151 }
1152
1153 lock (m_forwarders)
1154 {
1155 // TODO: Fix this to unregister if this happens
1156 if (m_forwarders.ContainsKey(virtualScene.RegionInfo.originRegionID))
1157 m_forwarders.Remove(virtualScene.RegionInfo.originRegionID);
1158
1159 RegionCombinerModuleIndividualForwarder forwarder =
1160 new RegionCombinerModuleIndividualForwarder(m_rootScene, virtualScene);
1161 m_forwarders.Add(virtualScene.RegionInfo.originRegionID, forwarder);
1162
1163 virtualScene.EventManager.OnNewClient += forwarder.ClientConnect;
1164 virtualScene.EventManager.OnClientClosed += forwarder.ClientClosed;
1165 }
1166 }
1167
1168 public void RemoveSceneFromEventForwarding (Scene virtualScene)
1169 {
1170 lock (m_forwarders)
1171 {
1172 RegionCombinerModuleIndividualForwarder forwarder = m_forwarders[virtualScene.RegionInfo.originRegionID];
1173 virtualScene.EventManager.OnNewClient -= forwarder.ClientConnect;
1174 virtualScene.EventManager.OnClientClosed -= forwarder.ClientClosed;
1175 m_forwarders.Remove(virtualScene.RegionInfo.originRegionID);
1176 }
1177 lock (m_virtScene)
1178 {
1179 if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID))
1180 {
1181 m_virtScene.Remove(virtualScene.RegionInfo.originRegionID);
1182 }
1183 }
1184 }
1185 }
1186
1187 public class RegionCombinerModuleIndividualForwarder
1188 {
1189 private Scene m_rootScene;
1190 private Scene m_virtScene;
1191 public RegionCombinerModuleIndividualForwarder(Scene rootScene, Scene virtScene)
1192 {
1193 m_rootScene = rootScene;
1194 m_virtScene = virtScene;
1195 }
1196
1197 public void ClientConnect(IClientAPI client)
1198 {
1199
1200 m_virtScene.UnSubscribeToClientPrimEvents(client);
1201 m_virtScene.UnSubscribeToClientPrimRezEvents(client);
1202 m_virtScene.UnSubscribeToClientInventoryEvents(client);
1203 m_virtScene.UnSubscribeToClientAttachmentEvents(client);
1204 m_virtScene.UnSubscribeToClientTeleportEvents(client);
1205 m_virtScene.UnSubscribeToClientScriptEvents(client);
1206 m_virtScene.UnSubscribeToClientGodEvents(client);
1207 m_virtScene.UnSubscribeToClientNetworkEvents(client);
1208
1209 m_rootScene.SubscribeToClientPrimEvents(client);
1210 client.OnAddPrim += LocalAddNewPrim;
1211 client.OnRezObject += LocalRezObject;
1212 m_rootScene.SubscribeToClientInventoryEvents(client);
1213 m_rootScene.SubscribeToClientAttachmentEvents(client);
1214 m_rootScene.SubscribeToClientTeleportEvents(client);
1215 m_rootScene.SubscribeToClientScriptEvents(client);
1216 m_rootScene.SubscribeToClientGodEvents(client);
1217 m_rootScene.SubscribeToClientNetworkEvents(client);
1218 }
1219 public void ClientClosed(UUID clientid, Scene scene)
1220 {
1221
1222 }
1223
1224
1225 private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart, UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, UUID fromtaskid)
1226 {
1227 int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX;
1228 int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY;
1229 rayend.X += differenceX * (int)Constants.RegionSize;
1230 rayend.Y += differenceY * (int)Constants.RegionSize;
1231 raystart.X += differenceX * (int)Constants.RegionSize;
1232 raystart.Y += differenceY * (int)Constants.RegionSize;
1233
1234 m_rootScene.RezObject(remoteclient, itemid, rayend, raystart, raytargetid, bypassraycast,
1235 rayendisintersection, rezselected, removeitem, fromtaskid);
1236
1237 }
1238
1239 private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot, PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, byte rayendisintersection)
1240 {
1241 int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX;
1242 int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY;
1243 rayend.X += differenceX * (int)Constants.RegionSize;
1244 rayend.Y += differenceY * (int)Constants.RegionSize;
1245 raystart.X += differenceX * (int)Constants.RegionSize;
1246 raystart.Y += differenceY * (int)Constants.RegionSize;
1247 m_rootScene.AddNewPrim(ownerid, groupid, rayend, rot, shape, bypassraycast, raystart, raytargetid,
1248 rayendisintersection);
1249
1250 }
1113 } 1251 }
1114} 1252}