diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 601 |
1 files changed, 521 insertions, 80 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 58721b0..1250a11 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -63,6 +63,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
63 | 63 | ||
64 | struct ScriptControllers | 64 | struct ScriptControllers |
65 | { | 65 | { |
66 | public UUID objectID; | ||
66 | public UUID itemID; | 67 | public UUID itemID; |
67 | public ScriptControlled ignoreControls; | 68 | public ScriptControlled ignoreControls; |
68 | public ScriptControlled eventControls; | 69 | public ScriptControlled eventControls; |
@@ -99,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
99 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 100 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
100 | /// issue #1716 | 101 | /// issue #1716 |
101 | /// </summary> | 102 | /// </summary> |
102 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 103 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
103 | 104 | ||
104 | /// <summary> | 105 | /// <summary> |
105 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 106 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -171,6 +172,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
171 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 172 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
172 | // private int m_updateCount = 0; //KF: Update Anims for a while | 173 | // private int m_updateCount = 0; //KF: Update Anims for a while |
173 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 174 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
175 | private List<uint> m_lastColliders = new List<uint>(); | ||
174 | 176 | ||
175 | private TeleportFlags m_teleportFlags; | 177 | private TeleportFlags m_teleportFlags; |
176 | public TeleportFlags TeleportFlags | 178 | public TeleportFlags TeleportFlags |
@@ -230,6 +232,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
230 | //private int m_moveToPositionStateStatus; | 232 | //private int m_moveToPositionStateStatus; |
231 | //***************************************************** | 233 | //***************************************************** |
232 | 234 | ||
235 | private bool m_collisionEventFlag = false; | ||
236 | private object m_collisionEventLock = new Object(); | ||
237 | |||
238 | private int m_movementAnimationUpdateCounter = 0; | ||
239 | |||
240 | private Vector3 m_prevSitOffset; | ||
241 | |||
233 | protected AvatarAppearance m_appearance; | 242 | protected AvatarAppearance m_appearance; |
234 | 243 | ||
235 | public AvatarAppearance Appearance | 244 | public AvatarAppearance Appearance |
@@ -424,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
424 | get { return (IClientCore)ControllingClient; } | 433 | get { return (IClientCore)ControllingClient; } |
425 | } | 434 | } |
426 | 435 | ||
427 | public Vector3 ParentPosition { get; set; } | 436 | // public Vector3 ParentPosition { get; set; } |
428 | 437 | ||
429 | /// <summary> | 438 | /// <summary> |
430 | /// Position of this avatar relative to the region the avatar is in | 439 | /// Position of this avatar relative to the region the avatar is in |
@@ -482,7 +491,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
482 | if (ParentID == 0) | 491 | if (ParentID == 0) |
483 | { | 492 | { |
484 | m_pos = value; | 493 | m_pos = value; |
485 | ParentPosition = Vector3.Zero; | 494 | // ParentPosition = Vector3.Zero; |
486 | } | 495 | } |
487 | 496 | ||
488 | //m_log.DebugFormat( | 497 | //m_log.DebugFormat( |
@@ -571,6 +580,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
571 | /// </summary> | 580 | /// </summary> |
572 | public uint ParentID { get; set; } | 581 | public uint ParentID { get; set; } |
573 | 582 | ||
583 | public UUID ParentUUID | ||
584 | { | ||
585 | get { return m_parentUUID; } | ||
586 | set { m_parentUUID = value; } | ||
587 | } | ||
588 | private UUID m_parentUUID = UUID.Zero; | ||
589 | |||
574 | /// <summary> | 590 | /// <summary> |
575 | /// Are we sitting on an object? | 591 | /// Are we sitting on an object? |
576 | /// </summary> | 592 | /// </summary> |
@@ -737,6 +753,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
737 | Appearance = appearance; | 753 | Appearance = appearance; |
738 | } | 754 | } |
739 | 755 | ||
756 | private void RegionHeartbeatEnd(Scene scene) | ||
757 | { | ||
758 | if (IsChildAgent) | ||
759 | return; | ||
760 | |||
761 | m_movementAnimationUpdateCounter ++; | ||
762 | if (m_movementAnimationUpdateCounter >= 2) | ||
763 | { | ||
764 | m_movementAnimationUpdateCounter = 0; | ||
765 | if (Animator != null) | ||
766 | { | ||
767 | // If the parentID == 0 we are not sitting | ||
768 | // if !SitGournd then we are not sitting on the ground | ||
769 | // Fairly straightforward, now here comes the twist | ||
770 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
771 | // be sat on an object that isn't there yet. Should | ||
772 | // be treated as if sat. | ||
773 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
774 | Animator.UpdateMovementAnimations(); | ||
775 | } | ||
776 | else | ||
777 | { | ||
778 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
779 | } | ||
780 | } | ||
781 | } | ||
782 | |||
740 | public void RegisterToEvents() | 783 | public void RegisterToEvents() |
741 | { | 784 | { |
742 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 785 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -746,8 +789,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
746 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 789 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
747 | ControllingClient.OnStartAnim += HandleStartAnim; | 790 | ControllingClient.OnStartAnim += HandleStartAnim; |
748 | ControllingClient.OnStopAnim += HandleStopAnim; | 791 | ControllingClient.OnStopAnim += HandleStopAnim; |
792 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
749 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 793 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
750 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 794 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
795 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
751 | 796 | ||
752 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 797 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
753 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 798 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -806,10 +851,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
806 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 851 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
807 | Name, m_scene.RegionInfo.RegionName); | 852 | Name, m_scene.RegionInfo.RegionName); |
808 | 853 | ||
809 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
810 | |||
811 | bool wasChild = IsChildAgent; | 854 | bool wasChild = IsChildAgent; |
812 | IsChildAgent = false; | 855 | |
856 | if (ParentUUID != UUID.Zero) | ||
857 | { | ||
858 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
859 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
860 | if (part == null) | ||
861 | { | ||
862 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
863 | } | ||
864 | else | ||
865 | { | ||
866 | part.ParentGroup.AddAvatar(UUID); | ||
867 | if (part.SitTargetPosition != Vector3.Zero) | ||
868 | part.SitTargetAvatar = UUID; | ||
869 | // ParentPosition = part.GetWorldPosition(); | ||
870 | ParentID = part.LocalId; | ||
871 | ParentPart = part; | ||
872 | m_pos = m_prevSitOffset; | ||
873 | // pos = ParentPosition; | ||
874 | pos = part.GetWorldPosition(); | ||
875 | } | ||
876 | ParentUUID = UUID.Zero; | ||
877 | |||
878 | IsChildAgent = false; | ||
879 | |||
880 | // Animator.TrySetMovementAnimation("SIT"); | ||
881 | } | ||
882 | else | ||
883 | { | ||
884 | IsChildAgent = false; | ||
885 | } | ||
886 | |||
813 | 887 | ||
814 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 888 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
815 | if (gm != null) | 889 | if (gm != null) |
@@ -819,62 +893,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
819 | 893 | ||
820 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 894 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
821 | 895 | ||
822 | // Moved this from SendInitialData to ensure that Appearance is initialized | 896 | if (ParentID == 0) |
823 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | ||
824 | // related to the handling of attachments | ||
825 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
826 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
827 | { | 897 | { |
828 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 898 | // Moved this from SendInitialData to ensure that Appearance is initialized |
829 | pos.X = crossedBorder.BorderLine.Z - 1; | 899 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
830 | } | 900 | // related to the handling of attachments |
901 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
902 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
903 | { | ||
904 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
905 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
906 | } | ||
831 | 907 | ||
832 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 908 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
833 | { | 909 | { |
834 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 910 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
835 | pos.Y = crossedBorder.BorderLine.Z - 1; | 911 | pos.Y = crossedBorder.BorderLine.Z - 1; |
836 | } | 912 | } |
837 | 913 | ||
838 | CheckAndAdjustLandingPoint(ref pos); | 914 | CheckAndAdjustLandingPoint(ref pos); |
839 | 915 | ||
840 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 916 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
841 | { | 917 | { |
842 | m_log.WarnFormat( | 918 | m_log.WarnFormat( |
843 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 919 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
844 | pos, Name, UUID); | 920 | pos, Name, UUID); |
845 | 921 | ||
846 | if (pos.X < 0f) pos.X = 0f; | 922 | if (pos.X < 0f) pos.X = 0f; |
847 | if (pos.Y < 0f) pos.Y = 0f; | 923 | if (pos.Y < 0f) pos.Y = 0f; |
848 | if (pos.Z < 0f) pos.Z = 0f; | 924 | if (pos.Z < 0f) pos.Z = 0f; |
849 | } | 925 | } |
850 | 926 | ||
851 | float localAVHeight = 1.56f; | 927 | float localAVHeight = 1.56f; |
852 | if (Appearance.AvatarHeight > 0) | 928 | if (Appearance.AvatarHeight > 0) |
853 | localAVHeight = Appearance.AvatarHeight; | 929 | localAVHeight = Appearance.AvatarHeight; |
854 | 930 | ||
855 | float posZLimit = 0; | 931 | float posZLimit = 0; |
856 | 932 | ||
857 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 933 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
858 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 934 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
859 | 935 | ||
860 | float newPosZ = posZLimit + localAVHeight / 2; | 936 | float newPosZ = posZLimit + localAVHeight / 2; |
861 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 937 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
862 | { | 938 | { |
863 | pos.Z = newPosZ; | 939 | pos.Z = newPosZ; |
864 | } | 940 | } |
865 | AbsolutePosition = pos; | 941 | AbsolutePosition = pos; |
866 | 942 | ||
867 | AddToPhysicalScene(isFlying); | 943 | if (m_teleportFlags == TeleportFlags.Default) |
944 | { | ||
945 | Vector3 vel = Velocity; | ||
946 | AddToPhysicalScene(isFlying); | ||
947 | if (PhysicsActor != null) | ||
948 | PhysicsActor.SetMomentum(vel); | ||
949 | } | ||
950 | else | ||
951 | AddToPhysicalScene(isFlying); | ||
868 | 952 | ||
869 | if (ForceFly) | 953 | if (ForceFly) |
870 | { | 954 | { |
871 | Flying = true; | 955 | Flying = true; |
872 | } | 956 | } |
873 | else if (FlyDisabled) | 957 | else if (FlyDisabled) |
874 | { | 958 | { |
875 | Flying = false; | 959 | Flying = false; |
960 | } | ||
876 | } | 961 | } |
877 | |||
878 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 962 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
879 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 963 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
880 | // elsewhere anyway | 964 | // elsewhere anyway |
@@ -894,14 +978,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
894 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | 978 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
895 | 979 | ||
896 | // Resume scripts | 980 | // Resume scripts |
897 | foreach (SceneObjectGroup sog in m_attachments) | 981 | Util.FireAndForget(delegate(object x) { |
898 | { | 982 | foreach (SceneObjectGroup sog in m_attachments) |
899 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 983 | { |
900 | sog.ResumeScripts(); | 984 | sog.ScheduleGroupForFullUpdate(); |
901 | } | 985 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
986 | sog.ResumeScripts(); | ||
987 | } | ||
988 | }); | ||
902 | } | 989 | } |
903 | } | 990 | } |
904 | 991 | ||
992 | SendAvatarDataToAllAgents(); | ||
993 | |||
905 | // send the animations of the other presences to me | 994 | // send the animations of the other presences to me |
906 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 995 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
907 | { | 996 | { |
@@ -912,9 +1001,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
912 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1001 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
913 | // stall on the border crossing since the existing child agent will still have the last movement | 1002 | // stall on the border crossing since the existing child agent will still have the last movement |
914 | // recorded, which stops the input from being processed. | 1003 | // recorded, which stops the input from being processed. |
1004 | |||
915 | MovementFlag = 0; | 1005 | MovementFlag = 0; |
916 | 1006 | ||
917 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1007 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1008 | |||
1009 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
918 | } | 1010 | } |
919 | 1011 | ||
920 | public int GetStateSource() | 1012 | public int GetStateSource() |
@@ -942,12 +1034,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
942 | /// </remarks> | 1034 | /// </remarks> |
943 | public void MakeChildAgent() | 1035 | public void MakeChildAgent() |
944 | { | 1036 | { |
1037 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1038 | |||
945 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1039 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
946 | 1040 | ||
947 | // Reset these so that teleporting in and walking out isn't seen | 1041 | // Reset these so that teleporting in and walking out isn't seen |
948 | // as teleporting back | 1042 | // as teleporting back |
949 | TeleportFlags = TeleportFlags.Default; | 1043 | TeleportFlags = TeleportFlags.Default; |
950 | 1044 | ||
1045 | MovementFlag = 0; | ||
1046 | |||
951 | // It looks like Animator is set to null somewhere, and MakeChild | 1047 | // It looks like Animator is set to null somewhere, and MakeChild |
952 | // is called after that. Probably in aborted teleports. | 1048 | // is called after that. Probably in aborted teleports. |
953 | if (Animator == null) | 1049 | if (Animator == null) |
@@ -955,6 +1051,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
955 | else | 1051 | else |
956 | Animator.ResetAnimations(); | 1052 | Animator.ResetAnimations(); |
957 | 1053 | ||
1054 | |||
958 | // m_log.DebugFormat( | 1055 | // m_log.DebugFormat( |
959 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1056 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
960 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1057 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -966,6 +1063,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
966 | IsChildAgent = true; | 1063 | IsChildAgent = true; |
967 | m_scene.SwapRootAgentCount(true); | 1064 | m_scene.SwapRootAgentCount(true); |
968 | RemoveFromPhysicalScene(); | 1065 | RemoveFromPhysicalScene(); |
1066 | ParentID = 0; // Child agents can't be sitting | ||
969 | 1067 | ||
970 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1068 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
971 | 1069 | ||
@@ -981,9 +1079,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
981 | { | 1079 | { |
982 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1080 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
983 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1081 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
984 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
985 | PhysicsActor.UnSubscribeEvents(); | ||
986 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1082 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1083 | PhysicsActor.UnSubscribeEvents(); | ||
1084 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
987 | PhysicsActor = null; | 1085 | PhysicsActor = null; |
988 | } | 1086 | } |
989 | // else | 1087 | // else |
@@ -1000,7 +1098,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1000 | /// <param name="pos"></param> | 1098 | /// <param name="pos"></param> |
1001 | public void Teleport(Vector3 pos) | 1099 | public void Teleport(Vector3 pos) |
1002 | { | 1100 | { |
1003 | TeleportWithMomentum(pos, null); | 1101 | TeleportWithMomentum(pos, Vector3.Zero); |
1004 | } | 1102 | } |
1005 | 1103 | ||
1006 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1104 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1024,6 +1122,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1024 | SendTerseUpdateToAllClients(); | 1122 | SendTerseUpdateToAllClients(); |
1025 | } | 1123 | } |
1026 | 1124 | ||
1125 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1126 | { | ||
1127 | CheckLandingPoint(ref newpos); | ||
1128 | AbsolutePosition = newpos; | ||
1129 | |||
1130 | if (newvel.HasValue) | ||
1131 | { | ||
1132 | if ((Vector3)newvel == Vector3.Zero) | ||
1133 | { | ||
1134 | if (PhysicsActor != null) | ||
1135 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1136 | m_velocity = Vector3.Zero; | ||
1137 | } | ||
1138 | else | ||
1139 | { | ||
1140 | if (PhysicsActor != null) | ||
1141 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1142 | m_velocity = (Vector3)newvel; | ||
1143 | |||
1144 | if (rotateToVelXY) | ||
1145 | { | ||
1146 | Vector3 lookAt = (Vector3)newvel; | ||
1147 | lookAt.Z = 0; | ||
1148 | lookAt.Normalize(); | ||
1149 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1150 | return; | ||
1151 | } | ||
1152 | } | ||
1153 | } | ||
1154 | |||
1155 | SendTerseUpdateToAllClients(); | ||
1156 | } | ||
1157 | |||
1158 | |||
1159 | |||
1027 | public void StopFlying() | 1160 | public void StopFlying() |
1028 | { | 1161 | { |
1029 | ControllingClient.StopFlying(this); | 1162 | ControllingClient.StopFlying(this); |
@@ -1133,7 +1266,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1133 | 1266 | ||
1134 | Vector3 look = Velocity; | 1267 | Vector3 look = Velocity; |
1135 | 1268 | ||
1136 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1269 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1270 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1137 | { | 1271 | { |
1138 | look = new Vector3(0.99f, 0.042f, 0); | 1272 | look = new Vector3(0.99f, 0.042f, 0); |
1139 | } | 1273 | } |
@@ -1183,13 +1317,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | // Create child agents in neighbouring regions | 1317 | // Create child agents in neighbouring regions |
1184 | if (openChildAgents && !IsChildAgent) | 1318 | if (openChildAgents && !IsChildAgent) |
1185 | { | 1319 | { |
1320 | |||
1186 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1321 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1187 | if (m_agentTransfer != null) | 1322 | if (m_agentTransfer != null) |
1188 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1323 | m_agentTransfer.EnableChildAgents(this); |
1189 | 1324 | ||
1190 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1325 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1191 | if (friendsModule != null) | 1326 | if (friendsModule != null) |
1192 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1327 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1328 | |||
1193 | } | 1329 | } |
1194 | 1330 | ||
1195 | // m_log.DebugFormat( | 1331 | // m_log.DebugFormat( |
@@ -1339,8 +1475,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1339 | { | 1475 | { |
1340 | if (m_followCamAuto) | 1476 | if (m_followCamAuto) |
1341 | { | 1477 | { |
1342 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1478 | // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1343 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1479 | // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); |
1480 | |||
1481 | Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; | ||
1482 | Vector3 distTocam = CameraPosition - posAdjusted; | ||
1483 | float distTocamlen = distTocam.Length(); | ||
1484 | if (distTocamlen > 0) | ||
1485 | { | ||
1486 | distTocam *= 1.0f / distTocamlen; | ||
1487 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); | ||
1488 | } | ||
1489 | |||
1344 | } | 1490 | } |
1345 | } | 1491 | } |
1346 | 1492 | ||
@@ -1796,12 +1942,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1796 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1942 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1797 | 1943 | ||
1798 | SitGround = false; | 1944 | SitGround = false; |
1945 | |||
1946 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1799 | if (PhysicsActor == null) | 1947 | if (PhysicsActor == null) |
1800 | AddToPhysicalScene(false); | 1948 | AddToPhysicalScene(false); |
1949 | */ | ||
1801 | 1950 | ||
1802 | if (ParentID != 0) | 1951 | if (ParentID != 0) |
1803 | { | 1952 | { |
1804 | SceneObjectPart part = ParentPart; | 1953 | SceneObjectPart part = ParentPart; |
1954 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
1955 | |||
1805 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1956 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1806 | if (taskIDict != null) | 1957 | if (taskIDict != null) |
1807 | { | 1958 | { |
@@ -1817,14 +1968,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1817 | } | 1968 | } |
1818 | } | 1969 | } |
1819 | 1970 | ||
1820 | ParentPosition = part.GetWorldPosition(); | 1971 | part.ParentGroup.DeleteAvatar(UUID); |
1972 | // ParentPosition = part.GetWorldPosition(); | ||
1821 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1973 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1822 | 1974 | ||
1823 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 1975 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
1824 | ParentPosition = Vector3.Zero; | 1976 | // ParentPosition = Vector3.Zero; |
1977 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
1978 | if (part.SitTargetAvatar == UUID) | ||
1979 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
1825 | 1980 | ||
1826 | ParentID = 0; | 1981 | ParentID = 0; |
1827 | ParentPart = null; | 1982 | ParentPart = null; |
1983 | |||
1984 | if (PhysicsActor == null) | ||
1985 | AddToPhysicalScene(false); | ||
1986 | |||
1828 | SendAvatarDataToAllAgents(); | 1987 | SendAvatarDataToAllAgents(); |
1829 | m_requestedSitTargetID = 0; | 1988 | m_requestedSitTargetID = 0; |
1830 | 1989 | ||
@@ -1834,6 +1993,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1834 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1993 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1835 | } | 1994 | } |
1836 | 1995 | ||
1996 | else if (PhysicsActor == null) | ||
1997 | AddToPhysicalScene(false); | ||
1998 | |||
1837 | Animator.TrySetMovementAnimation("STAND"); | 1999 | Animator.TrySetMovementAnimation("STAND"); |
1838 | } | 2000 | } |
1839 | 2001 | ||
@@ -1885,7 +2047,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1885 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 2047 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1886 | 2048 | ||
1887 | if (PhysicsActor != null) | 2049 | if (PhysicsActor != null) |
1888 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2050 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
1889 | 2051 | ||
1890 | bool canSit = false; | 2052 | bool canSit = false; |
1891 | Vector3 pos = part.AbsolutePosition + offset; | 2053 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -1934,7 +2096,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1934 | forceMouselook = part.GetForceMouselook(); | 2096 | forceMouselook = part.GetForceMouselook(); |
1935 | 2097 | ||
1936 | ControllingClient.SendSitResponse( | 2098 | ControllingClient.SendSitResponse( |
1937 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2099 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1938 | 2100 | ||
1939 | m_requestedSitTargetUUID = targetID; | 2101 | m_requestedSitTargetUUID = targetID; |
1940 | 2102 | ||
@@ -1948,6 +2110,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1948 | 2110 | ||
1949 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2111 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
1950 | { | 2112 | { |
2113 | if (IsChildAgent) | ||
2114 | return; | ||
2115 | |||
1951 | if (ParentID != 0) | 2116 | if (ParentID != 0) |
1952 | { | 2117 | { |
1953 | StandUp(); | 2118 | StandUp(); |
@@ -2198,14 +2363,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2198 | 2363 | ||
2199 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2364 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2200 | 2365 | ||
2201 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2366 | double x, y, z, m; |
2367 | |||
2368 | Quaternion r = sitTargetOrient; | ||
2369 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2370 | |||
2371 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2372 | { | ||
2373 | m = 1.0 / Math.Sqrt(m); | ||
2374 | r.X *= (float)m; | ||
2375 | r.Y *= (float)m; | ||
2376 | r.Z *= (float)m; | ||
2377 | r.W *= (float)m; | ||
2378 | } | ||
2379 | |||
2380 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2381 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2382 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2383 | |||
2384 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2385 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2386 | |||
2387 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2388 | |||
2389 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2202 | Rotation = sitTargetOrient; | 2390 | Rotation = sitTargetOrient; |
2203 | ParentPosition = part.AbsolutePosition; | 2391 | // ParentPosition = part.AbsolutePosition; |
2392 | part.ParentGroup.AddAvatar(UUID); | ||
2204 | } | 2393 | } |
2205 | else | 2394 | else |
2206 | { | 2395 | { |
2207 | m_pos -= part.AbsolutePosition; | 2396 | m_pos -= part.AbsolutePosition; |
2208 | ParentPosition = part.AbsolutePosition; | 2397 | // ParentPosition = part.AbsolutePosition; |
2398 | part.ParentGroup.AddAvatar(UUID); | ||
2209 | 2399 | ||
2210 | // m_log.DebugFormat( | 2400 | // m_log.DebugFormat( |
2211 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2401 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2255,6 +2445,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2255 | Animator.RemoveAnimation(animID); | 2445 | Animator.RemoveAnimation(animID); |
2256 | } | 2446 | } |
2257 | 2447 | ||
2448 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2449 | { | ||
2450 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2451 | } | ||
2452 | |||
2453 | |||
2454 | |||
2258 | /// <summary> | 2455 | /// <summary> |
2259 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2456 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2260 | /// </summary> | 2457 | /// </summary> |
@@ -2308,14 +2505,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2308 | direc.Z *= 2.6f; | 2505 | direc.Z *= 2.6f; |
2309 | 2506 | ||
2310 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2507 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2311 | Animator.TrySetMovementAnimation("PREJUMP"); | 2508 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2312 | Animator.TrySetMovementAnimation("JUMP"); | 2509 | // Animator.TrySetMovementAnimation("JUMP"); |
2313 | } | 2510 | } |
2314 | } | 2511 | } |
2315 | } | 2512 | } |
2316 | 2513 | ||
2317 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2514 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2318 | m_forceToApply = direc; | 2515 | m_forceToApply = direc; |
2516 | Animator.UpdateMovementAnimations(); | ||
2319 | } | 2517 | } |
2320 | 2518 | ||
2321 | #endregion | 2519 | #endregion |
@@ -2707,8 +2905,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2707 | 2905 | ||
2708 | // If we don't have a PhysActor, we can't cross anyway | 2906 | // If we don't have a PhysActor, we can't cross anyway |
2709 | // Also don't do this while sat, sitting avatars cross with the | 2907 | // Also don't do this while sat, sitting avatars cross with the |
2710 | // object they sit on. | 2908 | // object they sit on. ParentUUID denoted a pending sit, don't |
2711 | if (ParentID != 0 || PhysicsActor == null) | 2909 | // interfere with it. |
2910 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2712 | return; | 2911 | return; |
2713 | 2912 | ||
2714 | if (!IsInTransit) | 2913 | if (!IsInTransit) |
@@ -2969,6 +3168,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2969 | } | 3168 | } |
2970 | 3169 | ||
2971 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3170 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3171 | private void RaiseUpdateThrottles() | ||
3172 | { | ||
3173 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3174 | } | ||
2972 | /// <summary> | 3175 | /// <summary> |
2973 | /// This updates important decision making data about a child agent | 3176 | /// This updates important decision making data about a child agent |
2974 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3177 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3049,6 +3252,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3049 | cAgent.AlwaysRun = SetAlwaysRun; | 3252 | cAgent.AlwaysRun = SetAlwaysRun; |
3050 | 3253 | ||
3051 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3254 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3255 | |||
3256 | cAgent.ParentPart = ParentUUID; | ||
3257 | cAgent.SitOffset = m_pos; | ||
3052 | 3258 | ||
3053 | lock (scriptedcontrols) | 3259 | lock (scriptedcontrols) |
3054 | { | 3260 | { |
@@ -3057,7 +3263,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3057 | 3263 | ||
3058 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3264 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3059 | { | 3265 | { |
3060 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3266 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3061 | } | 3267 | } |
3062 | cAgent.Controllers = controls; | 3268 | cAgent.Controllers = controls; |
3063 | } | 3269 | } |
@@ -3090,6 +3296,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3090 | CameraAtAxis = cAgent.AtAxis; | 3296 | CameraAtAxis = cAgent.AtAxis; |
3091 | CameraLeftAxis = cAgent.LeftAxis; | 3297 | CameraLeftAxis = cAgent.LeftAxis; |
3092 | CameraUpAxis = cAgent.UpAxis; | 3298 | CameraUpAxis = cAgent.UpAxis; |
3299 | ParentUUID = cAgent.ParentPart; | ||
3300 | m_prevSitOffset = cAgent.SitOffset; | ||
3093 | 3301 | ||
3094 | // When we get to the point of re-computing neighbors everytime this | 3302 | // When we get to the point of re-computing neighbors everytime this |
3095 | // changes, then start using the agent's drawdistance rather than the | 3303 | // changes, then start using the agent's drawdistance rather than the |
@@ -3127,6 +3335,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3127 | foreach (ControllerData c in cAgent.Controllers) | 3335 | foreach (ControllerData c in cAgent.Controllers) |
3128 | { | 3336 | { |
3129 | ScriptControllers sc = new ScriptControllers(); | 3337 | ScriptControllers sc = new ScriptControllers(); |
3338 | sc.objectID = c.ObjectID; | ||
3130 | sc.itemID = c.ItemID; | 3339 | sc.itemID = c.ItemID; |
3131 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3340 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3132 | sc.eventControls = (ScriptControlled)c.EventControls; | 3341 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3207,7 +3416,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3207 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3416 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3208 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3417 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3209 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3418 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3210 | PhysicsActor.SubscribeEvents(500); | 3419 | PhysicsActor.SubscribeEvents(100); |
3211 | PhysicsActor.LocalID = LocalId; | 3420 | PhysicsActor.LocalID = LocalId; |
3212 | } | 3421 | } |
3213 | 3422 | ||
@@ -3234,7 +3443,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3234 | /// <param name="e"></param> | 3443 | /// <param name="e"></param> |
3235 | public void PhysicsCollisionUpdate(EventArgs e) | 3444 | public void PhysicsCollisionUpdate(EventArgs e) |
3236 | { | 3445 | { |
3237 | if (IsChildAgent) | 3446 | if (IsChildAgent || Animator == null) |
3238 | return; | 3447 | return; |
3239 | 3448 | ||
3240 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3449 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3289,6 +3498,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3289 | } | 3498 | } |
3290 | } | 3499 | } |
3291 | 3500 | ||
3501 | RaiseCollisionScriptEvents(coldata); | ||
3502 | |||
3292 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3503 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3293 | if (Invulnerable || GodLevel > 0) | 3504 | if (Invulnerable || GodLevel > 0) |
3294 | return; | 3505 | return; |
@@ -3386,6 +3597,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3386 | // m_reprioritizationTimer.Dispose(); | 3597 | // m_reprioritizationTimer.Dispose(); |
3387 | 3598 | ||
3388 | RemoveFromPhysicalScene(); | 3599 | RemoveFromPhysicalScene(); |
3600 | |||
3601 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3602 | |||
3603 | // if (Animator != null) | ||
3604 | // Animator.Close(); | ||
3605 | Animator = null; | ||
3606 | |||
3389 | } | 3607 | } |
3390 | 3608 | ||
3391 | public void AddAttachment(SceneObjectGroup gobj) | 3609 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3619,10 +3837,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3619 | 3837 | ||
3620 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 3838 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3621 | { | 3839 | { |
3840 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
3841 | if (p == null) | ||
3842 | return; | ||
3843 | |||
3844 | ControllingClient.SendTakeControls(controls, false, false); | ||
3845 | ControllingClient.SendTakeControls(controls, true, false); | ||
3846 | |||
3622 | ScriptControllers obj = new ScriptControllers(); | 3847 | ScriptControllers obj = new ScriptControllers(); |
3623 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 3848 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3624 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 3849 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3625 | 3850 | ||
3851 | obj.objectID = p.ParentGroup.UUID; | ||
3626 | obj.itemID = Script_item_UUID; | 3852 | obj.itemID = Script_item_UUID; |
3627 | if (pass_on == 0 && accept == 0) | 3853 | if (pass_on == 0 && accept == 0) |
3628 | { | 3854 | { |
@@ -3671,6 +3897,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3671 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 3897 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3672 | } | 3898 | } |
3673 | 3899 | ||
3900 | private void UnRegisterSeatControls(UUID obj) | ||
3901 | { | ||
3902 | List<UUID> takers = new List<UUID>(); | ||
3903 | |||
3904 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
3905 | { | ||
3906 | if (c.objectID == obj) | ||
3907 | takers.Add(c.itemID); | ||
3908 | } | ||
3909 | foreach (UUID t in takers) | ||
3910 | { | ||
3911 | UnRegisterControlEventsToScript(0, t); | ||
3912 | } | ||
3913 | } | ||
3914 | |||
3674 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3915 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3675 | { | 3916 | { |
3676 | ScriptControllers takecontrols; | 3917 | ScriptControllers takecontrols; |
@@ -3989,6 +4230,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3989 | 4230 | ||
3990 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4231 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3991 | { | 4232 | { |
4233 | string reason; | ||
4234 | |||
4235 | // Honor bans | ||
4236 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4237 | return; | ||
4238 | |||
3992 | SceneObjectGroup telehub = null; | 4239 | SceneObjectGroup telehub = null; |
3993 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4240 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
3994 | { | 4241 | { |
@@ -4028,11 +4275,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4028 | pos = land.LandData.UserLocation; | 4275 | pos = land.LandData.UserLocation; |
4029 | } | 4276 | } |
4030 | } | 4277 | } |
4031 | 4278 | ||
4032 | land.SendLandUpdateToClient(ControllingClient); | 4279 | land.SendLandUpdateToClient(ControllingClient); |
4033 | } | 4280 | } |
4034 | } | 4281 | } |
4035 | 4282 | ||
4283 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4284 | { | ||
4285 | DetectedObject detobj = new DetectedObject(); | ||
4286 | detobj.keyUUID = obj.UUID; | ||
4287 | detobj.nameStr = obj.Name; | ||
4288 | detobj.ownerUUID = obj.OwnerID; | ||
4289 | detobj.posVector = obj.AbsolutePosition; | ||
4290 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4291 | detobj.velVector = obj.Velocity; | ||
4292 | detobj.colliderType = 0; | ||
4293 | detobj.groupUUID = obj.GroupID; | ||
4294 | |||
4295 | return detobj; | ||
4296 | } | ||
4297 | |||
4298 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4299 | { | ||
4300 | DetectedObject detobj = new DetectedObject(); | ||
4301 | detobj.keyUUID = av.UUID; | ||
4302 | detobj.nameStr = av.ControllingClient.Name; | ||
4303 | detobj.ownerUUID = av.UUID; | ||
4304 | detobj.posVector = av.AbsolutePosition; | ||
4305 | detobj.rotQuat = av.Rotation; | ||
4306 | detobj.velVector = av.Velocity; | ||
4307 | detobj.colliderType = 0; | ||
4308 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4309 | |||
4310 | return detobj; | ||
4311 | } | ||
4312 | |||
4313 | private DetectedObject CreateDetObjectForGround() | ||
4314 | { | ||
4315 | DetectedObject detobj = new DetectedObject(); | ||
4316 | detobj.keyUUID = UUID.Zero; | ||
4317 | detobj.nameStr = ""; | ||
4318 | detobj.ownerUUID = UUID.Zero; | ||
4319 | detobj.posVector = AbsolutePosition; | ||
4320 | detobj.rotQuat = Quaternion.Identity; | ||
4321 | detobj.velVector = Vector3.Zero; | ||
4322 | detobj.colliderType = 0; | ||
4323 | detobj.groupUUID = UUID.Zero; | ||
4324 | |||
4325 | return detobj; | ||
4326 | } | ||
4327 | |||
4328 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4329 | { | ||
4330 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4331 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4332 | foreach (uint localId in colliders) | ||
4333 | { | ||
4334 | if (localId == 0) | ||
4335 | continue; | ||
4336 | |||
4337 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4338 | if (obj != null) | ||
4339 | { | ||
4340 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4341 | colliding.Add(CreateDetObject(obj)); | ||
4342 | } | ||
4343 | else | ||
4344 | { | ||
4345 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4346 | if (av != null && (!av.IsChildAgent)) | ||
4347 | { | ||
4348 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4349 | colliding.Add(CreateDetObject(av)); | ||
4350 | } | ||
4351 | } | ||
4352 | } | ||
4353 | |||
4354 | colliderArgs.Colliders = colliding; | ||
4355 | |||
4356 | return colliderArgs; | ||
4357 | } | ||
4358 | |||
4359 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4360 | |||
4361 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4362 | { | ||
4363 | ColliderArgs CollidingMessage; | ||
4364 | |||
4365 | if (colliders.Count > 0) | ||
4366 | { | ||
4367 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4368 | { | ||
4369 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4370 | |||
4371 | if (CollidingMessage.Colliders.Count > 0) | ||
4372 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4373 | } | ||
4374 | } | ||
4375 | } | ||
4376 | |||
4377 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4378 | { | ||
4379 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4380 | { | ||
4381 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4382 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4383 | |||
4384 | colliding.Add(CreateDetObjectForGround()); | ||
4385 | LandCollidingMessage.Colliders = colliding; | ||
4386 | |||
4387 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4388 | } | ||
4389 | } | ||
4390 | |||
4391 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4392 | { | ||
4393 | try | ||
4394 | { | ||
4395 | List<uint> thisHitColliders = new List<uint>(); | ||
4396 | List<uint> endedColliders = new List<uint>(); | ||
4397 | List<uint> startedColliders = new List<uint>(); | ||
4398 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4399 | CollisionForSoundInfo soundinfo; | ||
4400 | ContactPoint curcontact; | ||
4401 | |||
4402 | if (coldata.Count == 0) | ||
4403 | { | ||
4404 | if (m_lastColliders.Count == 0) | ||
4405 | return; // nothing to do | ||
4406 | |||
4407 | foreach (uint localID in m_lastColliders) | ||
4408 | { | ||
4409 | endedColliders.Add(localID); | ||
4410 | } | ||
4411 | m_lastColliders.Clear(); | ||
4412 | } | ||
4413 | |||
4414 | else | ||
4415 | { | ||
4416 | foreach (uint id in coldata.Keys) | ||
4417 | { | ||
4418 | thisHitColliders.Add(id); | ||
4419 | if (!m_lastColliders.Contains(id)) | ||
4420 | { | ||
4421 | startedColliders.Add(id); | ||
4422 | curcontact = coldata[id]; | ||
4423 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4424 | { | ||
4425 | soundinfo = new CollisionForSoundInfo(); | ||
4426 | soundinfo.colliderID = id; | ||
4427 | soundinfo.position = curcontact.Position; | ||
4428 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4429 | soundinfolist.Add(soundinfo); | ||
4430 | } | ||
4431 | } | ||
4432 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4433 | } | ||
4434 | |||
4435 | // calculate things that ended colliding | ||
4436 | foreach (uint localID in m_lastColliders) | ||
4437 | { | ||
4438 | if (!thisHitColliders.Contains(localID)) | ||
4439 | { | ||
4440 | endedColliders.Add(localID); | ||
4441 | } | ||
4442 | } | ||
4443 | //add the items that started colliding this time to the last colliders list. | ||
4444 | foreach (uint localID in startedColliders) | ||
4445 | { | ||
4446 | m_lastColliders.Add(localID); | ||
4447 | } | ||
4448 | // remove things that ended colliding from the last colliders list | ||
4449 | foreach (uint localID in endedColliders) | ||
4450 | { | ||
4451 | m_lastColliders.Remove(localID); | ||
4452 | } | ||
4453 | |||
4454 | if (soundinfolist.Count > 0) | ||
4455 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4456 | } | ||
4457 | |||
4458 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4459 | { | ||
4460 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4461 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4462 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4463 | |||
4464 | if (startedColliders.Contains(0)) | ||
4465 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4466 | if (m_lastColliders.Contains(0)) | ||
4467 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4468 | if (endedColliders.Contains(0)) | ||
4469 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4470 | } | ||
4471 | } | ||
4472 | finally | ||
4473 | { | ||
4474 | m_collisionEventFlag = false; | ||
4475 | } | ||
4476 | } | ||
4477 | |||
4036 | private void TeleportFlagsDebug() { | 4478 | private void TeleportFlagsDebug() { |
4037 | 4479 | ||
4038 | // Some temporary debugging help to show all the TeleportFlags we have... | 4480 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4057,6 +4499,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4057 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4499 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4058 | 4500 | ||
4059 | } | 4501 | } |
4060 | |||
4061 | } | 4502 | } |
4062 | } | 4503 | } |