diff options
author | Teravus Ovares (Dan Olivares) | 2009-09-05 02:58:35 -0400 |
---|---|---|
committer | Teravus Ovares (Dan Olivares) | 2009-09-05 02:58:35 -0400 |
commit | 855fb58c9650086122b76c586c4a4a408343143f (patch) | |
tree | b0a6f98c26c59c8f228e1c3e3e208b30024fda06 /OpenSim/Region | |
parent | Merge branch 'master' of ssh://MyConnection/var/git/opensim (diff) | |
download | opensim-SC-855fb58c9650086122b76c586c4a4a408343143f.zip opensim-SC-855fb58c9650086122b76c586c4a4a408343143f.tar.gz opensim-SC-855fb58c9650086122b76c586c4a4a408343143f.tar.bz2 opensim-SC-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')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs | 171 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 23 |
2 files changed, 188 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; |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 857dc11..1024857 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -62,6 +62,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
62 | public ScriptControlled eventControls; | 62 | public ScriptControlled eventControls; |
63 | } | 63 | } |
64 | 64 | ||
65 | public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence); | ||
66 | |||
65 | public class ScenePresence : EntityBase | 67 | public class ScenePresence : EntityBase |
66 | { | 68 | { |
67 | // ~ScenePresence() | 69 | // ~ScenePresence() |
@@ -87,12 +89,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
87 | public Vector3 lastKnownAllowedPosition; | 89 | public Vector3 lastKnownAllowedPosition; |
88 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 90 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
89 | 91 | ||
92 | |||
93 | |||
90 | private bool m_updateflag; | 94 | private bool m_updateflag; |
91 | private byte m_movementflag; | 95 | private byte m_movementflag; |
92 | private readonly List<NewForce> m_forcesList = new List<NewForce>(); | 96 | private readonly List<NewForce> m_forcesList = new List<NewForce>(); |
93 | private short m_updateCount; | 97 | private short m_updateCount; |
94 | private uint m_requestedSitTargetID; | 98 | private uint m_requestedSitTargetID; |
95 | private UUID m_requestedSitTargetUUID = UUID.Zero; | 99 | private UUID m_requestedSitTargetUUID = UUID.Zero; |
100 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; | ||
96 | 101 | ||
97 | private bool m_startAnimationSet; | 102 | private bool m_startAnimationSet; |
98 | 103 | ||
@@ -616,6 +621,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
616 | 621 | ||
617 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) | 622 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) |
618 | { | 623 | { |
624 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | ||
619 | CreateSceneViewer(); | 625 | CreateSceneViewer(); |
620 | m_regionHandle = reginfo.RegionHandle; | 626 | m_regionHandle = reginfo.RegionHandle; |
621 | m_controllingClient = client; | 627 | m_controllingClient = client; |
@@ -2458,6 +2464,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
2458 | 2464 | ||
2459 | public void SendCoarseLocations() | 2465 | public void SendCoarseLocations() |
2460 | { | 2466 | { |
2467 | SendCourseLocationsMethod d = m_sendCourseLocationsMethod; | ||
2468 | if (d != null) | ||
2469 | { | ||
2470 | d.Invoke(m_scene.RegionInfo.originRegionID, this); | ||
2471 | } | ||
2472 | } | ||
2473 | |||
2474 | public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) | ||
2475 | { | ||
2476 | if (d != null) | ||
2477 | m_sendCourseLocationsMethod = d; | ||
2478 | } | ||
2479 | |||
2480 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p) | ||
2481 | { | ||
2461 | m_perfMonMS = Environment.TickCount; | 2482 | m_perfMonMS = Environment.TickCount; |
2462 | 2483 | ||
2463 | List<Vector3> CoarseLocations = new List<Vector3>(); | 2484 | List<Vector3> CoarseLocations = new List<Vector3>(); |
@@ -3302,6 +3323,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3302 | { | 3323 | { |
3303 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); | 3324 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); |
3304 | DefaultTexture = textu.GetBytes(); | 3325 | DefaultTexture = textu.GetBytes(); |
3326 | |||
3305 | } | 3327 | } |
3306 | 3328 | ||
3307 | public class NewForce | 3329 | public class NewForce |
@@ -3431,6 +3453,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3431 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); | 3453 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); |
3432 | DefaultTexture = textu.GetBytes(); | 3454 | DefaultTexture = textu.GetBytes(); |
3433 | } | 3455 | } |
3456 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | ||
3434 | CreateSceneViewer(); | 3457 | CreateSceneViewer(); |
3435 | } | 3458 | } |
3436 | 3459 | ||