aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs89
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs139
2 files changed, 174 insertions, 54 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 877fe96..a4ca0fb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -465,10 +465,76 @@ namespace OpenSim.Region.Framework.Scenes
465 || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) 465 || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
466 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) 466 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
467 { 467 {
468 m_scene.CrossPrimGroupIntoNewRegion(val, this, true); 468 IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
469 uint x = 0;
470 uint y = 0;
471 string version = String.Empty;
472 Vector3 newpos = Vector3.Zero;
473 OpenSim.Services.Interfaces.GridRegion destination = null;
474
475 bool canCross = true;
476 foreach (ScenePresence av in m_linkedAvatars)
477 {
478 // We need to cross these agents. First, let's find
479 // out if any of them can't cross for some reason.
480 // We have to deny the crossing entirely if any
481 // of them are banned. Alternatively, we could
482 // unsit banned agents....
483
484
485 // We set the avatar position as being the object
486 // position to get the region to send to
487 if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null)
488 {
489 canCross = false;
490 break;
491 }
492
493 m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName);
494 }
495
496 if (canCross)
497 {
498 // We unparent the SP quietly so that it won't
499 // be made to stand up
500 foreach (ScenePresence av in m_linkedAvatars)
501 {
502 SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID);
503 if (parentPart != null)
504 av.ParentUUID = parentPart.UUID;
505
506 av.ParentID = 0;
507 }
508
509 m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
510
511 // Normalize
512 if (val.X >= Constants.RegionSize)
513 val.X -= Constants.RegionSize;
514 if (val.Y >= Constants.RegionSize)
515 val.Y -= Constants.RegionSize;
516 if (val.X < 0)
517 val.X += Constants.RegionSize;
518 if (val.Y < 0)
519 val.Y += Constants.RegionSize;
520
521 // If it's deleted, crossing was successful
522 if (IsDeleted)
523 {
524 foreach (ScenePresence av in m_linkedAvatars)
525 {
526 m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val);
527
528 av.IsInTransit = true;
529
530 CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync;
531 d.BeginInvoke(av, val, x, y, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d);
532 }
533
534 return;
535 }
536 }
469 537
470 if (IsDeleted)
471 return;
472 val = AbsolutePosition; 538 val = AbsolutePosition;
473 } 539 }
474 } 540 }
@@ -528,6 +594,23 @@ namespace OpenSim.Region.Framework.Scenes
528 } 594 }
529 } 595 }
530 596
597 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
598 {
599 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
600 ScenePresence agent = icon.EndInvoke(iar);
601
602 //// If the cross was successful, this agent is a child agent
603 //if (agent.IsChildAgent)
604 // agent.Reset();
605 //else // Not successful
606 // agent.RestoreInCurrentScene();
607
608 // In any case
609 agent.IsInTransit = false;
610
611 m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
612 }
613
531 public override uint LocalId 614 public override uint LocalId
532 { 615 {
533 get { return m_rootPart.LocalId; } 616 get { return m_rootPart.LocalId; }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index c7c90da..e44060c 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -233,6 +233,8 @@ namespace OpenSim.Region.Framework.Scenes
233 private bool m_collisionEventFlag = false; 233 private bool m_collisionEventFlag = false;
234 private object m_collisionEventLock = new Object(); 234 private object m_collisionEventLock = new Object();
235 235
236 private Vector3 m_prevSitOffset;
237
236 protected AvatarAppearance m_appearance; 238 protected AvatarAppearance m_appearance;
237 239
238 public AvatarAppearance Appearance 240 public AvatarAppearance Appearance
@@ -647,6 +649,13 @@ namespace OpenSim.Region.Framework.Scenes
647 } 649 }
648 private uint m_parentID; 650 private uint m_parentID;
649 651
652 public UUID ParentUUID
653 {
654 get { return m_parentUUID; }
655 set { m_parentUUID = value; }
656 }
657 private UUID m_parentUUID = UUID.Zero;
658
650 public float Health 659 public float Health
651 { 660 {
652 get { return m_health; } 661 get { return m_health; }
@@ -868,7 +877,26 @@ namespace OpenSim.Region.Framework.Scenes
868 "[SCENE]: Upgrading child to root agent for {0} in {1}", 877 "[SCENE]: Upgrading child to root agent for {0} in {1}",
869 Name, m_scene.RegionInfo.RegionName); 878 Name, m_scene.RegionInfo.RegionName);
870 879
871 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); 880 if (ParentUUID != UUID.Zero)
881 {
882 m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID);
883 SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID);
884 if (part == null)
885 {
886 m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID);
887 }
888 else
889 {
890 part.ParentGroup.AddAvatar(UUID);
891 if (part.SitTargetPosition != Vector3.Zero)
892 part.SitTargetAvatar = UUID;
893 ParentPosition = part.GetWorldPosition();
894 ParentID = part.LocalId;
895 m_pos = m_prevSitOffset;
896 pos = ParentPosition;
897 }
898 ParentUUID = UUID.Zero;
899 }
872 900
873 bool wasChild = IsChildAgent; 901 bool wasChild = IsChildAgent;
874 IsChildAgent = false; 902 IsChildAgent = false;
@@ -881,62 +909,64 @@ namespace OpenSim.Region.Framework.Scenes
881 909
882 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 910 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
883 911
884 // Moved this from SendInitialData to ensure that Appearance is initialized 912 if (ParentID == 0)
885 // before the inventory is processed in MakeRootAgent. This fixes a race condition
886 // related to the handling of attachments
887 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
888 if (m_scene.TestBorderCross(pos, Cardinals.E))
889 { 913 {
890 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); 914 // Moved this from SendInitialData to ensure that Appearance is initialized
891 pos.X = crossedBorder.BorderLine.Z - 1; 915 // before the inventory is processed in MakeRootAgent. This fixes a race condition
892 } 916 // related to the handling of attachments
917 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
918 if (m_scene.TestBorderCross(pos, Cardinals.E))
919 {
920 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
921 pos.X = crossedBorder.BorderLine.Z - 1;
922 }
893 923
894 if (m_scene.TestBorderCross(pos, Cardinals.N)) 924 if (m_scene.TestBorderCross(pos, Cardinals.N))
895 { 925 {
896 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); 926 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
897 pos.Y = crossedBorder.BorderLine.Z - 1; 927 pos.Y = crossedBorder.BorderLine.Z - 1;
898 } 928 }
899 929
900 CheckAndAdjustLandingPoint(ref pos); 930 CheckAndAdjustLandingPoint(ref pos);
901 931
902 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 932 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
903 { 933 {
904 m_log.WarnFormat( 934 m_log.WarnFormat(
905 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", 935 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
906 pos, Name, UUID); 936 pos, Name, UUID);
907 937
908 if (pos.X < 0f) pos.X = 0f; 938 if (pos.X < 0f) pos.X = 0f;
909 if (pos.Y < 0f) pos.Y = 0f; 939 if (pos.Y < 0f) pos.Y = 0f;
910 if (pos.Z < 0f) pos.Z = 0f; 940 if (pos.Z < 0f) pos.Z = 0f;
911 } 941 }
912 942
913 float localAVHeight = 1.56f; 943 float localAVHeight = 1.56f;
914 if (Appearance.AvatarHeight > 0) 944 if (Appearance.AvatarHeight > 0)
915 localAVHeight = Appearance.AvatarHeight; 945 localAVHeight = Appearance.AvatarHeight;
916 946
917 float posZLimit = 0; 947 float posZLimit = 0;
918 948
919 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 949 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
920 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 950 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
921 951
922 float newPosZ = posZLimit + localAVHeight / 2; 952 float newPosZ = posZLimit + localAVHeight / 2;
923 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) 953 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
924 { 954 {
925 pos.Z = newPosZ; 955 pos.Z = newPosZ;
926 } 956 }
927 AbsolutePosition = pos; 957 AbsolutePosition = pos;
928 958
929 AddToPhysicalScene(isFlying); 959 AddToPhysicalScene(isFlying);
930 960
931 if (ForceFly) 961 if (ForceFly)
932 { 962 {
933 Flying = true; 963 Flying = true;
934 } 964 }
935 else if (FlyDisabled) 965 else if (FlyDisabled)
936 { 966 {
937 Flying = false; 967 Flying = false;
968 }
938 } 969 }
939
940 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 970 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
941 // avatar to return to the standing position in mid-air. On login it looks like this is being sent 971 // avatar to return to the standing position in mid-air. On login it looks like this is being sent
942 // elsewhere anyway 972 // elsewhere anyway
@@ -954,11 +984,13 @@ namespace OpenSim.Region.Framework.Scenes
954 { 984 {
955 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); 985 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments...");
956 // Resume scripts 986 // Resume scripts
957 foreach (SceneObjectGroup sog in m_attachments) 987 Util.FireAndForget(delegate(object x) {
958 { 988 foreach (SceneObjectGroup sog in m_attachments)
959 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 989 {
960 sog.ResumeScripts(); 990 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
961 } 991 sog.ResumeScripts();
992 }
993 });
962 } 994 }
963 } 995 }
964 996
@@ -3112,6 +3144,9 @@ namespace OpenSim.Region.Framework.Scenes
3112 cAgent.AlwaysRun = SetAlwaysRun; 3144 cAgent.AlwaysRun = SetAlwaysRun;
3113 3145
3114 cAgent.Appearance = new AvatarAppearance(Appearance); 3146 cAgent.Appearance = new AvatarAppearance(Appearance);
3147
3148 cAgent.ParentPart = ParentUUID;
3149 cAgent.SitOffset = m_pos;
3115 3150
3116 lock (scriptedcontrols) 3151 lock (scriptedcontrols)
3117 { 3152 {
@@ -3171,6 +3206,8 @@ namespace OpenSim.Region.Framework.Scenes
3171 CameraAtAxis = cAgent.AtAxis; 3206 CameraAtAxis = cAgent.AtAxis;
3172 CameraLeftAxis = cAgent.LeftAxis; 3207 CameraLeftAxis = cAgent.LeftAxis;
3173 m_CameraUpAxis = cAgent.UpAxis; 3208 m_CameraUpAxis = cAgent.UpAxis;
3209 ParentUUID = cAgent.ParentPart;
3210 m_prevSitOffset = cAgent.SitOffset;
3174 3211
3175 // When we get to the point of re-computing neighbors everytime this 3212 // When we get to the point of re-computing neighbors everytime this
3176 // changes, then start using the agent's drawdistance rather than the 3213 // changes, then start using the agent's drawdistance rather than the