aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorTeravus Ovares (Dan Olivares)2009-09-05 02:58:35 -0400
committerTeravus Ovares (Dan Olivares)2009-09-05 02:58:35 -0400
commit855fb58c9650086122b76c586c4a4a408343143f (patch)
treeb0a6f98c26c59c8f228e1c3e3e208b30024fda06 /OpenSim/Region/CoreModules
parentMerge branch 'master' of ssh://MyConnection/var/git/opensim (diff)
downloadopensim-SC_OLD-855fb58c9650086122b76c586c4a4a408343143f.zip
opensim-SC_OLD-855fb58c9650086122b76c586c4a4a408343143f.tar.gz
opensim-SC_OLD-855fb58c9650086122b76c586c4a4a408343143f.tar.bz2
opensim-SC_OLD-855fb58c9650086122b76c586c4a4a408343143f.tar.xz
* Moves ScenePresence SendCourseLocations to a delegate and provide a method to replace the delegate
* RegionCombinerModule replaces this delegate and distributes the CoarseLocationUpdates through the client connection in the region where the user would be if it was a separate region. * Fixes Mini Map display on combined regions.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs171
1 files changed, 165 insertions, 6 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
index 91d736b..9da869c 100644
--- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
@@ -514,7 +514,8 @@ namespace OpenSim.Region.CoreModules.World.Land
514 rdata.RegionScene = scene; 514 rdata.RegionScene = scene;
515 regionConnections.RegionLandChannel = scene.LandChannel; 515 regionConnections.RegionLandChannel = scene.LandChannel;
516 516
517 RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, regionConnections.ConnectedRegions); 517 RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel,
518 regionConnections.ConnectedRegions);
518 scene.LandChannel = lnd; 519 scene.LandChannel = lnd;
519 lock (m_regions) 520 lock (m_regions)
520 { 521 {
@@ -525,19 +526,164 @@ namespace OpenSim.Region.CoreModules.World.Land
525 } 526 }
526 527
527 regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); 528 regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections);
528 529 scene.EventManager.OnNewPresence += SetCourseLocationDelegate;
529 m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); 530 m_regions.Add(scene.RegionInfo.originRegionID, regionConnections);
531
530 } 532 }
531 533
532 } 534 }
533 AdjustLargeRegionBounds(); 535 AdjustLargeRegionBounds();
534 } 536 }
535 537
538 private void SetCourseLocationDelegate(ScenePresence presence)
539 {
540 presence.SetSendCourseLocationMethod(SendCourseLocationUpdates);
541 }
542
543 private void SendCourseLocationUpdates(UUID sceneId, ScenePresence presence)
544 {
545 RegionConnections connectiondata = null;
546 lock (m_regions)
547 {
548 if (m_regions.ContainsKey(sceneId))
549 connectiondata = m_regions[sceneId];
550 else
551 return;
552 }
553
554 List<ScenePresence> avatars = connectiondata.RegionScene.GetAvatars();
555 List<Vector3> CoarseLocations = new List<Vector3>();
556 List<UUID> AvatarUUIDs = new List<UUID>();
557 for (int i = 0; i < avatars.Count; i++)
558 {
559 if (avatars[i].UUID != presence.UUID)
560 {
561 if (avatars[i].ParentID != 0)
562 {
563 // sitting avatar
564 SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(avatars[i].ParentID);
565 if (sop != null)
566 {
567 CoarseLocations.Add(sop.AbsolutePosition + avatars[i].AbsolutePosition);
568 AvatarUUIDs.Add(avatars[i].UUID);
569 }
570 else
571 {
572 // we can't find the parent.. ! arg!
573 CoarseLocations.Add(avatars[i].AbsolutePosition);
574 AvatarUUIDs.Add(avatars[i].UUID);
575 }
576 }
577 else
578 {
579 CoarseLocations.Add(avatars[i].AbsolutePosition);
580 AvatarUUIDs.Add(avatars[i].UUID);
581 }
582 }
583 }
584 DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence);
585 }
586
587 private void DistributeCourseLocationUpdates(List<Vector3> locations, List<UUID> uuids,
588 RegionConnections connectiondata, ScenePresence rootPresence)
589 {
590 RegionData[] rdata = connectiondata.ConnectedRegions.ToArray();
591 List<IClientAPI> clients = new List<IClientAPI>();
592 Dictionary<Vector2, RegionCourseLocationStruct> updates = new Dictionary<Vector2, RegionCourseLocationStruct>();
593
594
595 // Root Region entry
596 RegionCourseLocationStruct rootupdatedata = new RegionCourseLocationStruct();
597 rootupdatedata.Locations = new List<Vector3>();
598 rootupdatedata.Uuids = new List<UUID>();
599 rootupdatedata.Offset = Vector2.Zero;
600
601 rootupdatedata.UserAPI = rootPresence.ControllingClient;
602
603 if (rootupdatedata.UserAPI != null)
604 updates.Add(Vector2.Zero, rootupdatedata);
605
606 //Each Region needs an entry or we will end up with dead minimap dots
607 foreach (RegionData regiondata in rdata)
608 {
609 Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y);
610 RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct();
611 updatedata.Locations = new List<Vector3>();
612 updatedata.Uuids = new List<UUID>();
613 updatedata.Offset = offset;
614
615 if (offset == Vector2.Zero)
616 updatedata.UserAPI = rootPresence.ControllingClient;
617 else
618 updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata);
619
620 if (updatedata.UserAPI != null)
621 updates.Add(offset, updatedata);
622 }
623
624 // go over the locations and assign them to an IClientAPI
625 for (int i = 0; i < locations.Count;i++ )
626 //{locations[i]/(int) Constants.RegionSize;
627 {
628 Vector3 pPosition = new Vector3((int)locations[i].X / (int)Constants.RegionSize,
629 (int)locations[i].Y / (int)Constants.RegionSize, locations[i].Z);
630 Vector2 offset = new Vector2(pPosition.X*(int) Constants.RegionSize,
631 pPosition.Y*(int) Constants.RegionSize);
632
633 if (!updates.ContainsKey(offset))
634 {
635 // This shouldn't happen
636 RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct();
637 updatedata.Locations = new List<Vector3>();
638 updatedata.Uuids = new List<UUID>();
639 updatedata.Offset = offset;
640
641 if (offset == Vector2.Zero)
642 updatedata.UserAPI = rootPresence.ControllingClient;
643 else
644 updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata);
645
646 updates.Add(offset,updatedata);
647
648 }
649
650 updates[offset].Locations.Add(locations[i]);
651 updates[offset].Uuids.Add(uuids[i]);
652
653 }
654
655 // Send out the CoarseLocationupdates from their respective client connection based on where the avatar is
656 foreach (Vector2 offset in updates.Keys)
657 {
658 if (updates[offset].UserAPI != null)
659 {
660 updates[offset].UserAPI.SendCoarseLocationUpdate(updates[offset].Uuids,updates[offset].Locations);
661 }
662 }
663
664 }
665
666 private IClientAPI LocateUsersChildAgentIClientAPI(Vector2 offset, UUID uUID, RegionData[] rdata)
667 {
668 IClientAPI returnclient = null;
669 foreach (RegionData r in rdata)
670 {
671 if (r.Offset.X == offset.X && r.Offset.Y == offset.Y)
672 {
673 return r.RegionScene.SceneGraph.GetControllingClient(uUID);
674 }
675 }
676
677 return returnclient;
678 }
679
536 public void PostInitialise() 680 public void PostInitialise()
537 { 681 {
538 682
539 } 683 }
540 684
685
686
541 public void UnCombineRegion(RegionData rdata) 687 public void UnCombineRegion(RegionData rdata)
542 { 688 {
543 lock (m_regions) 689 lock (m_regions)
@@ -758,6 +904,13 @@ namespace OpenSim.Region.CoreModules.World.Land
758 public Vector3 Offset; 904 public Vector3 Offset;
759 905
760 } 906 }
907 struct RegionCourseLocationStruct
908 {
909 public List<Vector3> Locations;
910 public List<UUID> Uuids;
911 public IClientAPI UserAPI;
912 public Vector2 Offset;
913 }
761 914
762 public class RegionCombinerLargeLandChannel : ILandChannel 915 public class RegionCombinerLargeLandChannel : ILandChannel
763 { 916 {
@@ -769,7 +922,8 @@ namespace OpenSim.Region.CoreModules.World.Land
769 922
770 #region ILandChannel Members 923 #region ILandChannel Members
771 924
772 public RegionCombinerLargeLandChannel(RegionData regData, ILandChannel rootRegionLandChannel,List<RegionData> regionConnections) 925 public RegionCombinerLargeLandChannel(RegionData regData, ILandChannel rootRegionLandChannel,
926 List<RegionData> regionConnections)
773 { 927 {
774 RegData = regData; 928 RegData = regData;
775 RootRegionLandChannel = rootRegionLandChannel; 929 RootRegionLandChannel = rootRegionLandChannel;
@@ -1128,7 +1282,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1128 { 1282 {
1129 private Scene m_rootScene; 1283 private Scene m_rootScene;
1130 private Dictionary<UUID, Scene> m_virtScene = new Dictionary<UUID, Scene>(); 1284 private Dictionary<UUID, Scene> m_virtScene = new Dictionary<UUID, Scene>();
1131 private Dictionary<UUID,RegionCombinerModuleIndividualForwarder> m_forwarders = new Dictionary<UUID, RegionCombinerModuleIndividualForwarder>(); 1285 private Dictionary<UUID,RegionCombinerModuleIndividualForwarder> m_forwarders = new Dictionary<UUID,
1286 RegionCombinerModuleIndividualForwarder>();
1132 public RegionCombinerClientEventForwarder(RegionConnections rootScene) 1287 public RegionCombinerClientEventForwarder(RegionConnections rootScene)
1133 { 1288 {
1134 m_rootScene = rootScene.RegionScene; 1289 m_rootScene = rootScene.RegionScene;
@@ -1222,7 +1377,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1222 } 1377 }
1223 1378
1224 1379
1225 private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart, UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, UUID fromtaskid) 1380 private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart,
1381 UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem,
1382 UUID fromtaskid)
1226 { 1383 {
1227 int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; 1384 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; 1385 int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY;
@@ -1236,7 +1393,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1236 1393
1237 } 1394 }
1238 1395
1239 private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot, PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, byte rayendisintersection) 1396 private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot,
1397 PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid,
1398 byte rayendisintersection)
1240 { 1399 {
1241 int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; 1400 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; 1401 int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY;