diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 590 |
1 files changed, 513 insertions, 77 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1222ac6..0176921 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; |
@@ -98,7 +99,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
98 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 99 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
99 | /// issue #1716 | 100 | /// issue #1716 |
100 | /// </summary> | 101 | /// </summary> |
101 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 102 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
102 | 103 | ||
103 | /// <summary> | 104 | /// <summary> |
104 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 105 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -170,6 +171,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
170 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 171 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
171 | // private int m_updateCount = 0; //KF: Update Anims for a while | 172 | // private int m_updateCount = 0; //KF: Update Anims for a while |
172 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 173 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
174 | private List<uint> m_lastColliders = new List<uint>(); | ||
173 | 175 | ||
174 | private TeleportFlags m_teleportFlags; | 176 | private TeleportFlags m_teleportFlags; |
175 | public TeleportFlags TeleportFlags | 177 | public TeleportFlags TeleportFlags |
@@ -231,6 +233,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
231 | //private int m_moveToPositionStateStatus; | 233 | //private int m_moveToPositionStateStatus; |
232 | //***************************************************** | 234 | //***************************************************** |
233 | 235 | ||
236 | private bool m_collisionEventFlag = false; | ||
237 | private object m_collisionEventLock = new Object(); | ||
238 | |||
239 | private int m_movementAnimationUpdateCounter = 0; | ||
240 | |||
241 | private Vector3 m_prevSitOffset; | ||
242 | |||
234 | protected AvatarAppearance m_appearance; | 243 | protected AvatarAppearance m_appearance; |
235 | 244 | ||
236 | public AvatarAppearance Appearance | 245 | public AvatarAppearance Appearance |
@@ -425,7 +434,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
425 | get { return (IClientCore)ControllingClient; } | 434 | get { return (IClientCore)ControllingClient; } |
426 | } | 435 | } |
427 | 436 | ||
428 | public Vector3 ParentPosition { get; set; } | 437 | // public Vector3 ParentPosition { get; set; } |
429 | 438 | ||
430 | /// <summary> | 439 | /// <summary> |
431 | /// Position of this avatar relative to the region the avatar is in | 440 | /// Position of this avatar relative to the region the avatar is in |
@@ -483,7 +492,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
483 | if (ParentID == 0) | 492 | if (ParentID == 0) |
484 | { | 493 | { |
485 | m_pos = value; | 494 | m_pos = value; |
486 | ParentPosition = Vector3.Zero; | 495 | // ParentPosition = Vector3.Zero; |
487 | } | 496 | } |
488 | 497 | ||
489 | //m_log.DebugFormat( | 498 | //m_log.DebugFormat( |
@@ -572,6 +581,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
572 | /// </summary> | 581 | /// </summary> |
573 | public uint ParentID { get; set; } | 582 | public uint ParentID { get; set; } |
574 | 583 | ||
584 | public UUID ParentUUID | ||
585 | { | ||
586 | get { return m_parentUUID; } | ||
587 | set { m_parentUUID = value; } | ||
588 | } | ||
589 | private UUID m_parentUUID = UUID.Zero; | ||
590 | |||
575 | /// <summary> | 591 | /// <summary> |
576 | /// Are we sitting on an object? | 592 | /// Are we sitting on an object? |
577 | /// </summary> | 593 | /// </summary> |
@@ -738,6 +754,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
738 | Appearance = appearance; | 754 | Appearance = appearance; |
739 | } | 755 | } |
740 | 756 | ||
757 | private void RegionHeartbeatEnd(Scene scene) | ||
758 | { | ||
759 | if (IsChildAgent) | ||
760 | return; | ||
761 | |||
762 | m_movementAnimationUpdateCounter ++; | ||
763 | if (m_movementAnimationUpdateCounter >= 2) | ||
764 | { | ||
765 | m_movementAnimationUpdateCounter = 0; | ||
766 | if (Animator != null) | ||
767 | { | ||
768 | // If the parentID == 0 we are not sitting | ||
769 | // if !SitGournd then we are not sitting on the ground | ||
770 | // Fairly straightforward, now here comes the twist | ||
771 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
772 | // be sat on an object that isn't there yet. Should | ||
773 | // be treated as if sat. | ||
774 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
775 | Animator.UpdateMovementAnimations(); | ||
776 | } | ||
777 | else | ||
778 | { | ||
779 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
780 | } | ||
781 | } | ||
782 | } | ||
783 | |||
741 | public void RegisterToEvents() | 784 | public void RegisterToEvents() |
742 | { | 785 | { |
743 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 786 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -747,6 +790,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
747 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 790 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
748 | ControllingClient.OnStartAnim += HandleStartAnim; | 791 | ControllingClient.OnStartAnim += HandleStartAnim; |
749 | ControllingClient.OnStopAnim += HandleStopAnim; | 792 | ControllingClient.OnStopAnim += HandleStopAnim; |
793 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
750 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 794 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
751 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 795 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
752 | 796 | ||
@@ -807,10 +851,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
807 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 851 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
808 | Name, m_scene.RegionInfo.RegionName); | 852 | Name, m_scene.RegionInfo.RegionName); |
809 | 853 | ||
810 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
811 | |||
812 | bool wasChild = IsChildAgent; | 854 | bool wasChild = IsChildAgent; |
813 | 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 | |||
814 | 887 | ||
815 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 888 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
816 | if (gm != null) | 889 | if (gm != null) |
@@ -820,62 +893,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
820 | 893 | ||
821 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 894 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
822 | 895 | ||
823 | // Moved this from SendInitialData to ensure that Appearance is initialized | 896 | if (ParentID == 0) |
824 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | ||
825 | // related to the handling of attachments | ||
826 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
827 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
828 | { | 897 | { |
829 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 898 | // Moved this from SendInitialData to ensure that Appearance is initialized |
830 | pos.X = crossedBorder.BorderLine.Z - 1; | 899 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
831 | } | 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 | } | ||
832 | 907 | ||
833 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 908 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
834 | { | 909 | { |
835 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 910 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
836 | pos.Y = crossedBorder.BorderLine.Z - 1; | 911 | pos.Y = crossedBorder.BorderLine.Z - 1; |
837 | } | 912 | } |
838 | 913 | ||
839 | CheckAndAdjustLandingPoint(ref pos); | 914 | CheckAndAdjustLandingPoint(ref pos); |
840 | 915 | ||
841 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 916 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
842 | { | 917 | { |
843 | m_log.WarnFormat( | 918 | m_log.WarnFormat( |
844 | "[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", |
845 | pos, Name, UUID); | 920 | pos, Name, UUID); |
846 | 921 | ||
847 | if (pos.X < 0f) pos.X = 0f; | 922 | if (pos.X < 0f) pos.X = 0f; |
848 | if (pos.Y < 0f) pos.Y = 0f; | 923 | if (pos.Y < 0f) pos.Y = 0f; |
849 | if (pos.Z < 0f) pos.Z = 0f; | 924 | if (pos.Z < 0f) pos.Z = 0f; |
850 | } | 925 | } |
851 | 926 | ||
852 | float localAVHeight = 1.56f; | 927 | float localAVHeight = 1.56f; |
853 | if (Appearance.AvatarHeight > 0) | 928 | if (Appearance.AvatarHeight > 0) |
854 | localAVHeight = Appearance.AvatarHeight; | 929 | localAVHeight = Appearance.AvatarHeight; |
855 | 930 | ||
856 | float posZLimit = 0; | 931 | float posZLimit = 0; |
857 | 932 | ||
858 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 933 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
859 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 934 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
860 | 935 | ||
861 | float newPosZ = posZLimit + localAVHeight / 2; | 936 | float newPosZ = posZLimit + localAVHeight / 2; |
862 | 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))) |
863 | { | 938 | { |
864 | pos.Z = newPosZ; | 939 | pos.Z = newPosZ; |
865 | } | 940 | } |
866 | AbsolutePosition = pos; | 941 | AbsolutePosition = pos; |
867 | 942 | ||
868 | 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); | ||
869 | 952 | ||
870 | if (ForceFly) | 953 | if (ForceFly) |
871 | { | 954 | { |
872 | Flying = true; | 955 | Flying = true; |
873 | } | 956 | } |
874 | else if (FlyDisabled) | 957 | else if (FlyDisabled) |
875 | { | 958 | { |
876 | Flying = false; | 959 | Flying = false; |
960 | } | ||
877 | } | 961 | } |
878 | |||
879 | // 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 |
880 | // 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 |
881 | // elsewhere anyway | 964 | // elsewhere anyway |
@@ -895,14 +978,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
895 | "[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); |
896 | 979 | ||
897 | // Resume scripts | 980 | // Resume scripts |
898 | foreach (SceneObjectGroup sog in m_attachments) | 981 | Util.FireAndForget(delegate(object x) { |
899 | { | 982 | foreach (SceneObjectGroup sog in m_attachments) |
900 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 983 | { |
901 | sog.ResumeScripts(); | 984 | sog.ScheduleGroupForFullUpdate(); |
902 | } | 985 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
986 | sog.ResumeScripts(); | ||
987 | } | ||
988 | }); | ||
903 | } | 989 | } |
904 | } | 990 | } |
905 | 991 | ||
992 | SendAvatarDataToAllAgents(); | ||
993 | |||
906 | // send the animations of the other presences to me | 994 | // send the animations of the other presences to me |
907 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 995 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
908 | { | 996 | { |
@@ -913,9 +1001,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
913 | // 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 |
914 | // 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 |
915 | // recorded, which stops the input from being processed. | 1003 | // recorded, which stops the input from being processed. |
1004 | |||
916 | MovementFlag = 0; | 1005 | MovementFlag = 0; |
917 | 1006 | ||
918 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1007 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1008 | |||
1009 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
919 | } | 1010 | } |
920 | 1011 | ||
921 | public int GetStateSource() | 1012 | public int GetStateSource() |
@@ -943,12 +1034,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
943 | /// </remarks> | 1034 | /// </remarks> |
944 | public void MakeChildAgent() | 1035 | public void MakeChildAgent() |
945 | { | 1036 | { |
1037 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1038 | |||
946 | 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); |
947 | 1040 | ||
948 | // 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 |
949 | // as teleporting back | 1042 | // as teleporting back |
950 | TeleportFlags = TeleportFlags.Default; | 1043 | TeleportFlags = TeleportFlags.Default; |
951 | 1044 | ||
1045 | MovementFlag = 0; | ||
1046 | |||
952 | // It looks like Animator is set to null somewhere, and MakeChild | 1047 | // It looks like Animator is set to null somewhere, and MakeChild |
953 | // is called after that. Probably in aborted teleports. | 1048 | // is called after that. Probably in aborted teleports. |
954 | if (Animator == null) | 1049 | if (Animator == null) |
@@ -956,6 +1051,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
956 | else | 1051 | else |
957 | Animator.ResetAnimations(); | 1052 | Animator.ResetAnimations(); |
958 | 1053 | ||
1054 | |||
959 | // m_log.DebugFormat( | 1055 | // m_log.DebugFormat( |
960 | // "[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}", |
961 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1057 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -967,6 +1063,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
967 | IsChildAgent = true; | 1063 | IsChildAgent = true; |
968 | m_scene.SwapRootAgentCount(true); | 1064 | m_scene.SwapRootAgentCount(true); |
969 | RemoveFromPhysicalScene(); | 1065 | RemoveFromPhysicalScene(); |
1066 | ParentID = 0; // Child agents can't be sitting | ||
970 | 1067 | ||
971 | // 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 |
972 | 1069 | ||
@@ -982,9 +1079,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
982 | { | 1079 | { |
983 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1080 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
984 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1081 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
985 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
986 | PhysicsActor.UnSubscribeEvents(); | ||
987 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1082 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1083 | PhysicsActor.UnSubscribeEvents(); | ||
1084 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
988 | PhysicsActor = null; | 1085 | PhysicsActor = null; |
989 | } | 1086 | } |
990 | // else | 1087 | // else |
@@ -1001,7 +1098,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1001 | /// <param name="pos"></param> | 1098 | /// <param name="pos"></param> |
1002 | public void Teleport(Vector3 pos) | 1099 | public void Teleport(Vector3 pos) |
1003 | { | 1100 | { |
1004 | TeleportWithMomentum(pos, null); | 1101 | TeleportWithMomentum(pos, Vector3.Zero); |
1005 | } | 1102 | } |
1006 | 1103 | ||
1007 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1104 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1025,6 +1122,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1025 | SendTerseUpdateToAllClients(); | 1122 | SendTerseUpdateToAllClients(); |
1026 | } | 1123 | } |
1027 | 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 | |||
1028 | public void StopFlying() | 1160 | public void StopFlying() |
1029 | { | 1161 | { |
1030 | ControllingClient.StopFlying(this); | 1162 | ControllingClient.StopFlying(this); |
@@ -1340,8 +1472,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1340 | { | 1472 | { |
1341 | if (m_followCamAuto) | 1473 | if (m_followCamAuto) |
1342 | { | 1474 | { |
1343 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1475 | // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1344 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1476 | // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); |
1477 | |||
1478 | Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; | ||
1479 | Vector3 distTocam = CameraPosition - posAdjusted; | ||
1480 | float distTocamlen = distTocam.Length(); | ||
1481 | if (distTocamlen > 0) | ||
1482 | { | ||
1483 | distTocam *= 1.0f / distTocamlen; | ||
1484 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); | ||
1485 | } | ||
1486 | |||
1345 | } | 1487 | } |
1346 | } | 1488 | } |
1347 | 1489 | ||
@@ -1780,12 +1922,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1780 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1922 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1781 | 1923 | ||
1782 | SitGround = false; | 1924 | SitGround = false; |
1925 | |||
1926 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1783 | if (PhysicsActor == null) | 1927 | if (PhysicsActor == null) |
1784 | AddToPhysicalScene(false); | 1928 | AddToPhysicalScene(false); |
1929 | */ | ||
1785 | 1930 | ||
1786 | if (ParentID != 0) | 1931 | if (ParentID != 0) |
1787 | { | 1932 | { |
1788 | SceneObjectPart part = ParentPart; | 1933 | SceneObjectPart part = ParentPart; |
1934 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
1935 | |||
1789 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1936 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1790 | if (taskIDict != null) | 1937 | if (taskIDict != null) |
1791 | { | 1938 | { |
@@ -1801,14 +1948,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1801 | } | 1948 | } |
1802 | } | 1949 | } |
1803 | 1950 | ||
1804 | ParentPosition = part.GetWorldPosition(); | 1951 | part.ParentGroup.DeleteAvatar(UUID); |
1952 | // ParentPosition = part.GetWorldPosition(); | ||
1805 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1953 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1806 | 1954 | ||
1807 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 1955 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
1808 | ParentPosition = Vector3.Zero; | 1956 | // ParentPosition = Vector3.Zero; |
1957 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
1958 | if (part.SitTargetAvatar == UUID) | ||
1959 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
1809 | 1960 | ||
1810 | ParentID = 0; | 1961 | ParentID = 0; |
1811 | ParentPart = null; | 1962 | ParentPart = null; |
1963 | |||
1964 | if (PhysicsActor == null) | ||
1965 | AddToPhysicalScene(false); | ||
1966 | |||
1812 | SendAvatarDataToAllAgents(); | 1967 | SendAvatarDataToAllAgents(); |
1813 | m_requestedSitTargetID = 0; | 1968 | m_requestedSitTargetID = 0; |
1814 | 1969 | ||
@@ -1818,6 +1973,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1818 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1973 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1819 | } | 1974 | } |
1820 | 1975 | ||
1976 | else if (PhysicsActor == null) | ||
1977 | AddToPhysicalScene(false); | ||
1978 | |||
1821 | Animator.TrySetMovementAnimation("STAND"); | 1979 | Animator.TrySetMovementAnimation("STAND"); |
1822 | } | 1980 | } |
1823 | 1981 | ||
@@ -1869,7 +2027,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1869 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 2027 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1870 | 2028 | ||
1871 | if (PhysicsActor != null) | 2029 | if (PhysicsActor != null) |
1872 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2030 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
1873 | 2031 | ||
1874 | bool canSit = false; | 2032 | bool canSit = false; |
1875 | Vector3 pos = part.AbsolutePosition + offset; | 2033 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -1918,7 +2076,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1918 | forceMouselook = part.GetForceMouselook(); | 2076 | forceMouselook = part.GetForceMouselook(); |
1919 | 2077 | ||
1920 | ControllingClient.SendSitResponse( | 2078 | ControllingClient.SendSitResponse( |
1921 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2079 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1922 | 2080 | ||
1923 | m_requestedSitTargetUUID = targetID; | 2081 | m_requestedSitTargetUUID = targetID; |
1924 | 2082 | ||
@@ -1932,6 +2090,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1932 | 2090 | ||
1933 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2091 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
1934 | { | 2092 | { |
2093 | if (IsChildAgent) | ||
2094 | return; | ||
2095 | |||
1935 | if (ParentID != 0) | 2096 | if (ParentID != 0) |
1936 | { | 2097 | { |
1937 | StandUp(); | 2098 | StandUp(); |
@@ -2209,14 +2370,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2209 | 2370 | ||
2210 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2371 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2211 | 2372 | ||
2212 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2373 | double x, y, z, m; |
2374 | |||
2375 | Quaternion r = sitTargetOrient; | ||
2376 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2377 | |||
2378 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2379 | { | ||
2380 | m = 1.0 / Math.Sqrt(m); | ||
2381 | r.X *= (float)m; | ||
2382 | r.Y *= (float)m; | ||
2383 | r.Z *= (float)m; | ||
2384 | r.W *= (float)m; | ||
2385 | } | ||
2386 | |||
2387 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2388 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2389 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2390 | |||
2391 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2392 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2393 | |||
2394 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2395 | |||
2396 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2213 | Rotation = sitTargetOrient; | 2397 | Rotation = sitTargetOrient; |
2214 | ParentPosition = part.AbsolutePosition; | 2398 | // ParentPosition = part.AbsolutePosition; |
2399 | part.ParentGroup.AddAvatar(UUID); | ||
2215 | } | 2400 | } |
2216 | else | 2401 | else |
2217 | { | 2402 | { |
2218 | m_pos -= part.AbsolutePosition; | 2403 | m_pos -= part.AbsolutePosition; |
2219 | ParentPosition = part.AbsolutePosition; | 2404 | // ParentPosition = part.AbsolutePosition; |
2405 | part.ParentGroup.AddAvatar(UUID); | ||
2220 | 2406 | ||
2221 | // m_log.DebugFormat( | 2407 | // m_log.DebugFormat( |
2222 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2408 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2261,6 +2447,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2261 | Animator.RemoveAnimation(animID); | 2447 | Animator.RemoveAnimation(animID); |
2262 | } | 2448 | } |
2263 | 2449 | ||
2450 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2451 | { | ||
2452 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2453 | } | ||
2454 | |||
2455 | |||
2456 | |||
2264 | /// <summary> | 2457 | /// <summary> |
2265 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2458 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2266 | /// </summary> | 2459 | /// </summary> |
@@ -2314,14 +2507,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2314 | direc.Z *= 2.6f; | 2507 | direc.Z *= 2.6f; |
2315 | 2508 | ||
2316 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2509 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2317 | Animator.TrySetMovementAnimation("PREJUMP"); | 2510 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2318 | Animator.TrySetMovementAnimation("JUMP"); | 2511 | // Animator.TrySetMovementAnimation("JUMP"); |
2319 | } | 2512 | } |
2320 | } | 2513 | } |
2321 | } | 2514 | } |
2322 | 2515 | ||
2323 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2516 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2324 | m_forceToApply = direc; | 2517 | m_forceToApply = direc; |
2518 | Animator.UpdateMovementAnimations(); | ||
2325 | } | 2519 | } |
2326 | 2520 | ||
2327 | #endregion | 2521 | #endregion |
@@ -2713,8 +2907,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2713 | 2907 | ||
2714 | // If we don't have a PhysActor, we can't cross anyway | 2908 | // If we don't have a PhysActor, we can't cross anyway |
2715 | // Also don't do this while sat, sitting avatars cross with the | 2909 | // Also don't do this while sat, sitting avatars cross with the |
2716 | // object they sit on. | 2910 | // object they sit on. ParentUUID denoted a pending sit, don't |
2717 | if (ParentID != 0 || PhysicsActor == null) | 2911 | // interfere with it. |
2912 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2718 | return; | 2913 | return; |
2719 | 2914 | ||
2720 | if (!IsInTransit) | 2915 | if (!IsInTransit) |
@@ -3055,6 +3250,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3055 | cAgent.AlwaysRun = SetAlwaysRun; | 3250 | cAgent.AlwaysRun = SetAlwaysRun; |
3056 | 3251 | ||
3057 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3252 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3253 | |||
3254 | cAgent.ParentPart = ParentUUID; | ||
3255 | cAgent.SitOffset = m_pos; | ||
3058 | 3256 | ||
3059 | lock (scriptedcontrols) | 3257 | lock (scriptedcontrols) |
3060 | { | 3258 | { |
@@ -3063,7 +3261,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3063 | 3261 | ||
3064 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3262 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3065 | { | 3263 | { |
3066 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3264 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3067 | } | 3265 | } |
3068 | cAgent.Controllers = controls; | 3266 | cAgent.Controllers = controls; |
3069 | } | 3267 | } |
@@ -3074,6 +3272,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3074 | cAgent.Anims = Animator.Animations.ToArray(); | 3272 | cAgent.Anims = Animator.Animations.ToArray(); |
3075 | } | 3273 | } |
3076 | catch { } | 3274 | catch { } |
3275 | cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; | ||
3077 | 3276 | ||
3078 | if (Scene.AttachmentsModule != null) | 3277 | if (Scene.AttachmentsModule != null) |
3079 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); | 3278 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); |
@@ -3094,6 +3293,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3094 | CameraAtAxis = cAgent.AtAxis; | 3293 | CameraAtAxis = cAgent.AtAxis; |
3095 | CameraLeftAxis = cAgent.LeftAxis; | 3294 | CameraLeftAxis = cAgent.LeftAxis; |
3096 | CameraUpAxis = cAgent.UpAxis; | 3295 | CameraUpAxis = cAgent.UpAxis; |
3296 | ParentUUID = cAgent.ParentPart; | ||
3297 | m_prevSitOffset = cAgent.SitOffset; | ||
3097 | 3298 | ||
3098 | // When we get to the point of re-computing neighbors everytime this | 3299 | // When we get to the point of re-computing neighbors everytime this |
3099 | // changes, then start using the agent's drawdistance rather than the | 3300 | // changes, then start using the agent's drawdistance rather than the |
@@ -3131,6 +3332,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3131 | foreach (ControllerData c in cAgent.Controllers) | 3332 | foreach (ControllerData c in cAgent.Controllers) |
3132 | { | 3333 | { |
3133 | ScriptControllers sc = new ScriptControllers(); | 3334 | ScriptControllers sc = new ScriptControllers(); |
3335 | sc.objectID = c.ObjectID; | ||
3134 | sc.itemID = c.ItemID; | 3336 | sc.itemID = c.ItemID; |
3135 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3337 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3136 | sc.eventControls = (ScriptControlled)c.EventControls; | 3338 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3145,6 +3347,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3145 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? | 3347 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? |
3146 | if (cAgent.Anims != null) | 3348 | if (cAgent.Anims != null) |
3147 | Animator.Animations.FromArray(cAgent.Anims); | 3349 | Animator.Animations.FromArray(cAgent.Anims); |
3350 | if (cAgent.DefaultAnim != null) | ||
3351 | Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); | ||
3148 | 3352 | ||
3149 | if (Scene.AttachmentsModule != null) | 3353 | if (Scene.AttachmentsModule != null) |
3150 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); | 3354 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); |
@@ -3207,7 +3411,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3207 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3411 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3208 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3412 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3209 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3413 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3210 | PhysicsActor.SubscribeEvents(500); | 3414 | PhysicsActor.SubscribeEvents(100); |
3211 | PhysicsActor.LocalID = LocalId; | 3415 | PhysicsActor.LocalID = LocalId; |
3212 | } | 3416 | } |
3213 | 3417 | ||
@@ -3289,6 +3493,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3289 | } | 3493 | } |
3290 | } | 3494 | } |
3291 | 3495 | ||
3496 | RaiseCollisionScriptEvents(coldata); | ||
3497 | |||
3292 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3498 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3293 | if (Invulnerable || GodLevel > 0) | 3499 | if (Invulnerable || GodLevel > 0) |
3294 | return; | 3500 | return; |
@@ -3386,6 +3592,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3386 | // m_reprioritizationTimer.Dispose(); | 3592 | // m_reprioritizationTimer.Dispose(); |
3387 | 3593 | ||
3388 | RemoveFromPhysicalScene(); | 3594 | RemoveFromPhysicalScene(); |
3595 | |||
3596 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3597 | |||
3598 | // if (Animator != null) | ||
3599 | // Animator.Close(); | ||
3600 | Animator = null; | ||
3601 | |||
3389 | } | 3602 | } |
3390 | 3603 | ||
3391 | public void AddAttachment(SceneObjectGroup gobj) | 3604 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3619,10 +3832,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3619 | 3832 | ||
3620 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 3833 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3621 | { | 3834 | { |
3835 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
3836 | if (p == null) | ||
3837 | return; | ||
3838 | |||
3839 | ControllingClient.SendTakeControls(controls, false, false); | ||
3840 | ControllingClient.SendTakeControls(controls, true, false); | ||
3841 | |||
3622 | ScriptControllers obj = new ScriptControllers(); | 3842 | ScriptControllers obj = new ScriptControllers(); |
3623 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 3843 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3624 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 3844 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3625 | 3845 | ||
3846 | obj.objectID = p.ParentGroup.UUID; | ||
3626 | obj.itemID = Script_item_UUID; | 3847 | obj.itemID = Script_item_UUID; |
3627 | if (pass_on == 0 && accept == 0) | 3848 | if (pass_on == 0 && accept == 0) |
3628 | { | 3849 | { |
@@ -3671,6 +3892,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3671 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 3892 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3672 | } | 3893 | } |
3673 | 3894 | ||
3895 | private void UnRegisterSeatControls(UUID obj) | ||
3896 | { | ||
3897 | List<UUID> takers = new List<UUID>(); | ||
3898 | |||
3899 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
3900 | { | ||
3901 | if (c.objectID == obj) | ||
3902 | takers.Add(c.itemID); | ||
3903 | } | ||
3904 | foreach (UUID t in takers) | ||
3905 | { | ||
3906 | UnRegisterControlEventsToScript(0, t); | ||
3907 | } | ||
3908 | } | ||
3909 | |||
3674 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3910 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3675 | { | 3911 | { |
3676 | ScriptControllers takecontrols; | 3912 | ScriptControllers takecontrols; |
@@ -3989,6 +4225,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3989 | 4225 | ||
3990 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4226 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3991 | { | 4227 | { |
4228 | string reason; | ||
4229 | |||
4230 | // Honor bans | ||
4231 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4232 | return; | ||
4233 | |||
3992 | SceneObjectGroup telehub = null; | 4234 | SceneObjectGroup telehub = null; |
3993 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4235 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
3994 | { | 4236 | { |
@@ -4028,11 +4270,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4028 | pos = land.LandData.UserLocation; | 4270 | pos = land.LandData.UserLocation; |
4029 | } | 4271 | } |
4030 | } | 4272 | } |
4031 | 4273 | ||
4032 | land.SendLandUpdateToClient(ControllingClient); | 4274 | land.SendLandUpdateToClient(ControllingClient); |
4033 | } | 4275 | } |
4034 | } | 4276 | } |
4035 | 4277 | ||
4278 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4279 | { | ||
4280 | DetectedObject detobj = new DetectedObject(); | ||
4281 | detobj.keyUUID = obj.UUID; | ||
4282 | detobj.nameStr = obj.Name; | ||
4283 | detobj.ownerUUID = obj.OwnerID; | ||
4284 | detobj.posVector = obj.AbsolutePosition; | ||
4285 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4286 | detobj.velVector = obj.Velocity; | ||
4287 | detobj.colliderType = 0; | ||
4288 | detobj.groupUUID = obj.GroupID; | ||
4289 | |||
4290 | return detobj; | ||
4291 | } | ||
4292 | |||
4293 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4294 | { | ||
4295 | DetectedObject detobj = new DetectedObject(); | ||
4296 | detobj.keyUUID = av.UUID; | ||
4297 | detobj.nameStr = av.ControllingClient.Name; | ||
4298 | detobj.ownerUUID = av.UUID; | ||
4299 | detobj.posVector = av.AbsolutePosition; | ||
4300 | detobj.rotQuat = av.Rotation; | ||
4301 | detobj.velVector = av.Velocity; | ||
4302 | detobj.colliderType = 0; | ||
4303 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4304 | |||
4305 | return detobj; | ||
4306 | } | ||
4307 | |||
4308 | private DetectedObject CreateDetObjectForGround() | ||
4309 | { | ||
4310 | DetectedObject detobj = new DetectedObject(); | ||
4311 | detobj.keyUUID = UUID.Zero; | ||
4312 | detobj.nameStr = ""; | ||
4313 | detobj.ownerUUID = UUID.Zero; | ||
4314 | detobj.posVector = AbsolutePosition; | ||
4315 | detobj.rotQuat = Quaternion.Identity; | ||
4316 | detobj.velVector = Vector3.Zero; | ||
4317 | detobj.colliderType = 0; | ||
4318 | detobj.groupUUID = UUID.Zero; | ||
4319 | |||
4320 | return detobj; | ||
4321 | } | ||
4322 | |||
4323 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4324 | { | ||
4325 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4326 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4327 | foreach (uint localId in colliders) | ||
4328 | { | ||
4329 | if (localId == 0) | ||
4330 | continue; | ||
4331 | |||
4332 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4333 | if (obj != null) | ||
4334 | { | ||
4335 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4336 | colliding.Add(CreateDetObject(obj)); | ||
4337 | } | ||
4338 | else | ||
4339 | { | ||
4340 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4341 | if (av != null && (!av.IsChildAgent)) | ||
4342 | { | ||
4343 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4344 | colliding.Add(CreateDetObject(av)); | ||
4345 | } | ||
4346 | } | ||
4347 | } | ||
4348 | |||
4349 | colliderArgs.Colliders = colliding; | ||
4350 | |||
4351 | return colliderArgs; | ||
4352 | } | ||
4353 | |||
4354 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4355 | |||
4356 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4357 | { | ||
4358 | ColliderArgs CollidingMessage; | ||
4359 | |||
4360 | if (colliders.Count > 0) | ||
4361 | { | ||
4362 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4363 | { | ||
4364 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4365 | |||
4366 | if (CollidingMessage.Colliders.Count > 0) | ||
4367 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4368 | } | ||
4369 | } | ||
4370 | } | ||
4371 | |||
4372 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4373 | { | ||
4374 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4375 | { | ||
4376 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4377 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4378 | |||
4379 | colliding.Add(CreateDetObjectForGround()); | ||
4380 | LandCollidingMessage.Colliders = colliding; | ||
4381 | |||
4382 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4383 | } | ||
4384 | } | ||
4385 | |||
4386 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4387 | { | ||
4388 | try | ||
4389 | { | ||
4390 | List<uint> thisHitColliders = new List<uint>(); | ||
4391 | List<uint> endedColliders = new List<uint>(); | ||
4392 | List<uint> startedColliders = new List<uint>(); | ||
4393 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4394 | CollisionForSoundInfo soundinfo; | ||
4395 | ContactPoint curcontact; | ||
4396 | |||
4397 | if (coldata.Count == 0) | ||
4398 | { | ||
4399 | if (m_lastColliders.Count == 0) | ||
4400 | return; // nothing to do | ||
4401 | |||
4402 | foreach (uint localID in m_lastColliders) | ||
4403 | { | ||
4404 | endedColliders.Add(localID); | ||
4405 | } | ||
4406 | m_lastColliders.Clear(); | ||
4407 | } | ||
4408 | |||
4409 | else | ||
4410 | { | ||
4411 | foreach (uint id in coldata.Keys) | ||
4412 | { | ||
4413 | thisHitColliders.Add(id); | ||
4414 | if (!m_lastColliders.Contains(id)) | ||
4415 | { | ||
4416 | startedColliders.Add(id); | ||
4417 | curcontact = coldata[id]; | ||
4418 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4419 | { | ||
4420 | soundinfo = new CollisionForSoundInfo(); | ||
4421 | soundinfo.colliderID = id; | ||
4422 | soundinfo.position = curcontact.Position; | ||
4423 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4424 | soundinfolist.Add(soundinfo); | ||
4425 | } | ||
4426 | } | ||
4427 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4428 | } | ||
4429 | |||
4430 | // calculate things that ended colliding | ||
4431 | foreach (uint localID in m_lastColliders) | ||
4432 | { | ||
4433 | if (!thisHitColliders.Contains(localID)) | ||
4434 | { | ||
4435 | endedColliders.Add(localID); | ||
4436 | } | ||
4437 | } | ||
4438 | //add the items that started colliding this time to the last colliders list. | ||
4439 | foreach (uint localID in startedColliders) | ||
4440 | { | ||
4441 | m_lastColliders.Add(localID); | ||
4442 | } | ||
4443 | // remove things that ended colliding from the last colliders list | ||
4444 | foreach (uint localID in endedColliders) | ||
4445 | { | ||
4446 | m_lastColliders.Remove(localID); | ||
4447 | } | ||
4448 | |||
4449 | if (soundinfolist.Count > 0) | ||
4450 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4451 | } | ||
4452 | |||
4453 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4454 | { | ||
4455 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4456 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4457 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4458 | |||
4459 | if (startedColliders.Contains(0)) | ||
4460 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4461 | if (m_lastColliders.Contains(0)) | ||
4462 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4463 | if (endedColliders.Contains(0)) | ||
4464 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4465 | } | ||
4466 | } | ||
4467 | finally | ||
4468 | { | ||
4469 | m_collisionEventFlag = false; | ||
4470 | } | ||
4471 | } | ||
4472 | |||
4036 | private void TeleportFlagsDebug() { | 4473 | private void TeleportFlagsDebug() { |
4037 | 4474 | ||
4038 | // Some temporary debugging help to show all the TeleportFlags we have... | 4475 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4057,6 +4494,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4057 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4494 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4058 | 4495 | ||
4059 | } | 4496 | } |
4060 | |||
4061 | } | 4497 | } |
4062 | } | 4498 | } |