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 65d526f..cfd4a51 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 |
@@ -893,14 +976,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
893 | { | 976 | { |
894 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); | 977 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); |
895 | // Resume scripts | 978 | // Resume scripts |
896 | foreach (SceneObjectGroup sog in m_attachments) | 979 | Util.FireAndForget(delegate(object x) { |
897 | { | 980 | foreach (SceneObjectGroup sog in m_attachments) |
898 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 981 | { |
899 | sog.ResumeScripts(); | 982 | sog.ScheduleGroupForFullUpdate(); |
900 | } | 983 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
984 | sog.ResumeScripts(); | ||
985 | } | ||
986 | }); | ||
901 | } | 987 | } |
902 | } | 988 | } |
903 | 989 | ||
990 | SendAvatarDataToAllAgents(); | ||
991 | |||
904 | // send the animations of the other presences to me | 992 | // send the animations of the other presences to me |
905 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 993 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
906 | { | 994 | { |
@@ -911,9 +999,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
911 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 999 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
912 | // stall on the border crossing since the existing child agent will still have the last movement | 1000 | // stall on the border crossing since the existing child agent will still have the last movement |
913 | // recorded, which stops the input from being processed. | 1001 | // recorded, which stops the input from being processed. |
1002 | |||
914 | MovementFlag = 0; | 1003 | MovementFlag = 0; |
915 | 1004 | ||
916 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1005 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1006 | |||
1007 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
917 | } | 1008 | } |
918 | 1009 | ||
919 | public int GetStateSource() | 1010 | public int GetStateSource() |
@@ -941,12 +1032,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
941 | /// </remarks> | 1032 | /// </remarks> |
942 | public void MakeChildAgent() | 1033 | public void MakeChildAgent() |
943 | { | 1034 | { |
1035 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1036 | |||
944 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1037 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
945 | 1038 | ||
946 | // Reset these so that teleporting in and walking out isn't seen | 1039 | // Reset these so that teleporting in and walking out isn't seen |
947 | // as teleporting back | 1040 | // as teleporting back |
948 | TeleportFlags = TeleportFlags.Default; | 1041 | TeleportFlags = TeleportFlags.Default; |
949 | 1042 | ||
1043 | MovementFlag = 0; | ||
1044 | |||
950 | // It looks like Animator is set to null somewhere, and MakeChild | 1045 | // It looks like Animator is set to null somewhere, and MakeChild |
951 | // is called after that. Probably in aborted teleports. | 1046 | // is called after that. Probably in aborted teleports. |
952 | if (Animator == null) | 1047 | if (Animator == null) |
@@ -954,6 +1049,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
954 | else | 1049 | else |
955 | Animator.ResetAnimations(); | 1050 | Animator.ResetAnimations(); |
956 | 1051 | ||
1052 | |||
957 | // m_log.DebugFormat( | 1053 | // m_log.DebugFormat( |
958 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1054 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
959 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1055 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -965,6 +1061,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
965 | IsChildAgent = true; | 1061 | IsChildAgent = true; |
966 | m_scene.SwapRootAgentCount(true); | 1062 | m_scene.SwapRootAgentCount(true); |
967 | RemoveFromPhysicalScene(); | 1063 | RemoveFromPhysicalScene(); |
1064 | ParentID = 0; // Child agents can't be sitting | ||
968 | 1065 | ||
969 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1066 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
970 | 1067 | ||
@@ -980,9 +1077,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
980 | { | 1077 | { |
981 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1078 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
982 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1079 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
983 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
984 | PhysicsActor.UnSubscribeEvents(); | ||
985 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1080 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1081 | PhysicsActor.UnSubscribeEvents(); | ||
1082 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
986 | PhysicsActor = null; | 1083 | PhysicsActor = null; |
987 | } | 1084 | } |
988 | // else | 1085 | // else |
@@ -999,7 +1096,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
999 | /// <param name="pos"></param> | 1096 | /// <param name="pos"></param> |
1000 | public void Teleport(Vector3 pos) | 1097 | public void Teleport(Vector3 pos) |
1001 | { | 1098 | { |
1002 | TeleportWithMomentum(pos, null); | 1099 | TeleportWithMomentum(pos, Vector3.Zero); |
1003 | } | 1100 | } |
1004 | 1101 | ||
1005 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1102 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1023,6 +1120,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1023 | SendTerseUpdateToAllClients(); | 1120 | SendTerseUpdateToAllClients(); |
1024 | } | 1121 | } |
1025 | 1122 | ||
1123 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1124 | { | ||
1125 | CheckLandingPoint(ref newpos); | ||
1126 | AbsolutePosition = newpos; | ||
1127 | |||
1128 | if (newvel.HasValue) | ||
1129 | { | ||
1130 | if ((Vector3)newvel == Vector3.Zero) | ||
1131 | { | ||
1132 | if (PhysicsActor != null) | ||
1133 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1134 | m_velocity = Vector3.Zero; | ||
1135 | } | ||
1136 | else | ||
1137 | { | ||
1138 | if (PhysicsActor != null) | ||
1139 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1140 | m_velocity = (Vector3)newvel; | ||
1141 | |||
1142 | if (rotateToVelXY) | ||
1143 | { | ||
1144 | Vector3 lookAt = (Vector3)newvel; | ||
1145 | lookAt.Z = 0; | ||
1146 | lookAt.Normalize(); | ||
1147 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1148 | return; | ||
1149 | } | ||
1150 | } | ||
1151 | } | ||
1152 | |||
1153 | SendTerseUpdateToAllClients(); | ||
1154 | } | ||
1155 | |||
1156 | |||
1157 | |||
1026 | public void StopFlying() | 1158 | public void StopFlying() |
1027 | { | 1159 | { |
1028 | ControllingClient.StopFlying(this); | 1160 | ControllingClient.StopFlying(this); |
@@ -1338,8 +1470,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1338 | { | 1470 | { |
1339 | if (m_followCamAuto) | 1471 | if (m_followCamAuto) |
1340 | { | 1472 | { |
1341 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1473 | // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1342 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1474 | // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); |
1475 | |||
1476 | Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; | ||
1477 | Vector3 distTocam = CameraPosition - posAdjusted; | ||
1478 | float distTocamlen = distTocam.Length(); | ||
1479 | if (distTocamlen > 0) | ||
1480 | { | ||
1481 | distTocam *= 1.0f / distTocamlen; | ||
1482 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); | ||
1483 | } | ||
1484 | |||
1343 | } | 1485 | } |
1344 | } | 1486 | } |
1345 | 1487 | ||
@@ -1778,12 +1920,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1778 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1920 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1779 | 1921 | ||
1780 | SitGround = false; | 1922 | SitGround = false; |
1923 | |||
1924 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1781 | if (PhysicsActor == null) | 1925 | if (PhysicsActor == null) |
1782 | AddToPhysicalScene(false); | 1926 | AddToPhysicalScene(false); |
1927 | */ | ||
1783 | 1928 | ||
1784 | if (ParentID != 0) | 1929 | if (ParentID != 0) |
1785 | { | 1930 | { |
1786 | SceneObjectPart part = ParentPart; | 1931 | SceneObjectPart part = ParentPart; |
1932 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
1933 | |||
1787 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1934 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1788 | if (taskIDict != null) | 1935 | if (taskIDict != null) |
1789 | { | 1936 | { |
@@ -1799,14 +1946,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1799 | } | 1946 | } |
1800 | } | 1947 | } |
1801 | 1948 | ||
1802 | ParentPosition = part.GetWorldPosition(); | 1949 | part.ParentGroup.DeleteAvatar(UUID); |
1950 | // ParentPosition = part.GetWorldPosition(); | ||
1803 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1951 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1804 | 1952 | ||
1805 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 1953 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
1806 | ParentPosition = Vector3.Zero; | 1954 | // ParentPosition = Vector3.Zero; |
1955 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
1956 | if (part.SitTargetAvatar == UUID) | ||
1957 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
1807 | 1958 | ||
1808 | ParentID = 0; | 1959 | ParentID = 0; |
1809 | ParentPart = null; | 1960 | ParentPart = null; |
1961 | |||
1962 | if (PhysicsActor == null) | ||
1963 | AddToPhysicalScene(false); | ||
1964 | |||
1810 | SendAvatarDataToAllAgents(); | 1965 | SendAvatarDataToAllAgents(); |
1811 | m_requestedSitTargetID = 0; | 1966 | m_requestedSitTargetID = 0; |
1812 | 1967 | ||
@@ -1816,6 +1971,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1816 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1971 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1817 | } | 1972 | } |
1818 | 1973 | ||
1974 | else if (PhysicsActor == null) | ||
1975 | AddToPhysicalScene(false); | ||
1976 | |||
1819 | Animator.TrySetMovementAnimation("STAND"); | 1977 | Animator.TrySetMovementAnimation("STAND"); |
1820 | } | 1978 | } |
1821 | 1979 | ||
@@ -1867,7 +2025,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1867 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 2025 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1868 | 2026 | ||
1869 | if (PhysicsActor != null) | 2027 | if (PhysicsActor != null) |
1870 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2028 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
1871 | 2029 | ||
1872 | bool canSit = false; | 2030 | bool canSit = false; |
1873 | Vector3 pos = part.AbsolutePosition + offset; | 2031 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -1916,7 +2074,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1916 | forceMouselook = part.GetForceMouselook(); | 2074 | forceMouselook = part.GetForceMouselook(); |
1917 | 2075 | ||
1918 | ControllingClient.SendSitResponse( | 2076 | ControllingClient.SendSitResponse( |
1919 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2077 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1920 | 2078 | ||
1921 | m_requestedSitTargetUUID = targetID; | 2079 | m_requestedSitTargetUUID = targetID; |
1922 | 2080 | ||
@@ -1930,6 +2088,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1930 | 2088 | ||
1931 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2089 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
1932 | { | 2090 | { |
2091 | if (IsChildAgent) | ||
2092 | return; | ||
2093 | |||
1933 | if (ParentID != 0) | 2094 | if (ParentID != 0) |
1934 | { | 2095 | { |
1935 | StandUp(); | 2096 | StandUp(); |
@@ -2207,14 +2368,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2207 | 2368 | ||
2208 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2369 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2209 | 2370 | ||
2210 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2371 | double x, y, z, m; |
2372 | |||
2373 | Quaternion r = sitTargetOrient; | ||
2374 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2375 | |||
2376 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2377 | { | ||
2378 | m = 1.0 / Math.Sqrt(m); | ||
2379 | r.X *= (float)m; | ||
2380 | r.Y *= (float)m; | ||
2381 | r.Z *= (float)m; | ||
2382 | r.W *= (float)m; | ||
2383 | } | ||
2384 | |||
2385 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2386 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2387 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2388 | |||
2389 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2390 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2391 | |||
2392 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2393 | |||
2394 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2211 | Rotation = sitTargetOrient; | 2395 | Rotation = sitTargetOrient; |
2212 | ParentPosition = part.AbsolutePosition; | 2396 | // ParentPosition = part.AbsolutePosition; |
2397 | part.ParentGroup.AddAvatar(UUID); | ||
2213 | } | 2398 | } |
2214 | else | 2399 | else |
2215 | { | 2400 | { |
2216 | m_pos -= part.AbsolutePosition; | 2401 | m_pos -= part.AbsolutePosition; |
2217 | ParentPosition = part.AbsolutePosition; | 2402 | // ParentPosition = part.AbsolutePosition; |
2403 | part.ParentGroup.AddAvatar(UUID); | ||
2218 | 2404 | ||
2219 | // m_log.DebugFormat( | 2405 | // m_log.DebugFormat( |
2220 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2406 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2259,6 +2445,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2259 | Animator.RemoveAnimation(animID); | 2445 | Animator.RemoveAnimation(animID); |
2260 | } | 2446 | } |
2261 | 2447 | ||
2448 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2449 | { | ||
2450 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2451 | } | ||
2452 | |||
2453 | |||
2454 | |||
2262 | /// <summary> | 2455 | /// <summary> |
2263 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2456 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2264 | /// </summary> | 2457 | /// </summary> |
@@ -2312,14 +2505,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2312 | direc.Z *= 2.6f; | 2505 | direc.Z *= 2.6f; |
2313 | 2506 | ||
2314 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2507 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2315 | Animator.TrySetMovementAnimation("PREJUMP"); | 2508 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2316 | Animator.TrySetMovementAnimation("JUMP"); | 2509 | // Animator.TrySetMovementAnimation("JUMP"); |
2317 | } | 2510 | } |
2318 | } | 2511 | } |
2319 | } | 2512 | } |
2320 | 2513 | ||
2321 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2514 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2322 | m_forceToApply = direc; | 2515 | m_forceToApply = direc; |
2516 | Animator.UpdateMovementAnimations(); | ||
2323 | } | 2517 | } |
2324 | 2518 | ||
2325 | #endregion | 2519 | #endregion |
@@ -2711,8 +2905,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2711 | 2905 | ||
2712 | // If we don't have a PhysActor, we can't cross anyway | 2906 | // If we don't have a PhysActor, we can't cross anyway |
2713 | // Also don't do this while sat, sitting avatars cross with the | 2907 | // Also don't do this while sat, sitting avatars cross with the |
2714 | // object they sit on. | 2908 | // object they sit on. ParentUUID denoted a pending sit, don't |
2715 | if (ParentID != 0 || PhysicsActor == null) | 2909 | // interfere with it. |
2910 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2716 | return; | 2911 | return; |
2717 | 2912 | ||
2718 | if (!IsInTransit) | 2913 | if (!IsInTransit) |
@@ -3053,6 +3248,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3053 | cAgent.AlwaysRun = SetAlwaysRun; | 3248 | cAgent.AlwaysRun = SetAlwaysRun; |
3054 | 3249 | ||
3055 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3250 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3251 | |||
3252 | cAgent.ParentPart = ParentUUID; | ||
3253 | cAgent.SitOffset = m_pos; | ||
3056 | 3254 | ||
3057 | lock (scriptedcontrols) | 3255 | lock (scriptedcontrols) |
3058 | { | 3256 | { |
@@ -3061,7 +3259,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3061 | 3259 | ||
3062 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3260 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3063 | { | 3261 | { |
3064 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3262 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3065 | } | 3263 | } |
3066 | cAgent.Controllers = controls; | 3264 | cAgent.Controllers = controls; |
3067 | } | 3265 | } |
@@ -3072,6 +3270,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3072 | cAgent.Anims = Animator.Animations.ToArray(); | 3270 | cAgent.Anims = Animator.Animations.ToArray(); |
3073 | } | 3271 | } |
3074 | catch { } | 3272 | catch { } |
3273 | cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; | ||
3075 | 3274 | ||
3076 | if (Scene.AttachmentsModule != null) | 3275 | if (Scene.AttachmentsModule != null) |
3077 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); | 3276 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); |
@@ -3092,6 +3291,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3092 | CameraAtAxis = cAgent.AtAxis; | 3291 | CameraAtAxis = cAgent.AtAxis; |
3093 | CameraLeftAxis = cAgent.LeftAxis; | 3292 | CameraLeftAxis = cAgent.LeftAxis; |
3094 | CameraUpAxis = cAgent.UpAxis; | 3293 | CameraUpAxis = cAgent.UpAxis; |
3294 | ParentUUID = cAgent.ParentPart; | ||
3295 | m_prevSitOffset = cAgent.SitOffset; | ||
3095 | 3296 | ||
3096 | // When we get to the point of re-computing neighbors everytime this | 3297 | // When we get to the point of re-computing neighbors everytime this |
3097 | // changes, then start using the agent's drawdistance rather than the | 3298 | // changes, then start using the agent's drawdistance rather than the |
@@ -3129,6 +3330,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3129 | foreach (ControllerData c in cAgent.Controllers) | 3330 | foreach (ControllerData c in cAgent.Controllers) |
3130 | { | 3331 | { |
3131 | ScriptControllers sc = new ScriptControllers(); | 3332 | ScriptControllers sc = new ScriptControllers(); |
3333 | sc.objectID = c.ObjectID; | ||
3132 | sc.itemID = c.ItemID; | 3334 | sc.itemID = c.ItemID; |
3133 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3335 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3134 | sc.eventControls = (ScriptControlled)c.EventControls; | 3336 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3143,6 +3345,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3143 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? | 3345 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? |
3144 | if (cAgent.Anims != null) | 3346 | if (cAgent.Anims != null) |
3145 | Animator.Animations.FromArray(cAgent.Anims); | 3347 | Animator.Animations.FromArray(cAgent.Anims); |
3348 | if (cAgent.DefaultAnim != null) | ||
3349 | Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); | ||
3146 | 3350 | ||
3147 | if (Scene.AttachmentsModule != null) | 3351 | if (Scene.AttachmentsModule != null) |
3148 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); | 3352 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); |
@@ -3205,7 +3409,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3205 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3409 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3206 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3410 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3207 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3411 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3208 | PhysicsActor.SubscribeEvents(500); | 3412 | PhysicsActor.SubscribeEvents(100); |
3209 | PhysicsActor.LocalID = LocalId; | 3413 | PhysicsActor.LocalID = LocalId; |
3210 | } | 3414 | } |
3211 | 3415 | ||
@@ -3287,6 +3491,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3287 | } | 3491 | } |
3288 | } | 3492 | } |
3289 | 3493 | ||
3494 | RaiseCollisionScriptEvents(coldata); | ||
3495 | |||
3290 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3496 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3291 | if (Invulnerable || GodLevel > 0) | 3497 | if (Invulnerable || GodLevel > 0) |
3292 | return; | 3498 | return; |
@@ -3384,6 +3590,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3384 | // m_reprioritizationTimer.Dispose(); | 3590 | // m_reprioritizationTimer.Dispose(); |
3385 | 3591 | ||
3386 | RemoveFromPhysicalScene(); | 3592 | RemoveFromPhysicalScene(); |
3593 | |||
3594 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3595 | |||
3596 | // if (Animator != null) | ||
3597 | // Animator.Close(); | ||
3598 | Animator = null; | ||
3599 | |||
3387 | } | 3600 | } |
3388 | 3601 | ||
3389 | public void AddAttachment(SceneObjectGroup gobj) | 3602 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3614,10 +3827,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3614 | 3827 | ||
3615 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 3828 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3616 | { | 3829 | { |
3830 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
3831 | if (p == null) | ||
3832 | return; | ||
3833 | |||
3834 | ControllingClient.SendTakeControls(controls, false, false); | ||
3835 | ControllingClient.SendTakeControls(controls, true, false); | ||
3836 | |||
3617 | ScriptControllers obj = new ScriptControllers(); | 3837 | ScriptControllers obj = new ScriptControllers(); |
3618 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 3838 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3619 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 3839 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3620 | 3840 | ||
3841 | obj.objectID = p.ParentGroup.UUID; | ||
3621 | obj.itemID = Script_item_UUID; | 3842 | obj.itemID = Script_item_UUID; |
3622 | if (pass_on == 0 && accept == 0) | 3843 | if (pass_on == 0 && accept == 0) |
3623 | { | 3844 | { |
@@ -3666,6 +3887,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3666 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 3887 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3667 | } | 3888 | } |
3668 | 3889 | ||
3890 | private void UnRegisterSeatControls(UUID obj) | ||
3891 | { | ||
3892 | List<UUID> takers = new List<UUID>(); | ||
3893 | |||
3894 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
3895 | { | ||
3896 | if (c.objectID == obj) | ||
3897 | takers.Add(c.itemID); | ||
3898 | } | ||
3899 | foreach (UUID t in takers) | ||
3900 | { | ||
3901 | UnRegisterControlEventsToScript(0, t); | ||
3902 | } | ||
3903 | } | ||
3904 | |||
3669 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3905 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3670 | { | 3906 | { |
3671 | ScriptControllers takecontrols; | 3907 | ScriptControllers takecontrols; |
@@ -3984,6 +4220,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3984 | 4220 | ||
3985 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4221 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3986 | { | 4222 | { |
4223 | string reason; | ||
4224 | |||
4225 | // Honor bans | ||
4226 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4227 | return; | ||
4228 | |||
3987 | SceneObjectGroup telehub = null; | 4229 | SceneObjectGroup telehub = null; |
3988 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4230 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
3989 | { | 4231 | { |
@@ -4023,11 +4265,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4023 | pos = land.LandData.UserLocation; | 4265 | pos = land.LandData.UserLocation; |
4024 | } | 4266 | } |
4025 | } | 4267 | } |
4026 | 4268 | ||
4027 | land.SendLandUpdateToClient(ControllingClient); | 4269 | land.SendLandUpdateToClient(ControllingClient); |
4028 | } | 4270 | } |
4029 | } | 4271 | } |
4030 | 4272 | ||
4273 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4274 | { | ||
4275 | DetectedObject detobj = new DetectedObject(); | ||
4276 | detobj.keyUUID = obj.UUID; | ||
4277 | detobj.nameStr = obj.Name; | ||
4278 | detobj.ownerUUID = obj.OwnerID; | ||
4279 | detobj.posVector = obj.AbsolutePosition; | ||
4280 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4281 | detobj.velVector = obj.Velocity; | ||
4282 | detobj.colliderType = 0; | ||
4283 | detobj.groupUUID = obj.GroupID; | ||
4284 | |||
4285 | return detobj; | ||
4286 | } | ||
4287 | |||
4288 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4289 | { | ||
4290 | DetectedObject detobj = new DetectedObject(); | ||
4291 | detobj.keyUUID = av.UUID; | ||
4292 | detobj.nameStr = av.ControllingClient.Name; | ||
4293 | detobj.ownerUUID = av.UUID; | ||
4294 | detobj.posVector = av.AbsolutePosition; | ||
4295 | detobj.rotQuat = av.Rotation; | ||
4296 | detobj.velVector = av.Velocity; | ||
4297 | detobj.colliderType = 0; | ||
4298 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4299 | |||
4300 | return detobj; | ||
4301 | } | ||
4302 | |||
4303 | private DetectedObject CreateDetObjectForGround() | ||
4304 | { | ||
4305 | DetectedObject detobj = new DetectedObject(); | ||
4306 | detobj.keyUUID = UUID.Zero; | ||
4307 | detobj.nameStr = ""; | ||
4308 | detobj.ownerUUID = UUID.Zero; | ||
4309 | detobj.posVector = AbsolutePosition; | ||
4310 | detobj.rotQuat = Quaternion.Identity; | ||
4311 | detobj.velVector = Vector3.Zero; | ||
4312 | detobj.colliderType = 0; | ||
4313 | detobj.groupUUID = UUID.Zero; | ||
4314 | |||
4315 | return detobj; | ||
4316 | } | ||
4317 | |||
4318 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4319 | { | ||
4320 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4321 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4322 | foreach (uint localId in colliders) | ||
4323 | { | ||
4324 | if (localId == 0) | ||
4325 | continue; | ||
4326 | |||
4327 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4328 | if (obj != null) | ||
4329 | { | ||
4330 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4331 | colliding.Add(CreateDetObject(obj)); | ||
4332 | } | ||
4333 | else | ||
4334 | { | ||
4335 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4336 | if (av != null && (!av.IsChildAgent)) | ||
4337 | { | ||
4338 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4339 | colliding.Add(CreateDetObject(av)); | ||
4340 | } | ||
4341 | } | ||
4342 | } | ||
4343 | |||
4344 | colliderArgs.Colliders = colliding; | ||
4345 | |||
4346 | return colliderArgs; | ||
4347 | } | ||
4348 | |||
4349 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4350 | |||
4351 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4352 | { | ||
4353 | ColliderArgs CollidingMessage; | ||
4354 | |||
4355 | if (colliders.Count > 0) | ||
4356 | { | ||
4357 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4358 | { | ||
4359 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4360 | |||
4361 | if (CollidingMessage.Colliders.Count > 0) | ||
4362 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4363 | } | ||
4364 | } | ||
4365 | } | ||
4366 | |||
4367 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4368 | { | ||
4369 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4370 | { | ||
4371 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4372 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4373 | |||
4374 | colliding.Add(CreateDetObjectForGround()); | ||
4375 | LandCollidingMessage.Colliders = colliding; | ||
4376 | |||
4377 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4378 | } | ||
4379 | } | ||
4380 | |||
4381 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4382 | { | ||
4383 | try | ||
4384 | { | ||
4385 | List<uint> thisHitColliders = new List<uint>(); | ||
4386 | List<uint> endedColliders = new List<uint>(); | ||
4387 | List<uint> startedColliders = new List<uint>(); | ||
4388 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4389 | CollisionForSoundInfo soundinfo; | ||
4390 | ContactPoint curcontact; | ||
4391 | |||
4392 | if (coldata.Count == 0) | ||
4393 | { | ||
4394 | if (m_lastColliders.Count == 0) | ||
4395 | return; // nothing to do | ||
4396 | |||
4397 | foreach (uint localID in m_lastColliders) | ||
4398 | { | ||
4399 | endedColliders.Add(localID); | ||
4400 | } | ||
4401 | m_lastColliders.Clear(); | ||
4402 | } | ||
4403 | |||
4404 | else | ||
4405 | { | ||
4406 | foreach (uint id in coldata.Keys) | ||
4407 | { | ||
4408 | thisHitColliders.Add(id); | ||
4409 | if (!m_lastColliders.Contains(id)) | ||
4410 | { | ||
4411 | startedColliders.Add(id); | ||
4412 | curcontact = coldata[id]; | ||
4413 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4414 | { | ||
4415 | soundinfo = new CollisionForSoundInfo(); | ||
4416 | soundinfo.colliderID = id; | ||
4417 | soundinfo.position = curcontact.Position; | ||
4418 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4419 | soundinfolist.Add(soundinfo); | ||
4420 | } | ||
4421 | } | ||
4422 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4423 | } | ||
4424 | |||
4425 | // calculate things that ended colliding | ||
4426 | foreach (uint localID in m_lastColliders) | ||
4427 | { | ||
4428 | if (!thisHitColliders.Contains(localID)) | ||
4429 | { | ||
4430 | endedColliders.Add(localID); | ||
4431 | } | ||
4432 | } | ||
4433 | //add the items that started colliding this time to the last colliders list. | ||
4434 | foreach (uint localID in startedColliders) | ||
4435 | { | ||
4436 | m_lastColliders.Add(localID); | ||
4437 | } | ||
4438 | // remove things that ended colliding from the last colliders list | ||
4439 | foreach (uint localID in endedColliders) | ||
4440 | { | ||
4441 | m_lastColliders.Remove(localID); | ||
4442 | } | ||
4443 | |||
4444 | if (soundinfolist.Count > 0) | ||
4445 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4446 | } | ||
4447 | |||
4448 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4449 | { | ||
4450 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4451 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4452 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4453 | |||
4454 | if (startedColliders.Contains(0)) | ||
4455 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4456 | if (m_lastColliders.Contains(0)) | ||
4457 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4458 | if (endedColliders.Contains(0)) | ||
4459 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4460 | } | ||
4461 | } | ||
4462 | finally | ||
4463 | { | ||
4464 | m_collisionEventFlag = false; | ||
4465 | } | ||
4466 | } | ||
4467 | |||
4031 | private void TeleportFlagsDebug() { | 4468 | private void TeleportFlagsDebug() { |
4032 | 4469 | ||
4033 | // Some temporary debugging help to show all the TeleportFlags we have... | 4470 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4052,6 +4489,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4052 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4489 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4053 | 4490 | ||
4054 | } | 4491 | } |
4055 | |||
4056 | } | 4492 | } |
4057 | } | 4493 | } |