diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 593 |
1 files changed, 503 insertions, 90 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0e7f2e5..e27d309 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. |
@@ -175,6 +176,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
175 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 176 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
176 | // private int m_updateCount = 0; //KF: Update Anims for a while | 177 | // private int m_updateCount = 0; //KF: Update Anims for a while |
177 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 178 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
179 | private List<uint> m_lastColliders = new List<uint>(); | ||
178 | 180 | ||
179 | private TeleportFlags m_teleportFlags; | 181 | private TeleportFlags m_teleportFlags; |
180 | public TeleportFlags TeleportFlags | 182 | public TeleportFlags TeleportFlags |
@@ -236,6 +238,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
236 | //private int m_moveToPositionStateStatus; | 238 | //private int m_moveToPositionStateStatus; |
237 | //***************************************************** | 239 | //***************************************************** |
238 | 240 | ||
241 | private bool m_collisionEventFlag = false; | ||
242 | private object m_collisionEventLock = new Object(); | ||
243 | |||
244 | private int m_movementAnimationUpdateCounter = 0; | ||
245 | |||
246 | private Vector3 m_prevSitOffset; | ||
247 | |||
239 | protected AvatarAppearance m_appearance; | 248 | protected AvatarAppearance m_appearance; |
240 | 249 | ||
241 | public AvatarAppearance Appearance | 250 | public AvatarAppearance Appearance |
@@ -430,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
430 | get { return (IClientCore)ControllingClient; } | 439 | get { return (IClientCore)ControllingClient; } |
431 | } | 440 | } |
432 | 441 | ||
433 | public Vector3 ParentPosition { get; set; } | 442 | // public Vector3 ParentPosition { get; set; } |
434 | 443 | ||
435 | /// <summary> | 444 | /// <summary> |
436 | /// Position of this avatar relative to the region the avatar is in | 445 | /// Position of this avatar relative to the region the avatar is in |
@@ -488,7 +497,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
488 | if (ParentID == 0) | 497 | if (ParentID == 0) |
489 | { | 498 | { |
490 | m_pos = value; | 499 | m_pos = value; |
491 | ParentPosition = Vector3.Zero; | 500 | // ParentPosition = Vector3.Zero; |
492 | } | 501 | } |
493 | 502 | ||
494 | //m_log.DebugFormat( | 503 | //m_log.DebugFormat( |
@@ -577,6 +586,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
577 | /// </summary> | 586 | /// </summary> |
578 | public uint ParentID { get; set; } | 587 | public uint ParentID { get; set; } |
579 | 588 | ||
589 | public UUID ParentUUID | ||
590 | { | ||
591 | get { return m_parentUUID; } | ||
592 | set { m_parentUUID = value; } | ||
593 | } | ||
594 | private UUID m_parentUUID = UUID.Zero; | ||
595 | |||
580 | /// <summary> | 596 | /// <summary> |
581 | /// Are we sitting on an object? | 597 | /// Are we sitting on an object? |
582 | /// </summary> | 598 | /// </summary> |
@@ -743,6 +759,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
743 | Appearance = appearance; | 759 | Appearance = appearance; |
744 | } | 760 | } |
745 | 761 | ||
762 | private void RegionHeartbeatEnd(Scene scene) | ||
763 | { | ||
764 | if (IsChildAgent) | ||
765 | return; | ||
766 | |||
767 | m_movementAnimationUpdateCounter ++; | ||
768 | if (m_movementAnimationUpdateCounter >= 2) | ||
769 | { | ||
770 | m_movementAnimationUpdateCounter = 0; | ||
771 | if (Animator != null) | ||
772 | { | ||
773 | // If the parentID == 0 we are not sitting | ||
774 | // if !SitGournd then we are not sitting on the ground | ||
775 | // Fairly straightforward, now here comes the twist | ||
776 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
777 | // be sat on an object that isn't there yet. Should | ||
778 | // be treated as if sat. | ||
779 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
780 | Animator.UpdateMovementAnimations(); | ||
781 | } | ||
782 | else | ||
783 | { | ||
784 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
785 | } | ||
786 | } | ||
787 | } | ||
788 | |||
746 | public void RegisterToEvents() | 789 | public void RegisterToEvents() |
747 | { | 790 | { |
748 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 791 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -752,6 +795,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
752 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 795 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
753 | ControllingClient.OnStartAnim += HandleStartAnim; | 796 | ControllingClient.OnStartAnim += HandleStartAnim; |
754 | ControllingClient.OnStopAnim += HandleStopAnim; | 797 | ControllingClient.OnStopAnim += HandleStopAnim; |
798 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
755 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 799 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
756 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 800 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
757 | 801 | ||
@@ -812,10 +856,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
812 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 856 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
813 | Name, m_scene.RegionInfo.RegionName); | 857 | Name, m_scene.RegionInfo.RegionName); |
814 | 858 | ||
815 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
816 | |||
817 | bool wasChild = IsChildAgent; | 859 | bool wasChild = IsChildAgent; |
818 | IsChildAgent = false; | 860 | |
861 | if (ParentUUID != UUID.Zero) | ||
862 | { | ||
863 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
864 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
865 | if (part == null) | ||
866 | { | ||
867 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
868 | } | ||
869 | else | ||
870 | { | ||
871 | part.ParentGroup.AddAvatar(UUID); | ||
872 | if (part.SitTargetPosition != Vector3.Zero) | ||
873 | part.SitTargetAvatar = UUID; | ||
874 | // ParentPosition = part.GetWorldPosition(); | ||
875 | ParentID = part.LocalId; | ||
876 | ParentPart = part; | ||
877 | m_pos = m_prevSitOffset; | ||
878 | // pos = ParentPosition; | ||
879 | pos = part.GetWorldPosition(); | ||
880 | } | ||
881 | ParentUUID = UUID.Zero; | ||
882 | |||
883 | IsChildAgent = false; | ||
884 | |||
885 | // Animator.TrySetMovementAnimation("SIT"); | ||
886 | } | ||
887 | else | ||
888 | { | ||
889 | IsChildAgent = false; | ||
890 | } | ||
891 | |||
819 | 892 | ||
820 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 893 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
821 | if (gm != null) | 894 | if (gm != null) |
@@ -825,62 +898,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
825 | 898 | ||
826 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 899 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
827 | 900 | ||
828 | // Moved this from SendInitialData to ensure that Appearance is initialized | 901 | if (ParentID == 0) |
829 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | ||
830 | // related to the handling of attachments | ||
831 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
832 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
833 | { | 902 | { |
834 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 903 | // Moved this from SendInitialData to ensure that Appearance is initialized |
835 | pos.X = crossedBorder.BorderLine.Z - 1; | 904 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
836 | } | 905 | // related to the handling of attachments |
906 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
907 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
908 | { | ||
909 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
910 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
911 | } | ||
837 | 912 | ||
838 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 913 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
839 | { | 914 | { |
840 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 915 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
841 | pos.Y = crossedBorder.BorderLine.Z - 1; | 916 | pos.Y = crossedBorder.BorderLine.Z - 1; |
842 | } | 917 | } |
843 | 918 | ||
844 | CheckAndAdjustLandingPoint(ref pos); | 919 | CheckAndAdjustLandingPoint(ref pos); |
845 | 920 | ||
846 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 921 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
847 | { | 922 | { |
848 | m_log.WarnFormat( | 923 | m_log.WarnFormat( |
849 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 924 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
850 | pos, Name, UUID); | 925 | pos, Name, UUID); |
851 | 926 | ||
852 | if (pos.X < 0f) pos.X = 0f; | 927 | if (pos.X < 0f) pos.X = 0f; |
853 | if (pos.Y < 0f) pos.Y = 0f; | 928 | if (pos.Y < 0f) pos.Y = 0f; |
854 | if (pos.Z < 0f) pos.Z = 0f; | 929 | if (pos.Z < 0f) pos.Z = 0f; |
855 | } | 930 | } |
856 | 931 | ||
857 | float localAVHeight = 1.56f; | 932 | float localAVHeight = 1.56f; |
858 | if (Appearance.AvatarHeight > 0) | 933 | if (Appearance.AvatarHeight > 0) |
859 | localAVHeight = Appearance.AvatarHeight; | 934 | localAVHeight = Appearance.AvatarHeight; |
860 | 935 | ||
861 | float posZLimit = 0; | 936 | float posZLimit = 0; |
862 | 937 | ||
863 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 938 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
864 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 939 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
865 | 940 | ||
866 | float newPosZ = posZLimit + localAVHeight / 2; | 941 | float newPosZ = posZLimit + localAVHeight / 2; |
867 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 942 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
868 | { | 943 | { |
869 | pos.Z = newPosZ; | 944 | pos.Z = newPosZ; |
870 | } | 945 | } |
871 | AbsolutePosition = pos; | 946 | AbsolutePosition = pos; |
872 | 947 | ||
873 | AddToPhysicalScene(isFlying); | 948 | if (m_teleportFlags == TeleportFlags.Default) |
949 | { | ||
950 | Vector3 vel = Velocity; | ||
951 | AddToPhysicalScene(isFlying); | ||
952 | if (PhysicsActor != null) | ||
953 | PhysicsActor.SetMomentum(vel); | ||
954 | } | ||
955 | else | ||
956 | AddToPhysicalScene(isFlying); | ||
874 | 957 | ||
875 | if (ForceFly) | 958 | if (ForceFly) |
876 | { | 959 | { |
877 | Flying = true; | 960 | Flying = true; |
878 | } | 961 | } |
879 | else if (FlyDisabled) | 962 | else if (FlyDisabled) |
880 | { | 963 | { |
881 | Flying = false; | 964 | Flying = false; |
965 | } | ||
882 | } | 966 | } |
883 | |||
884 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 967 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
885 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 968 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
886 | // elsewhere anyway | 969 | // elsewhere anyway |
@@ -898,14 +981,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
898 | { | 981 | { |
899 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); | 982 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); |
900 | // Resume scripts | 983 | // Resume scripts |
901 | foreach (SceneObjectGroup sog in m_attachments) | 984 | Util.FireAndForget(delegate(object x) { |
902 | { | 985 | foreach (SceneObjectGroup sog in m_attachments) |
903 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 986 | { |
904 | sog.ResumeScripts(); | 987 | sog.ScheduleGroupForFullUpdate(); |
905 | } | 988 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
989 | sog.ResumeScripts(); | ||
990 | } | ||
991 | }); | ||
906 | } | 992 | } |
907 | } | 993 | } |
908 | 994 | ||
995 | SendAvatarDataToAllAgents(); | ||
996 | |||
909 | // send the animations of the other presences to me | 997 | // send the animations of the other presences to me |
910 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 998 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
911 | { | 999 | { |
@@ -916,9 +1004,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
916 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1004 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
917 | // stall on the border crossing since the existing child agent will still have the last movement | 1005 | // stall on the border crossing since the existing child agent will still have the last movement |
918 | // recorded, which stops the input from being processed. | 1006 | // recorded, which stops the input from being processed. |
1007 | |||
919 | MovementFlag = 0; | 1008 | MovementFlag = 0; |
920 | 1009 | ||
921 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1010 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1011 | |||
1012 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
922 | } | 1013 | } |
923 | 1014 | ||
924 | public int GetStateSource() | 1015 | public int GetStateSource() |
@@ -946,12 +1037,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
946 | /// </remarks> | 1037 | /// </remarks> |
947 | public void MakeChildAgent() | 1038 | public void MakeChildAgent() |
948 | { | 1039 | { |
1040 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1041 | |||
949 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1042 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
950 | 1043 | ||
951 | // Reset these so that teleporting in and walking out isn't seen | 1044 | // Reset these so that teleporting in and walking out isn't seen |
952 | // as teleporting back | 1045 | // as teleporting back |
953 | TeleportFlags = TeleportFlags.Default; | 1046 | TeleportFlags = TeleportFlags.Default; |
954 | 1047 | ||
1048 | MovementFlag = 0; | ||
1049 | |||
955 | // It looks like Animator is set to null somewhere, and MakeChild | 1050 | // It looks like Animator is set to null somewhere, and MakeChild |
956 | // is called after that. Probably in aborted teleports. | 1051 | // is called after that. Probably in aborted teleports. |
957 | if (Animator == null) | 1052 | if (Animator == null) |
@@ -959,6 +1054,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
959 | else | 1054 | else |
960 | Animator.ResetAnimations(); | 1055 | Animator.ResetAnimations(); |
961 | 1056 | ||
1057 | |||
962 | // m_log.DebugFormat( | 1058 | // m_log.DebugFormat( |
963 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1059 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
964 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1060 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -970,6 +1066,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
970 | IsChildAgent = true; | 1066 | IsChildAgent = true; |
971 | m_scene.SwapRootAgentCount(true); | 1067 | m_scene.SwapRootAgentCount(true); |
972 | RemoveFromPhysicalScene(); | 1068 | RemoveFromPhysicalScene(); |
1069 | ParentID = 0; // Child agents can't be sitting | ||
973 | 1070 | ||
974 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1071 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
975 | 1072 | ||
@@ -985,9 +1082,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
985 | { | 1082 | { |
986 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1083 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
987 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1084 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
988 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
989 | PhysicsActor.UnSubscribeEvents(); | ||
990 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1085 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1086 | PhysicsActor.UnSubscribeEvents(); | ||
1087 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
991 | PhysicsActor = null; | 1088 | PhysicsActor = null; |
992 | } | 1089 | } |
993 | // else | 1090 | // else |
@@ -1004,7 +1101,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1004 | /// <param name="pos"></param> | 1101 | /// <param name="pos"></param> |
1005 | public void Teleport(Vector3 pos) | 1102 | public void Teleport(Vector3 pos) |
1006 | { | 1103 | { |
1007 | TeleportWithMomentum(pos, null); | 1104 | TeleportWithMomentum(pos, Vector3.Zero); |
1008 | } | 1105 | } |
1009 | 1106 | ||
1010 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1107 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1028,6 +1125,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1028 | SendTerseUpdateToAllClients(); | 1125 | SendTerseUpdateToAllClients(); |
1029 | } | 1126 | } |
1030 | 1127 | ||
1128 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1129 | { | ||
1130 | CheckLandingPoint(ref newpos); | ||
1131 | AbsolutePosition = newpos; | ||
1132 | |||
1133 | if (newvel.HasValue) | ||
1134 | { | ||
1135 | if ((Vector3)newvel == Vector3.Zero) | ||
1136 | { | ||
1137 | if (PhysicsActor != null) | ||
1138 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1139 | m_velocity = Vector3.Zero; | ||
1140 | } | ||
1141 | else | ||
1142 | { | ||
1143 | if (PhysicsActor != null) | ||
1144 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1145 | m_velocity = (Vector3)newvel; | ||
1146 | |||
1147 | if (rotateToVelXY) | ||
1148 | { | ||
1149 | Vector3 lookAt = (Vector3)newvel; | ||
1150 | lookAt.Z = 0; | ||
1151 | lookAt.Normalize(); | ||
1152 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1153 | return; | ||
1154 | } | ||
1155 | } | ||
1156 | } | ||
1157 | |||
1158 | SendTerseUpdateToAllClients(); | ||
1159 | } | ||
1160 | |||
1161 | |||
1162 | |||
1031 | public void StopFlying() | 1163 | public void StopFlying() |
1032 | { | 1164 | { |
1033 | ControllingClient.StopFlying(this); | 1165 | ControllingClient.StopFlying(this); |
@@ -1343,8 +1475,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1343 | { | 1475 | { |
1344 | if (m_followCamAuto) | 1476 | if (m_followCamAuto) |
1345 | { | 1477 | { |
1346 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1478 | // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1347 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1479 | // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); |
1480 | |||
1481 | Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; | ||
1482 | Vector3 distTocam = CameraPosition - posAdjusted; | ||
1483 | float distTocamlen = distTocam.Length(); | ||
1484 | if (distTocamlen > 0) | ||
1485 | { | ||
1486 | distTocam *= 1.0f / distTocamlen; | ||
1487 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); | ||
1488 | } | ||
1489 | |||
1348 | } | 1490 | } |
1349 | } | 1491 | } |
1350 | 1492 | ||
@@ -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,20 @@ 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.GetWorldPosition() + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
1807 | 1956 | ||
1808 | ParentID = 0; | 1957 | ParentID = 0; |
1809 | ParentPart = null; | 1958 | ParentPart = null; |
1959 | |||
1960 | if (PhysicsActor == null) | ||
1961 | AddToPhysicalScene(false); | ||
1962 | |||
1810 | SendAvatarDataToAllAgents(); | 1963 | SendAvatarDataToAllAgents(); |
1811 | m_requestedSitTargetID = 0; | 1964 | m_requestedSitTargetID = 0; |
1812 | 1965 | ||
@@ -1816,6 +1969,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1816 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1969 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1817 | } | 1970 | } |
1818 | 1971 | ||
1972 | else if (PhysicsActor == null) | ||
1973 | AddToPhysicalScene(false); | ||
1974 | |||
1819 | Animator.TrySetMovementAnimation("STAND"); | 1975 | Animator.TrySetMovementAnimation("STAND"); |
1820 | } | 1976 | } |
1821 | 1977 | ||
@@ -1867,7 +2023,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 | 2023 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1868 | 2024 | ||
1869 | if (PhysicsActor != null) | 2025 | if (PhysicsActor != null) |
1870 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2026 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
1871 | 2027 | ||
1872 | bool canSit = false; | 2028 | bool canSit = false; |
1873 | Vector3 pos = part.AbsolutePosition + offset; | 2029 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -1916,7 +2072,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1916 | forceMouselook = part.GetForceMouselook(); | 2072 | forceMouselook = part.GetForceMouselook(); |
1917 | 2073 | ||
1918 | ControllingClient.SendSitResponse( | 2074 | ControllingClient.SendSitResponse( |
1919 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2075 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1920 | 2076 | ||
1921 | m_requestedSitTargetUUID = targetID; | 2077 | m_requestedSitTargetUUID = targetID; |
1922 | 2078 | ||
@@ -1930,6 +2086,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1930 | 2086 | ||
1931 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2087 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
1932 | { | 2088 | { |
2089 | if (IsChildAgent) | ||
2090 | return; | ||
2091 | |||
1933 | if (ParentID != 0) | 2092 | if (ParentID != 0) |
1934 | { | 2093 | { |
1935 | StandUp(); | 2094 | StandUp(); |
@@ -2207,14 +2366,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2207 | 2366 | ||
2208 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2367 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2209 | 2368 | ||
2210 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2369 | double x, y, z, m; |
2370 | |||
2371 | Quaternion r = sitTargetOrient; | ||
2372 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2373 | |||
2374 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2375 | { | ||
2376 | m = 1.0 / Math.Sqrt(m); | ||
2377 | r.X *= (float)m; | ||
2378 | r.Y *= (float)m; | ||
2379 | r.Z *= (float)m; | ||
2380 | r.W *= (float)m; | ||
2381 | } | ||
2382 | |||
2383 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2384 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2385 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2386 | |||
2387 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2388 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2389 | |||
2390 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2391 | |||
2392 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2211 | Rotation = sitTargetOrient; | 2393 | Rotation = sitTargetOrient; |
2212 | ParentPosition = part.AbsolutePosition; | 2394 | // ParentPosition = part.AbsolutePosition; |
2395 | part.ParentGroup.AddAvatar(UUID); | ||
2213 | } | 2396 | } |
2214 | else | 2397 | else |
2215 | { | 2398 | { |
2216 | m_pos -= part.AbsolutePosition; | 2399 | m_pos -= part.AbsolutePosition; |
2217 | ParentPosition = part.AbsolutePosition; | 2400 | // ParentPosition = part.AbsolutePosition; |
2401 | part.ParentGroup.AddAvatar(UUID); | ||
2218 | 2402 | ||
2219 | // m_log.DebugFormat( | 2403 | // m_log.DebugFormat( |
2220 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2404 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2259,6 +2443,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2259 | Animator.RemoveAnimation(animID); | 2443 | Animator.RemoveAnimation(animID); |
2260 | } | 2444 | } |
2261 | 2445 | ||
2446 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2447 | { | ||
2448 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2449 | } | ||
2450 | |||
2451 | |||
2452 | |||
2262 | /// <summary> | 2453 | /// <summary> |
2263 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2454 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2264 | /// </summary> | 2455 | /// </summary> |
@@ -2312,14 +2503,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2312 | direc.Z *= 2.6f; | 2503 | direc.Z *= 2.6f; |
2313 | 2504 | ||
2314 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2505 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2315 | Animator.TrySetMovementAnimation("PREJUMP"); | 2506 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2316 | Animator.TrySetMovementAnimation("JUMP"); | 2507 | // Animator.TrySetMovementAnimation("JUMP"); |
2317 | } | 2508 | } |
2318 | } | 2509 | } |
2319 | } | 2510 | } |
2320 | 2511 | ||
2321 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2512 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2322 | m_forceToApply = direc; | 2513 | m_forceToApply = direc; |
2514 | Animator.UpdateMovementAnimations(); | ||
2323 | } | 2515 | } |
2324 | 2516 | ||
2325 | #endregion | 2517 | #endregion |
@@ -2712,8 +2904,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2712 | 2904 | ||
2713 | // If we don't have a PhysActor, we can't cross anyway | 2905 | // If we don't have a PhysActor, we can't cross anyway |
2714 | // Also don't do this while sat, sitting avatars cross with the | 2906 | // Also don't do this while sat, sitting avatars cross with the |
2715 | // object they sit on. | 2907 | // object they sit on. ParentUUID denoted a pending sit, don't |
2716 | if (ParentID != 0 || PhysicsActor == null) | 2908 | // interfere with it. |
2909 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2717 | return; | 2910 | return; |
2718 | 2911 | ||
2719 | if (!IsInTransit) | 2912 | if (!IsInTransit) |
@@ -3054,6 +3247,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3054 | cAgent.AlwaysRun = SetAlwaysRun; | 3247 | cAgent.AlwaysRun = SetAlwaysRun; |
3055 | 3248 | ||
3056 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3249 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3250 | |||
3251 | cAgent.ParentPart = ParentUUID; | ||
3252 | cAgent.SitOffset = m_pos; | ||
3057 | 3253 | ||
3058 | lock (scriptedcontrols) | 3254 | lock (scriptedcontrols) |
3059 | { | 3255 | { |
@@ -3062,7 +3258,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3062 | 3258 | ||
3063 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3259 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3064 | { | 3260 | { |
3065 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3261 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3066 | } | 3262 | } |
3067 | cAgent.Controllers = controls; | 3263 | cAgent.Controllers = controls; |
3068 | } | 3264 | } |
@@ -3073,6 +3269,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3073 | cAgent.Anims = Animator.Animations.ToArray(); | 3269 | cAgent.Anims = Animator.Animations.ToArray(); |
3074 | } | 3270 | } |
3075 | catch { } | 3271 | catch { } |
3272 | cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; | ||
3076 | 3273 | ||
3077 | if (Scene.AttachmentsModule != null) | 3274 | if (Scene.AttachmentsModule != null) |
3078 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); | 3275 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); |
@@ -3093,6 +3290,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3093 | CameraAtAxis = cAgent.AtAxis; | 3290 | CameraAtAxis = cAgent.AtAxis; |
3094 | CameraLeftAxis = cAgent.LeftAxis; | 3291 | CameraLeftAxis = cAgent.LeftAxis; |
3095 | CameraUpAxis = cAgent.UpAxis; | 3292 | CameraUpAxis = cAgent.UpAxis; |
3293 | ParentUUID = cAgent.ParentPart; | ||
3294 | m_prevSitOffset = cAgent.SitOffset; | ||
3096 | 3295 | ||
3097 | // When we get to the point of re-computing neighbors everytime this | 3296 | // When we get to the point of re-computing neighbors everytime this |
3098 | // changes, then start using the agent's drawdistance rather than the | 3297 | // changes, then start using the agent's drawdistance rather than the |
@@ -3130,6 +3329,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3130 | foreach (ControllerData c in cAgent.Controllers) | 3329 | foreach (ControllerData c in cAgent.Controllers) |
3131 | { | 3330 | { |
3132 | ScriptControllers sc = new ScriptControllers(); | 3331 | ScriptControllers sc = new ScriptControllers(); |
3332 | sc.objectID = c.ObjectID; | ||
3133 | sc.itemID = c.ItemID; | 3333 | sc.itemID = c.ItemID; |
3134 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3334 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3135 | sc.eventControls = (ScriptControlled)c.EventControls; | 3335 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3144,6 +3344,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3144 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? | 3344 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? |
3145 | if (cAgent.Anims != null) | 3345 | if (cAgent.Anims != null) |
3146 | Animator.Animations.FromArray(cAgent.Anims); | 3346 | Animator.Animations.FromArray(cAgent.Anims); |
3347 | if (cAgent.DefaultAnim != null) | ||
3348 | Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); | ||
3147 | 3349 | ||
3148 | if (Scene.AttachmentsModule != null) | 3350 | if (Scene.AttachmentsModule != null) |
3149 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); | 3351 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); |
@@ -3206,7 +3408,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3206 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3408 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3207 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3409 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3208 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3410 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3209 | PhysicsActor.SubscribeEvents(500); | 3411 | PhysicsActor.SubscribeEvents(100); |
3210 | PhysicsActor.LocalID = LocalId; | 3412 | PhysicsActor.LocalID = LocalId; |
3211 | } | 3413 | } |
3212 | 3414 | ||
@@ -3236,18 +3438,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3236 | if (IsChildAgent) | 3438 | if (IsChildAgent) |
3237 | return; | 3439 | return; |
3238 | 3440 | ||
3239 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | ||
3240 | // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( | ||
3241 | // as of this comment the interval is set in AddToPhysicalScene | ||
3242 | if (Animator != null) | ||
3243 | { | ||
3244 | // if (m_updateCount > 0) | ||
3245 | // { | ||
3246 | Animator.UpdateMovementAnimations(); | ||
3247 | // m_updateCount--; | ||
3248 | // } | ||
3249 | } | ||
3250 | |||
3251 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3441 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3252 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3442 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3253 | 3443 | ||
@@ -3290,6 +3480,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3290 | } | 3480 | } |
3291 | } | 3481 | } |
3292 | 3482 | ||
3483 | RaiseCollisionScriptEvents(coldata); | ||
3484 | |||
3293 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3485 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3294 | if (Invulnerable || GodLevel > 0) | 3486 | if (Invulnerable || GodLevel > 0) |
3295 | return; | 3487 | return; |
@@ -3387,7 +3579,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3387 | // m_reprioritizationTimer.Dispose(); | 3579 | // m_reprioritizationTimer.Dispose(); |
3388 | 3580 | ||
3389 | RemoveFromPhysicalScene(); | 3581 | RemoveFromPhysicalScene(); |
3390 | Animator.Close(); | 3582 | if(Animator != null) |
3583 | Animator.Close(); | ||
3391 | Animator = null; | 3584 | Animator = null; |
3392 | } | 3585 | } |
3393 | 3586 | ||
@@ -3619,10 +3812,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3619 | 3812 | ||
3620 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 3813 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3621 | { | 3814 | { |
3815 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
3816 | if (p == null) | ||
3817 | return; | ||
3818 | |||
3622 | ScriptControllers obj = new ScriptControllers(); | 3819 | ScriptControllers obj = new ScriptControllers(); |
3623 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 3820 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3624 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 3821 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3625 | 3822 | ||
3823 | obj.objectID = p.ParentGroup.UUID; | ||
3626 | obj.itemID = Script_item_UUID; | 3824 | obj.itemID = Script_item_UUID; |
3627 | if (pass_on == 0 && accept == 0) | 3825 | if (pass_on == 0 && accept == 0) |
3628 | { | 3826 | { |
@@ -3671,6 +3869,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3671 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 3869 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3672 | } | 3870 | } |
3673 | 3871 | ||
3872 | private void UnRegisterSeatControls(UUID obj) | ||
3873 | { | ||
3874 | List<UUID> takers = new List<UUID>(); | ||
3875 | |||
3876 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
3877 | { | ||
3878 | if (c.objectID == obj) | ||
3879 | takers.Add(c.itemID); | ||
3880 | } | ||
3881 | foreach (UUID t in takers) | ||
3882 | { | ||
3883 | UnRegisterControlEventsToScript(0, t); | ||
3884 | } | ||
3885 | } | ||
3886 | |||
3674 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3887 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3675 | { | 3888 | { |
3676 | ScriptControllers takecontrols; | 3889 | ScriptControllers takecontrols; |
@@ -3989,6 +4202,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3989 | 4202 | ||
3990 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4203 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3991 | { | 4204 | { |
4205 | string reason; | ||
4206 | |||
4207 | // Honor bans | ||
4208 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4209 | return; | ||
4210 | |||
3992 | SceneObjectGroup telehub = null; | 4211 | SceneObjectGroup telehub = null; |
3993 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4212 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
3994 | { | 4213 | { |
@@ -4028,11 +4247,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4028 | pos = land.LandData.UserLocation; | 4247 | pos = land.LandData.UserLocation; |
4029 | } | 4248 | } |
4030 | } | 4249 | } |
4031 | 4250 | ||
4032 | land.SendLandUpdateToClient(ControllingClient); | 4251 | land.SendLandUpdateToClient(ControllingClient); |
4033 | } | 4252 | } |
4034 | } | 4253 | } |
4035 | 4254 | ||
4255 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4256 | { | ||
4257 | DetectedObject detobj = new DetectedObject(); | ||
4258 | detobj.keyUUID = obj.UUID; | ||
4259 | detobj.nameStr = obj.Name; | ||
4260 | detobj.ownerUUID = obj.OwnerID; | ||
4261 | detobj.posVector = obj.AbsolutePosition; | ||
4262 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4263 | detobj.velVector = obj.Velocity; | ||
4264 | detobj.colliderType = 0; | ||
4265 | detobj.groupUUID = obj.GroupID; | ||
4266 | |||
4267 | return detobj; | ||
4268 | } | ||
4269 | |||
4270 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4271 | { | ||
4272 | DetectedObject detobj = new DetectedObject(); | ||
4273 | detobj.keyUUID = av.UUID; | ||
4274 | detobj.nameStr = av.ControllingClient.Name; | ||
4275 | detobj.ownerUUID = av.UUID; | ||
4276 | detobj.posVector = av.AbsolutePosition; | ||
4277 | detobj.rotQuat = av.Rotation; | ||
4278 | detobj.velVector = av.Velocity; | ||
4279 | detobj.colliderType = 0; | ||
4280 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4281 | |||
4282 | return detobj; | ||
4283 | } | ||
4284 | |||
4285 | private DetectedObject CreateDetObjectForGround() | ||
4286 | { | ||
4287 | DetectedObject detobj = new DetectedObject(); | ||
4288 | detobj.keyUUID = UUID.Zero; | ||
4289 | detobj.nameStr = ""; | ||
4290 | detobj.ownerUUID = UUID.Zero; | ||
4291 | detobj.posVector = AbsolutePosition; | ||
4292 | detobj.rotQuat = Quaternion.Identity; | ||
4293 | detobj.velVector = Vector3.Zero; | ||
4294 | detobj.colliderType = 0; | ||
4295 | detobj.groupUUID = UUID.Zero; | ||
4296 | |||
4297 | return detobj; | ||
4298 | } | ||
4299 | |||
4300 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4301 | { | ||
4302 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4303 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4304 | foreach (uint localId in colliders) | ||
4305 | { | ||
4306 | if (localId == 0) | ||
4307 | continue; | ||
4308 | |||
4309 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4310 | if (obj != null) | ||
4311 | { | ||
4312 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4313 | colliding.Add(CreateDetObject(obj)); | ||
4314 | } | ||
4315 | else | ||
4316 | { | ||
4317 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4318 | if (av != null && (!av.IsChildAgent)) | ||
4319 | { | ||
4320 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4321 | colliding.Add(CreateDetObject(av)); | ||
4322 | } | ||
4323 | } | ||
4324 | } | ||
4325 | |||
4326 | colliderArgs.Colliders = colliding; | ||
4327 | |||
4328 | return colliderArgs; | ||
4329 | } | ||
4330 | |||
4331 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4332 | |||
4333 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4334 | { | ||
4335 | ColliderArgs CollidingMessage; | ||
4336 | |||
4337 | if (colliders.Count > 0) | ||
4338 | { | ||
4339 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4340 | { | ||
4341 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4342 | |||
4343 | if (CollidingMessage.Colliders.Count > 0) | ||
4344 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4345 | } | ||
4346 | } | ||
4347 | } | ||
4348 | |||
4349 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4350 | { | ||
4351 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4352 | { | ||
4353 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4354 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4355 | |||
4356 | colliding.Add(CreateDetObjectForGround()); | ||
4357 | LandCollidingMessage.Colliders = colliding; | ||
4358 | |||
4359 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4360 | } | ||
4361 | } | ||
4362 | |||
4363 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4364 | { | ||
4365 | try | ||
4366 | { | ||
4367 | List<uint> thisHitColliders = new List<uint>(); | ||
4368 | List<uint> endedColliders = new List<uint>(); | ||
4369 | List<uint> startedColliders = new List<uint>(); | ||
4370 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4371 | CollisionForSoundInfo soundinfo; | ||
4372 | ContactPoint curcontact; | ||
4373 | |||
4374 | if (coldata.Count == 0) | ||
4375 | { | ||
4376 | if (m_lastColliders.Count == 0) | ||
4377 | return; // nothing to do | ||
4378 | |||
4379 | foreach (uint localID in m_lastColliders) | ||
4380 | { | ||
4381 | endedColliders.Add(localID); | ||
4382 | } | ||
4383 | m_lastColliders.Clear(); | ||
4384 | } | ||
4385 | |||
4386 | else | ||
4387 | { | ||
4388 | foreach (uint id in coldata.Keys) | ||
4389 | { | ||
4390 | thisHitColliders.Add(id); | ||
4391 | if (!m_lastColliders.Contains(id)) | ||
4392 | { | ||
4393 | startedColliders.Add(id); | ||
4394 | curcontact = coldata[id]; | ||
4395 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4396 | { | ||
4397 | soundinfo = new CollisionForSoundInfo(); | ||
4398 | soundinfo.colliderID = id; | ||
4399 | soundinfo.position = curcontact.Position; | ||
4400 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4401 | soundinfolist.Add(soundinfo); | ||
4402 | } | ||
4403 | } | ||
4404 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4405 | } | ||
4406 | |||
4407 | // calculate things that ended colliding | ||
4408 | foreach (uint localID in m_lastColliders) | ||
4409 | { | ||
4410 | if (!thisHitColliders.Contains(localID)) | ||
4411 | { | ||
4412 | endedColliders.Add(localID); | ||
4413 | } | ||
4414 | } | ||
4415 | //add the items that started colliding this time to the last colliders list. | ||
4416 | foreach (uint localID in startedColliders) | ||
4417 | { | ||
4418 | m_lastColliders.Add(localID); | ||
4419 | } | ||
4420 | // remove things that ended colliding from the last colliders list | ||
4421 | foreach (uint localID in endedColliders) | ||
4422 | { | ||
4423 | m_lastColliders.Remove(localID); | ||
4424 | } | ||
4425 | |||
4426 | if (soundinfolist.Count > 0) | ||
4427 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4428 | } | ||
4429 | |||
4430 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4431 | { | ||
4432 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4433 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4434 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4435 | |||
4436 | if (startedColliders.Contains(0)) | ||
4437 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4438 | if (m_lastColliders.Contains(0)) | ||
4439 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4440 | if (endedColliders.Contains(0)) | ||
4441 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4442 | } | ||
4443 | } | ||
4444 | finally | ||
4445 | { | ||
4446 | m_collisionEventFlag = false; | ||
4447 | } | ||
4448 | } | ||
4449 | |||
4036 | private void TeleportFlagsDebug() { | 4450 | private void TeleportFlagsDebug() { |
4037 | 4451 | ||
4038 | // Some temporary debugging help to show all the TeleportFlags we have... | 4452 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4057,6 +4471,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4057 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4471 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4058 | 4472 | ||
4059 | } | 4473 | } |
4060 | |||
4061 | } | 4474 | } |
4062 | } | 4475 | } |