diff options
author | Melanie | 2012-02-14 23:16:20 +0100 |
---|---|---|
committer | Melanie | 2012-02-14 23:16:20 +0100 |
commit | 2d3381b795611a8857077d1effb41323c2cb8658 (patch) | |
tree | a1b8a6d7832858d14bfb08eac29fcf3e643ef17c /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Prevent object loss and positioning outside the region with failed object sim (diff) | |
download | opensim-SC-2d3381b795611a8857077d1effb41323c2cb8658.zip opensim-SC-2d3381b795611a8857077d1effb41323c2cb8658.tar.gz opensim-SC-2d3381b795611a8857077d1effb41323c2cb8658.tar.bz2 opensim-SC-2d3381b795611a8857077d1effb41323c2cb8658.tar.xz |
Implement region crossing of sitting avatars. Edit mode and llSetPos work
but unscripted default sit anim is lost. Still some Gfx glitching. Physical
crossing doesn't work yet.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 139 |
1 files changed, 88 insertions, 51 deletions
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 |