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 6f36c0b..7f07d73 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 |
@@ -232,6 +234,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
232 | //private int m_moveToPositionStateStatus; | 234 | //private int m_moveToPositionStateStatus; |
233 | //***************************************************** | 235 | //***************************************************** |
234 | 236 | ||
237 | private bool m_collisionEventFlag = false; | ||
238 | private object m_collisionEventLock = new Object(); | ||
239 | |||
240 | private int m_movementAnimationUpdateCounter = 0; | ||
241 | |||
242 | private Vector3 m_prevSitOffset; | ||
243 | |||
235 | protected AvatarAppearance m_appearance; | 244 | protected AvatarAppearance m_appearance; |
236 | 245 | ||
237 | public AvatarAppearance Appearance | 246 | public AvatarAppearance Appearance |
@@ -426,7 +435,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
426 | get { return (IClientCore)ControllingClient; } | 435 | get { return (IClientCore)ControllingClient; } |
427 | } | 436 | } |
428 | 437 | ||
429 | public Vector3 ParentPosition { get; set; } | 438 | // public Vector3 ParentPosition { get; set; } |
430 | 439 | ||
431 | /// <summary> | 440 | /// <summary> |
432 | /// Position of this avatar relative to the region the avatar is in | 441 | /// Position of this avatar relative to the region the avatar is in |
@@ -484,7 +493,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
484 | if (ParentID == 0) | 493 | if (ParentID == 0) |
485 | { | 494 | { |
486 | m_pos = value; | 495 | m_pos = value; |
487 | ParentPosition = Vector3.Zero; | 496 | // ParentPosition = Vector3.Zero; |
488 | } | 497 | } |
489 | 498 | ||
490 | //m_log.DebugFormat( | 499 | //m_log.DebugFormat( |
@@ -573,6 +582,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
573 | /// </summary> | 582 | /// </summary> |
574 | public uint ParentID { get; set; } | 583 | public uint ParentID { get; set; } |
575 | 584 | ||
585 | public UUID ParentUUID | ||
586 | { | ||
587 | get { return m_parentUUID; } | ||
588 | set { m_parentUUID = value; } | ||
589 | } | ||
590 | private UUID m_parentUUID = UUID.Zero; | ||
591 | |||
576 | /// <summary> | 592 | /// <summary> |
577 | /// Are we sitting on an object? | 593 | /// Are we sitting on an object? |
578 | /// </summary> | 594 | /// </summary> |
@@ -739,6 +755,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
739 | Appearance = appearance; | 755 | Appearance = appearance; |
740 | } | 756 | } |
741 | 757 | ||
758 | private void RegionHeartbeatEnd(Scene scene) | ||
759 | { | ||
760 | if (IsChildAgent) | ||
761 | return; | ||
762 | |||
763 | m_movementAnimationUpdateCounter ++; | ||
764 | if (m_movementAnimationUpdateCounter >= 2) | ||
765 | { | ||
766 | m_movementAnimationUpdateCounter = 0; | ||
767 | if (Animator != null) | ||
768 | { | ||
769 | // If the parentID == 0 we are not sitting | ||
770 | // if !SitGournd then we are not sitting on the ground | ||
771 | // Fairly straightforward, now here comes the twist | ||
772 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
773 | // be sat on an object that isn't there yet. Should | ||
774 | // be treated as if sat. | ||
775 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
776 | Animator.UpdateMovementAnimations(); | ||
777 | } | ||
778 | else | ||
779 | { | ||
780 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
781 | } | ||
782 | } | ||
783 | } | ||
784 | |||
742 | public void RegisterToEvents() | 785 | public void RegisterToEvents() |
743 | { | 786 | { |
744 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 787 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -748,8 +791,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
748 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 791 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
749 | ControllingClient.OnStartAnim += HandleStartAnim; | 792 | ControllingClient.OnStartAnim += HandleStartAnim; |
750 | ControllingClient.OnStopAnim += HandleStopAnim; | 793 | ControllingClient.OnStopAnim += HandleStopAnim; |
794 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
751 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 795 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
752 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 796 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
797 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
753 | 798 | ||
754 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 799 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
755 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 800 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -808,10 +853,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
808 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 853 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
809 | Name, m_scene.RegionInfo.RegionName); | 854 | Name, m_scene.RegionInfo.RegionName); |
810 | 855 | ||
811 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
812 | |||
813 | bool wasChild = IsChildAgent; | 856 | bool wasChild = IsChildAgent; |
814 | IsChildAgent = false; | 857 | |
858 | if (ParentUUID != UUID.Zero) | ||
859 | { | ||
860 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
861 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
862 | if (part == null) | ||
863 | { | ||
864 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
865 | } | ||
866 | else | ||
867 | { | ||
868 | part.ParentGroup.AddAvatar(UUID); | ||
869 | if (part.SitTargetPosition != Vector3.Zero) | ||
870 | part.SitTargetAvatar = UUID; | ||
871 | // ParentPosition = part.GetWorldPosition(); | ||
872 | ParentID = part.LocalId; | ||
873 | ParentPart = part; | ||
874 | m_pos = m_prevSitOffset; | ||
875 | // pos = ParentPosition; | ||
876 | pos = part.GetWorldPosition(); | ||
877 | } | ||
878 | ParentUUID = UUID.Zero; | ||
879 | |||
880 | IsChildAgent = false; | ||
881 | |||
882 | // Animator.TrySetMovementAnimation("SIT"); | ||
883 | } | ||
884 | else | ||
885 | { | ||
886 | IsChildAgent = false; | ||
887 | } | ||
888 | |||
815 | 889 | ||
816 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 890 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
817 | if (gm != null) | 891 | if (gm != null) |
@@ -821,62 +895,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
821 | 895 | ||
822 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 896 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
823 | 897 | ||
824 | // Moved this from SendInitialData to ensure that Appearance is initialized | 898 | if (ParentID == 0) |
825 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | ||
826 | // related to the handling of attachments | ||
827 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
828 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
829 | { | 899 | { |
830 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 900 | // Moved this from SendInitialData to ensure that Appearance is initialized |
831 | pos.X = crossedBorder.BorderLine.Z - 1; | 901 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
832 | } | 902 | // related to the handling of attachments |
903 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
904 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
905 | { | ||
906 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
907 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
908 | } | ||
833 | 909 | ||
834 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 910 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
835 | { | 911 | { |
836 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 912 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
837 | pos.Y = crossedBorder.BorderLine.Z - 1; | 913 | pos.Y = crossedBorder.BorderLine.Z - 1; |
838 | } | 914 | } |
839 | 915 | ||
840 | CheckAndAdjustLandingPoint(ref pos); | 916 | CheckAndAdjustLandingPoint(ref pos); |
841 | 917 | ||
842 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 918 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
843 | { | 919 | { |
844 | m_log.WarnFormat( | 920 | m_log.WarnFormat( |
845 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 921 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
846 | pos, Name, UUID); | 922 | pos, Name, UUID); |
847 | 923 | ||
848 | if (pos.X < 0f) pos.X = 0f; | 924 | if (pos.X < 0f) pos.X = 0f; |
849 | if (pos.Y < 0f) pos.Y = 0f; | 925 | if (pos.Y < 0f) pos.Y = 0f; |
850 | if (pos.Z < 0f) pos.Z = 0f; | 926 | if (pos.Z < 0f) pos.Z = 0f; |
851 | } | 927 | } |
852 | 928 | ||
853 | float localAVHeight = 1.56f; | 929 | float localAVHeight = 1.56f; |
854 | if (Appearance.AvatarHeight > 0) | 930 | if (Appearance.AvatarHeight > 0) |
855 | localAVHeight = Appearance.AvatarHeight; | 931 | localAVHeight = Appearance.AvatarHeight; |
856 | 932 | ||
857 | float posZLimit = 0; | 933 | float posZLimit = 0; |
858 | 934 | ||
859 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 935 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
860 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 936 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
861 | 937 | ||
862 | float newPosZ = posZLimit + localAVHeight / 2; | 938 | float newPosZ = posZLimit + localAVHeight / 2; |
863 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 939 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
864 | { | 940 | { |
865 | pos.Z = newPosZ; | 941 | pos.Z = newPosZ; |
866 | } | 942 | } |
867 | AbsolutePosition = pos; | 943 | AbsolutePosition = pos; |
868 | 944 | ||
869 | AddToPhysicalScene(isFlying); | 945 | if (m_teleportFlags == TeleportFlags.Default) |
946 | { | ||
947 | Vector3 vel = Velocity; | ||
948 | AddToPhysicalScene(isFlying); | ||
949 | if (PhysicsActor != null) | ||
950 | PhysicsActor.SetMomentum(vel); | ||
951 | } | ||
952 | else | ||
953 | AddToPhysicalScene(isFlying); | ||
870 | 954 | ||
871 | if (ForceFly) | 955 | if (ForceFly) |
872 | { | 956 | { |
873 | Flying = true; | 957 | Flying = true; |
874 | } | 958 | } |
875 | else if (FlyDisabled) | 959 | else if (FlyDisabled) |
876 | { | 960 | { |
877 | Flying = false; | 961 | Flying = false; |
962 | } | ||
878 | } | 963 | } |
879 | |||
880 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 964 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
881 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 965 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
882 | // elsewhere anyway | 966 | // elsewhere anyway |
@@ -896,14 +980,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
896 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | 980 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
897 | 981 | ||
898 | // Resume scripts | 982 | // Resume scripts |
899 | foreach (SceneObjectGroup sog in m_attachments) | 983 | Util.FireAndForget(delegate(object x) { |
900 | { | 984 | foreach (SceneObjectGroup sog in m_attachments) |
901 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 985 | { |
902 | sog.ResumeScripts(); | 986 | sog.ScheduleGroupForFullUpdate(); |
903 | } | 987 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
988 | sog.ResumeScripts(); | ||
989 | } | ||
990 | }); | ||
904 | } | 991 | } |
905 | } | 992 | } |
906 | 993 | ||
994 | SendAvatarDataToAllAgents(); | ||
995 | |||
907 | // send the animations of the other presences to me | 996 | // send the animations of the other presences to me |
908 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 997 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
909 | { | 998 | { |
@@ -914,9 +1003,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
914 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1003 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
915 | // stall on the border crossing since the existing child agent will still have the last movement | 1004 | // stall on the border crossing since the existing child agent will still have the last movement |
916 | // recorded, which stops the input from being processed. | 1005 | // recorded, which stops the input from being processed. |
1006 | |||
917 | MovementFlag = 0; | 1007 | MovementFlag = 0; |
918 | 1008 | ||
919 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1009 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1010 | |||
1011 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
920 | } | 1012 | } |
921 | 1013 | ||
922 | public int GetStateSource() | 1014 | public int GetStateSource() |
@@ -944,12 +1036,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
944 | /// </remarks> | 1036 | /// </remarks> |
945 | public void MakeChildAgent() | 1037 | public void MakeChildAgent() |
946 | { | 1038 | { |
1039 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1040 | |||
947 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1041 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
948 | 1042 | ||
949 | // Reset these so that teleporting in and walking out isn't seen | 1043 | // Reset these so that teleporting in and walking out isn't seen |
950 | // as teleporting back | 1044 | // as teleporting back |
951 | TeleportFlags = TeleportFlags.Default; | 1045 | TeleportFlags = TeleportFlags.Default; |
952 | 1046 | ||
1047 | MovementFlag = 0; | ||
1048 | |||
953 | // It looks like Animator is set to null somewhere, and MakeChild | 1049 | // It looks like Animator is set to null somewhere, and MakeChild |
954 | // is called after that. Probably in aborted teleports. | 1050 | // is called after that. Probably in aborted teleports. |
955 | if (Animator == null) | 1051 | if (Animator == null) |
@@ -957,6 +1053,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
957 | else | 1053 | else |
958 | Animator.ResetAnimations(); | 1054 | Animator.ResetAnimations(); |
959 | 1055 | ||
1056 | |||
960 | // m_log.DebugFormat( | 1057 | // m_log.DebugFormat( |
961 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1058 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
962 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1059 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -968,6 +1065,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
968 | IsChildAgent = true; | 1065 | IsChildAgent = true; |
969 | m_scene.SwapRootAgentCount(true); | 1066 | m_scene.SwapRootAgentCount(true); |
970 | RemoveFromPhysicalScene(); | 1067 | RemoveFromPhysicalScene(); |
1068 | ParentID = 0; // Child agents can't be sitting | ||
971 | 1069 | ||
972 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1070 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
973 | 1071 | ||
@@ -983,9 +1081,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
983 | { | 1081 | { |
984 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1082 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
985 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1083 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
986 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
987 | PhysicsActor.UnSubscribeEvents(); | ||
988 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1084 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1085 | PhysicsActor.UnSubscribeEvents(); | ||
1086 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
989 | PhysicsActor = null; | 1087 | PhysicsActor = null; |
990 | } | 1088 | } |
991 | // else | 1089 | // else |
@@ -1002,7 +1100,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1002 | /// <param name="pos"></param> | 1100 | /// <param name="pos"></param> |
1003 | public void Teleport(Vector3 pos) | 1101 | public void Teleport(Vector3 pos) |
1004 | { | 1102 | { |
1005 | TeleportWithMomentum(pos, null); | 1103 | TeleportWithMomentum(pos, Vector3.Zero); |
1006 | } | 1104 | } |
1007 | 1105 | ||
1008 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1106 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1026,6 +1124,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1026 | SendTerseUpdateToAllClients(); | 1124 | SendTerseUpdateToAllClients(); |
1027 | } | 1125 | } |
1028 | 1126 | ||
1127 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1128 | { | ||
1129 | CheckLandingPoint(ref newpos); | ||
1130 | AbsolutePosition = newpos; | ||
1131 | |||
1132 | if (newvel.HasValue) | ||
1133 | { | ||
1134 | if ((Vector3)newvel == Vector3.Zero) | ||
1135 | { | ||
1136 | if (PhysicsActor != null) | ||
1137 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1138 | m_velocity = Vector3.Zero; | ||
1139 | } | ||
1140 | else | ||
1141 | { | ||
1142 | if (PhysicsActor != null) | ||
1143 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1144 | m_velocity = (Vector3)newvel; | ||
1145 | |||
1146 | if (rotateToVelXY) | ||
1147 | { | ||
1148 | Vector3 lookAt = (Vector3)newvel; | ||
1149 | lookAt.Z = 0; | ||
1150 | lookAt.Normalize(); | ||
1151 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1152 | return; | ||
1153 | } | ||
1154 | } | ||
1155 | } | ||
1156 | |||
1157 | SendTerseUpdateToAllClients(); | ||
1158 | } | ||
1159 | |||
1160 | |||
1161 | |||
1029 | public void StopFlying() | 1162 | public void StopFlying() |
1030 | { | 1163 | { |
1031 | ControllingClient.StopFlying(this); | 1164 | ControllingClient.StopFlying(this); |
@@ -1135,7 +1268,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1135 | 1268 | ||
1136 | Vector3 look = Velocity; | 1269 | Vector3 look = Velocity; |
1137 | 1270 | ||
1138 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1271 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1272 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1139 | { | 1273 | { |
1140 | look = new Vector3(0.99f, 0.042f, 0); | 1274 | look = new Vector3(0.99f, 0.042f, 0); |
1141 | } | 1275 | } |
@@ -1185,13 +1319,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1185 | // Create child agents in neighbouring regions | 1319 | // Create child agents in neighbouring regions |
1186 | if (openChildAgents && !IsChildAgent) | 1320 | if (openChildAgents && !IsChildAgent) |
1187 | { | 1321 | { |
1322 | |||
1188 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1323 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1189 | if (m_agentTransfer != null) | 1324 | if (m_agentTransfer != null) |
1190 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1325 | m_agentTransfer.EnableChildAgents(this); |
1191 | 1326 | ||
1192 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1327 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1193 | if (friendsModule != null) | 1328 | if (friendsModule != null) |
1194 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1329 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1330 | |||
1195 | } | 1331 | } |
1196 | 1332 | ||
1197 | // m_log.DebugFormat( | 1333 | // m_log.DebugFormat( |
@@ -1341,8 +1477,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1341 | { | 1477 | { |
1342 | if (m_followCamAuto) | 1478 | if (m_followCamAuto) |
1343 | { | 1479 | { |
1344 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1480 | // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1345 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1481 | // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); |
1482 | |||
1483 | Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; | ||
1484 | Vector3 distTocam = CameraPosition - posAdjusted; | ||
1485 | float distTocamlen = distTocam.Length(); | ||
1486 | if (distTocamlen > 0) | ||
1487 | { | ||
1488 | distTocam *= 1.0f / distTocamlen; | ||
1489 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); | ||
1490 | } | ||
1491 | |||
1346 | } | 1492 | } |
1347 | } | 1493 | } |
1348 | 1494 | ||
@@ -1798,12 +1944,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1798 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1944 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1799 | 1945 | ||
1800 | SitGround = false; | 1946 | SitGround = false; |
1947 | |||
1948 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1801 | if (PhysicsActor == null) | 1949 | if (PhysicsActor == null) |
1802 | AddToPhysicalScene(false); | 1950 | AddToPhysicalScene(false); |
1951 | */ | ||
1803 | 1952 | ||
1804 | if (ParentID != 0) | 1953 | if (ParentID != 0) |
1805 | { | 1954 | { |
1806 | SceneObjectPart part = ParentPart; | 1955 | SceneObjectPart part = ParentPart; |
1956 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
1957 | |||
1807 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1958 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1808 | if (taskIDict != null) | 1959 | if (taskIDict != null) |
1809 | { | 1960 | { |
@@ -1819,14 +1970,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1819 | } | 1970 | } |
1820 | } | 1971 | } |
1821 | 1972 | ||
1822 | ParentPosition = part.GetWorldPosition(); | 1973 | part.ParentGroup.DeleteAvatar(UUID); |
1974 | // ParentPosition = part.GetWorldPosition(); | ||
1823 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1975 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1824 | 1976 | ||
1825 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 1977 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
1826 | ParentPosition = Vector3.Zero; | 1978 | // ParentPosition = Vector3.Zero; |
1979 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
1980 | if (part.SitTargetAvatar == UUID) | ||
1981 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
1827 | 1982 | ||
1828 | ParentID = 0; | 1983 | ParentID = 0; |
1829 | ParentPart = null; | 1984 | ParentPart = null; |
1985 | |||
1986 | if (PhysicsActor == null) | ||
1987 | AddToPhysicalScene(false); | ||
1988 | |||
1830 | SendAvatarDataToAllAgents(); | 1989 | SendAvatarDataToAllAgents(); |
1831 | m_requestedSitTargetID = 0; | 1990 | m_requestedSitTargetID = 0; |
1832 | 1991 | ||
@@ -1836,6 +1995,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1836 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1995 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1837 | } | 1996 | } |
1838 | 1997 | ||
1998 | else if (PhysicsActor == null) | ||
1999 | AddToPhysicalScene(false); | ||
2000 | |||
1839 | Animator.TrySetMovementAnimation("STAND"); | 2001 | Animator.TrySetMovementAnimation("STAND"); |
1840 | } | 2002 | } |
1841 | 2003 | ||
@@ -1887,7 +2049,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1887 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 2049 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1888 | 2050 | ||
1889 | if (PhysicsActor != null) | 2051 | if (PhysicsActor != null) |
1890 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2052 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
1891 | 2053 | ||
1892 | bool canSit = false; | 2054 | bool canSit = false; |
1893 | Vector3 pos = part.AbsolutePosition + offset; | 2055 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -1936,7 +2098,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1936 | forceMouselook = part.GetForceMouselook(); | 2098 | forceMouselook = part.GetForceMouselook(); |
1937 | 2099 | ||
1938 | ControllingClient.SendSitResponse( | 2100 | ControllingClient.SendSitResponse( |
1939 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2101 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1940 | 2102 | ||
1941 | m_requestedSitTargetUUID = targetID; | 2103 | m_requestedSitTargetUUID = targetID; |
1942 | 2104 | ||
@@ -1950,6 +2112,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1950 | 2112 | ||
1951 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2113 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
1952 | { | 2114 | { |
2115 | if (IsChildAgent) | ||
2116 | return; | ||
2117 | |||
1953 | if (ParentID != 0) | 2118 | if (ParentID != 0) |
1954 | { | 2119 | { |
1955 | StandUp(); | 2120 | StandUp(); |
@@ -2227,14 +2392,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2227 | 2392 | ||
2228 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2393 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2229 | 2394 | ||
2230 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2395 | double x, y, z, m; |
2396 | |||
2397 | Quaternion r = sitTargetOrient; | ||
2398 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2399 | |||
2400 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2401 | { | ||
2402 | m = 1.0 / Math.Sqrt(m); | ||
2403 | r.X *= (float)m; | ||
2404 | r.Y *= (float)m; | ||
2405 | r.Z *= (float)m; | ||
2406 | r.W *= (float)m; | ||
2407 | } | ||
2408 | |||
2409 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2410 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2411 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2412 | |||
2413 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2414 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2415 | |||
2416 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2417 | |||
2418 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2231 | Rotation = sitTargetOrient; | 2419 | Rotation = sitTargetOrient; |
2232 | ParentPosition = part.AbsolutePosition; | 2420 | // ParentPosition = part.AbsolutePosition; |
2421 | part.ParentGroup.AddAvatar(UUID); | ||
2233 | } | 2422 | } |
2234 | else | 2423 | else |
2235 | { | 2424 | { |
2236 | m_pos -= part.AbsolutePosition; | 2425 | m_pos -= part.AbsolutePosition; |
2237 | ParentPosition = part.AbsolutePosition; | 2426 | // ParentPosition = part.AbsolutePosition; |
2427 | part.ParentGroup.AddAvatar(UUID); | ||
2238 | 2428 | ||
2239 | // m_log.DebugFormat( | 2429 | // m_log.DebugFormat( |
2240 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2430 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2279,6 +2469,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2279 | Animator.RemoveAnimation(animID); | 2469 | Animator.RemoveAnimation(animID); |
2280 | } | 2470 | } |
2281 | 2471 | ||
2472 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2473 | { | ||
2474 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2475 | } | ||
2476 | |||
2477 | |||
2478 | |||
2282 | /// <summary> | 2479 | /// <summary> |
2283 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2480 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2284 | /// </summary> | 2481 | /// </summary> |
@@ -2332,14 +2529,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2332 | direc.Z *= 2.6f; | 2529 | direc.Z *= 2.6f; |
2333 | 2530 | ||
2334 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2531 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2335 | Animator.TrySetMovementAnimation("PREJUMP"); | 2532 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2336 | Animator.TrySetMovementAnimation("JUMP"); | 2533 | // Animator.TrySetMovementAnimation("JUMP"); |
2337 | } | 2534 | } |
2338 | } | 2535 | } |
2339 | } | 2536 | } |
2340 | 2537 | ||
2341 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2538 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2342 | m_forceToApply = direc; | 2539 | m_forceToApply = direc; |
2540 | Animator.UpdateMovementAnimations(); | ||
2343 | } | 2541 | } |
2344 | 2542 | ||
2345 | #endregion | 2543 | #endregion |
@@ -2731,8 +2929,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2731 | 2929 | ||
2732 | // If we don't have a PhysActor, we can't cross anyway | 2930 | // If we don't have a PhysActor, we can't cross anyway |
2733 | // Also don't do this while sat, sitting avatars cross with the | 2931 | // Also don't do this while sat, sitting avatars cross with the |
2734 | // object they sit on. | 2932 | // object they sit on. ParentUUID denoted a pending sit, don't |
2735 | if (ParentID != 0 || PhysicsActor == null) | 2933 | // interfere with it. |
2934 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2736 | return; | 2935 | return; |
2737 | 2936 | ||
2738 | if (!IsInTransit) | 2937 | if (!IsInTransit) |
@@ -2993,6 +3192,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2993 | } | 3192 | } |
2994 | 3193 | ||
2995 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3194 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3195 | private void RaiseUpdateThrottles() | ||
3196 | { | ||
3197 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3198 | } | ||
2996 | /// <summary> | 3199 | /// <summary> |
2997 | /// This updates important decision making data about a child agent | 3200 | /// This updates important decision making data about a child agent |
2998 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3201 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3073,6 +3276,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3073 | cAgent.AlwaysRun = SetAlwaysRun; | 3276 | cAgent.AlwaysRun = SetAlwaysRun; |
3074 | 3277 | ||
3075 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3278 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3279 | |||
3280 | cAgent.ParentPart = ParentUUID; | ||
3281 | cAgent.SitOffset = m_pos; | ||
3076 | 3282 | ||
3077 | lock (scriptedcontrols) | 3283 | lock (scriptedcontrols) |
3078 | { | 3284 | { |
@@ -3081,7 +3287,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3081 | 3287 | ||
3082 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3288 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3083 | { | 3289 | { |
3084 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3290 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3085 | } | 3291 | } |
3086 | cAgent.Controllers = controls; | 3292 | cAgent.Controllers = controls; |
3087 | } | 3293 | } |
@@ -3114,6 +3320,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3114 | CameraAtAxis = cAgent.AtAxis; | 3320 | CameraAtAxis = cAgent.AtAxis; |
3115 | CameraLeftAxis = cAgent.LeftAxis; | 3321 | CameraLeftAxis = cAgent.LeftAxis; |
3116 | CameraUpAxis = cAgent.UpAxis; | 3322 | CameraUpAxis = cAgent.UpAxis; |
3323 | ParentUUID = cAgent.ParentPart; | ||
3324 | m_prevSitOffset = cAgent.SitOffset; | ||
3117 | 3325 | ||
3118 | // When we get to the point of re-computing neighbors everytime this | 3326 | // When we get to the point of re-computing neighbors everytime this |
3119 | // changes, then start using the agent's drawdistance rather than the | 3327 | // changes, then start using the agent's drawdistance rather than the |
@@ -3151,6 +3359,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3151 | foreach (ControllerData c in cAgent.Controllers) | 3359 | foreach (ControllerData c in cAgent.Controllers) |
3152 | { | 3360 | { |
3153 | ScriptControllers sc = new ScriptControllers(); | 3361 | ScriptControllers sc = new ScriptControllers(); |
3362 | sc.objectID = c.ObjectID; | ||
3154 | sc.itemID = c.ItemID; | 3363 | sc.itemID = c.ItemID; |
3155 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3364 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3156 | sc.eventControls = (ScriptControlled)c.EventControls; | 3365 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3231,7 +3440,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3231 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3440 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3232 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3441 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3233 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3442 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3234 | PhysicsActor.SubscribeEvents(500); | 3443 | PhysicsActor.SubscribeEvents(100); |
3235 | PhysicsActor.LocalID = LocalId; | 3444 | PhysicsActor.LocalID = LocalId; |
3236 | } | 3445 | } |
3237 | 3446 | ||
@@ -3258,7 +3467,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3258 | /// <param name="e"></param> | 3467 | /// <param name="e"></param> |
3259 | public void PhysicsCollisionUpdate(EventArgs e) | 3468 | public void PhysicsCollisionUpdate(EventArgs e) |
3260 | { | 3469 | { |
3261 | if (IsChildAgent) | 3470 | if (IsChildAgent || Animator == null) |
3262 | return; | 3471 | return; |
3263 | 3472 | ||
3264 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3473 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3313,6 +3522,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3313 | } | 3522 | } |
3314 | } | 3523 | } |
3315 | 3524 | ||
3525 | RaiseCollisionScriptEvents(coldata); | ||
3526 | |||
3316 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3527 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3317 | if (Invulnerable || GodLevel > 0) | 3528 | if (Invulnerable || GodLevel > 0) |
3318 | return; | 3529 | return; |
@@ -3410,6 +3621,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3410 | // m_reprioritizationTimer.Dispose(); | 3621 | // m_reprioritizationTimer.Dispose(); |
3411 | 3622 | ||
3412 | RemoveFromPhysicalScene(); | 3623 | RemoveFromPhysicalScene(); |
3624 | |||
3625 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3626 | |||
3627 | // if (Animator != null) | ||
3628 | // Animator.Close(); | ||
3629 | Animator = null; | ||
3630 | |||
3413 | } | 3631 | } |
3414 | 3632 | ||
3415 | public void AddAttachment(SceneObjectGroup gobj) | 3633 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3643,10 +3861,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3643 | 3861 | ||
3644 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 3862 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3645 | { | 3863 | { |
3864 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
3865 | if (p == null) | ||
3866 | return; | ||
3867 | |||
3868 | ControllingClient.SendTakeControls(controls, false, false); | ||
3869 | ControllingClient.SendTakeControls(controls, true, false); | ||
3870 | |||
3646 | ScriptControllers obj = new ScriptControllers(); | 3871 | ScriptControllers obj = new ScriptControllers(); |
3647 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 3872 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3648 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 3873 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3649 | 3874 | ||
3875 | obj.objectID = p.ParentGroup.UUID; | ||
3650 | obj.itemID = Script_item_UUID; | 3876 | obj.itemID = Script_item_UUID; |
3651 | if (pass_on == 0 && accept == 0) | 3877 | if (pass_on == 0 && accept == 0) |
3652 | { | 3878 | { |
@@ -3695,6 +3921,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3695 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 3921 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3696 | } | 3922 | } |
3697 | 3923 | ||
3924 | private void UnRegisterSeatControls(UUID obj) | ||
3925 | { | ||
3926 | List<UUID> takers = new List<UUID>(); | ||
3927 | |||
3928 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
3929 | { | ||
3930 | if (c.objectID == obj) | ||
3931 | takers.Add(c.itemID); | ||
3932 | } | ||
3933 | foreach (UUID t in takers) | ||
3934 | { | ||
3935 | UnRegisterControlEventsToScript(0, t); | ||
3936 | } | ||
3937 | } | ||
3938 | |||
3698 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3939 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3699 | { | 3940 | { |
3700 | ScriptControllers takecontrols; | 3941 | ScriptControllers takecontrols; |
@@ -4013,6 +4254,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4013 | 4254 | ||
4014 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4255 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4015 | { | 4256 | { |
4257 | string reason; | ||
4258 | |||
4259 | // Honor bans | ||
4260 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4261 | return; | ||
4262 | |||
4016 | SceneObjectGroup telehub = null; | 4263 | SceneObjectGroup telehub = null; |
4017 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4264 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4018 | { | 4265 | { |
@@ -4052,11 +4299,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4052 | pos = land.LandData.UserLocation; | 4299 | pos = land.LandData.UserLocation; |
4053 | } | 4300 | } |
4054 | } | 4301 | } |
4055 | 4302 | ||
4056 | land.SendLandUpdateToClient(ControllingClient); | 4303 | land.SendLandUpdateToClient(ControllingClient); |
4057 | } | 4304 | } |
4058 | } | 4305 | } |
4059 | 4306 | ||
4307 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4308 | { | ||
4309 | DetectedObject detobj = new DetectedObject(); | ||
4310 | detobj.keyUUID = obj.UUID; | ||
4311 | detobj.nameStr = obj.Name; | ||
4312 | detobj.ownerUUID = obj.OwnerID; | ||
4313 | detobj.posVector = obj.AbsolutePosition; | ||
4314 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4315 | detobj.velVector = obj.Velocity; | ||
4316 | detobj.colliderType = 0; | ||
4317 | detobj.groupUUID = obj.GroupID; | ||
4318 | |||
4319 | return detobj; | ||
4320 | } | ||
4321 | |||
4322 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4323 | { | ||
4324 | DetectedObject detobj = new DetectedObject(); | ||
4325 | detobj.keyUUID = av.UUID; | ||
4326 | detobj.nameStr = av.ControllingClient.Name; | ||
4327 | detobj.ownerUUID = av.UUID; | ||
4328 | detobj.posVector = av.AbsolutePosition; | ||
4329 | detobj.rotQuat = av.Rotation; | ||
4330 | detobj.velVector = av.Velocity; | ||
4331 | detobj.colliderType = 0; | ||
4332 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4333 | |||
4334 | return detobj; | ||
4335 | } | ||
4336 | |||
4337 | private DetectedObject CreateDetObjectForGround() | ||
4338 | { | ||
4339 | DetectedObject detobj = new DetectedObject(); | ||
4340 | detobj.keyUUID = UUID.Zero; | ||
4341 | detobj.nameStr = ""; | ||
4342 | detobj.ownerUUID = UUID.Zero; | ||
4343 | detobj.posVector = AbsolutePosition; | ||
4344 | detobj.rotQuat = Quaternion.Identity; | ||
4345 | detobj.velVector = Vector3.Zero; | ||
4346 | detobj.colliderType = 0; | ||
4347 | detobj.groupUUID = UUID.Zero; | ||
4348 | |||
4349 | return detobj; | ||
4350 | } | ||
4351 | |||
4352 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4353 | { | ||
4354 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4355 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4356 | foreach (uint localId in colliders) | ||
4357 | { | ||
4358 | if (localId == 0) | ||
4359 | continue; | ||
4360 | |||
4361 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4362 | if (obj != null) | ||
4363 | { | ||
4364 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4365 | colliding.Add(CreateDetObject(obj)); | ||
4366 | } | ||
4367 | else | ||
4368 | { | ||
4369 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4370 | if (av != null && (!av.IsChildAgent)) | ||
4371 | { | ||
4372 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4373 | colliding.Add(CreateDetObject(av)); | ||
4374 | } | ||
4375 | } | ||
4376 | } | ||
4377 | |||
4378 | colliderArgs.Colliders = colliding; | ||
4379 | |||
4380 | return colliderArgs; | ||
4381 | } | ||
4382 | |||
4383 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4384 | |||
4385 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4386 | { | ||
4387 | ColliderArgs CollidingMessage; | ||
4388 | |||
4389 | if (colliders.Count > 0) | ||
4390 | { | ||
4391 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4392 | { | ||
4393 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4394 | |||
4395 | if (CollidingMessage.Colliders.Count > 0) | ||
4396 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4397 | } | ||
4398 | } | ||
4399 | } | ||
4400 | |||
4401 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4402 | { | ||
4403 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4404 | { | ||
4405 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4406 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4407 | |||
4408 | colliding.Add(CreateDetObjectForGround()); | ||
4409 | LandCollidingMessage.Colliders = colliding; | ||
4410 | |||
4411 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4412 | } | ||
4413 | } | ||
4414 | |||
4415 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4416 | { | ||
4417 | try | ||
4418 | { | ||
4419 | List<uint> thisHitColliders = new List<uint>(); | ||
4420 | List<uint> endedColliders = new List<uint>(); | ||
4421 | List<uint> startedColliders = new List<uint>(); | ||
4422 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4423 | CollisionForSoundInfo soundinfo; | ||
4424 | ContactPoint curcontact; | ||
4425 | |||
4426 | if (coldata.Count == 0) | ||
4427 | { | ||
4428 | if (m_lastColliders.Count == 0) | ||
4429 | return; // nothing to do | ||
4430 | |||
4431 | foreach (uint localID in m_lastColliders) | ||
4432 | { | ||
4433 | endedColliders.Add(localID); | ||
4434 | } | ||
4435 | m_lastColliders.Clear(); | ||
4436 | } | ||
4437 | |||
4438 | else | ||
4439 | { | ||
4440 | foreach (uint id in coldata.Keys) | ||
4441 | { | ||
4442 | thisHitColliders.Add(id); | ||
4443 | if (!m_lastColliders.Contains(id)) | ||
4444 | { | ||
4445 | startedColliders.Add(id); | ||
4446 | curcontact = coldata[id]; | ||
4447 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4448 | { | ||
4449 | soundinfo = new CollisionForSoundInfo(); | ||
4450 | soundinfo.colliderID = id; | ||
4451 | soundinfo.position = curcontact.Position; | ||
4452 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4453 | soundinfolist.Add(soundinfo); | ||
4454 | } | ||
4455 | } | ||
4456 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4457 | } | ||
4458 | |||
4459 | // calculate things that ended colliding | ||
4460 | foreach (uint localID in m_lastColliders) | ||
4461 | { | ||
4462 | if (!thisHitColliders.Contains(localID)) | ||
4463 | { | ||
4464 | endedColliders.Add(localID); | ||
4465 | } | ||
4466 | } | ||
4467 | //add the items that started colliding this time to the last colliders list. | ||
4468 | foreach (uint localID in startedColliders) | ||
4469 | { | ||
4470 | m_lastColliders.Add(localID); | ||
4471 | } | ||
4472 | // remove things that ended colliding from the last colliders list | ||
4473 | foreach (uint localID in endedColliders) | ||
4474 | { | ||
4475 | m_lastColliders.Remove(localID); | ||
4476 | } | ||
4477 | |||
4478 | if (soundinfolist.Count > 0) | ||
4479 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4480 | } | ||
4481 | |||
4482 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4483 | { | ||
4484 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4485 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4486 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4487 | |||
4488 | if (startedColliders.Contains(0)) | ||
4489 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4490 | if (m_lastColliders.Contains(0)) | ||
4491 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4492 | if (endedColliders.Contains(0)) | ||
4493 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4494 | } | ||
4495 | } | ||
4496 | finally | ||
4497 | { | ||
4498 | m_collisionEventFlag = false; | ||
4499 | } | ||
4500 | } | ||
4501 | |||
4060 | private void TeleportFlagsDebug() { | 4502 | private void TeleportFlagsDebug() { |
4061 | 4503 | ||
4062 | // Some temporary debugging help to show all the TeleportFlags we have... | 4504 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4081,6 +4523,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4081 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4523 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4082 | 4524 | ||
4083 | } | 4525 | } |
4084 | |||
4085 | } | 4526 | } |
4086 | } | 4527 | } |