diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 562 |
1 files changed, 482 insertions, 80 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 029e0d7..e83696b 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 |
@@ -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 | /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. | 597 | /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. |
582 | /// </summary> | 598 | /// </summary> |
@@ -737,6 +753,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
737 | Appearance = appearance; | 753 | Appearance = appearance; |
738 | } | 754 | } |
739 | 755 | ||
756 | private void RegionHeartbeatEnd(Scene scene) | ||
757 | { | ||
758 | if (IsChildAgent) | ||
759 | return; | ||
760 | |||
761 | m_movementAnimationUpdateCounter ++; | ||
762 | if (m_movementAnimationUpdateCounter >= 2) | ||
763 | { | ||
764 | m_movementAnimationUpdateCounter = 0; | ||
765 | if (Animator != null) | ||
766 | { | ||
767 | // If the parentID == 0 we are not sitting | ||
768 | // if !SitGournd then we are not sitting on the ground | ||
769 | // Fairly straightforward, now here comes the twist | ||
770 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
771 | // be sat on an object that isn't there yet. Should | ||
772 | // be treated as if sat. | ||
773 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
774 | Animator.UpdateMovementAnimations(); | ||
775 | } | ||
776 | else | ||
777 | { | ||
778 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
779 | } | ||
780 | } | ||
781 | } | ||
782 | |||
740 | public void RegisterToEvents() | 783 | public void RegisterToEvents() |
741 | { | 784 | { |
742 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 785 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -746,6 +789,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
746 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 789 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
747 | ControllingClient.OnStartAnim += HandleStartAnim; | 790 | ControllingClient.OnStartAnim += HandleStartAnim; |
748 | ControllingClient.OnStopAnim += HandleStopAnim; | 791 | ControllingClient.OnStopAnim += HandleStopAnim; |
792 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
749 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 793 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
750 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 794 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
751 | 795 | ||
@@ -806,10 +850,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
806 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 850 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
807 | Name, m_scene.RegionInfo.RegionName); | 851 | Name, m_scene.RegionInfo.RegionName); |
808 | 852 | ||
809 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
810 | |||
811 | bool wasChild = IsChildAgent; | 853 | bool wasChild = IsChildAgent; |
812 | IsChildAgent = false; | 854 | |
855 | if (ParentUUID != UUID.Zero) | ||
856 | { | ||
857 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
858 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
859 | if (part == null) | ||
860 | { | ||
861 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
862 | } | ||
863 | else | ||
864 | { | ||
865 | part.ParentGroup.AddAvatar(UUID); | ||
866 | if (part.SitTargetPosition != Vector3.Zero) | ||
867 | part.SitTargetAvatar = UUID; | ||
868 | ParentPosition = part.GetWorldPosition(); | ||
869 | ParentID = part.LocalId; | ||
870 | ParentPart = part; | ||
871 | m_pos = m_prevSitOffset; | ||
872 | pos = ParentPosition; | ||
873 | } | ||
874 | ParentUUID = UUID.Zero; | ||
875 | |||
876 | IsChildAgent = false; | ||
877 | |||
878 | // Animator.TrySetMovementAnimation("SIT"); | ||
879 | } | ||
880 | else | ||
881 | { | ||
882 | IsChildAgent = false; | ||
883 | } | ||
884 | |||
813 | 885 | ||
814 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 886 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
815 | if (gm != null) | 887 | if (gm != null) |
@@ -819,62 +891,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
819 | 891 | ||
820 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 892 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
821 | 893 | ||
822 | // Moved this from SendInitialData to ensure that Appearance is initialized | 894 | if (ParentID == 0) |
823 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | ||
824 | // related to the handling of attachments | ||
825 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
826 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
827 | { | 895 | { |
828 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 896 | // Moved this from SendInitialData to ensure that Appearance is initialized |
829 | pos.X = crossedBorder.BorderLine.Z - 1; | 897 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
830 | } | 898 | // related to the handling of attachments |
899 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
900 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
901 | { | ||
902 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
903 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
904 | } | ||
831 | 905 | ||
832 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 906 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
833 | { | 907 | { |
834 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 908 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
835 | pos.Y = crossedBorder.BorderLine.Z - 1; | 909 | pos.Y = crossedBorder.BorderLine.Z - 1; |
836 | } | 910 | } |
837 | 911 | ||
838 | CheckAndAdjustLandingPoint(ref pos); | 912 | CheckAndAdjustLandingPoint(ref pos); |
839 | 913 | ||
840 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 914 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
841 | { | 915 | { |
842 | m_log.WarnFormat( | 916 | m_log.WarnFormat( |
843 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 917 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
844 | pos, Name, UUID); | 918 | pos, Name, UUID); |
845 | 919 | ||
846 | if (pos.X < 0f) pos.X = 0f; | 920 | if (pos.X < 0f) pos.X = 0f; |
847 | if (pos.Y < 0f) pos.Y = 0f; | 921 | if (pos.Y < 0f) pos.Y = 0f; |
848 | if (pos.Z < 0f) pos.Z = 0f; | 922 | if (pos.Z < 0f) pos.Z = 0f; |
849 | } | 923 | } |
850 | 924 | ||
851 | float localAVHeight = 1.56f; | 925 | float localAVHeight = 1.56f; |
852 | if (Appearance.AvatarHeight > 0) | 926 | if (Appearance.AvatarHeight > 0) |
853 | localAVHeight = Appearance.AvatarHeight; | 927 | localAVHeight = Appearance.AvatarHeight; |
854 | 928 | ||
855 | float posZLimit = 0; | 929 | float posZLimit = 0; |
856 | 930 | ||
857 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 931 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
858 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 932 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
859 | 933 | ||
860 | float newPosZ = posZLimit + localAVHeight / 2; | 934 | float newPosZ = posZLimit + localAVHeight / 2; |
861 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 935 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
862 | { | 936 | { |
863 | pos.Z = newPosZ; | 937 | pos.Z = newPosZ; |
864 | } | 938 | } |
865 | AbsolutePosition = pos; | 939 | AbsolutePosition = pos; |
866 | 940 | ||
867 | AddToPhysicalScene(isFlying); | 941 | if (m_teleportFlags == TeleportFlags.Default) |
942 | { | ||
943 | Vector3 vel = Velocity; | ||
944 | AddToPhysicalScene(isFlying); | ||
945 | if (PhysicsActor != null) | ||
946 | PhysicsActor.SetMomentum(vel); | ||
947 | } | ||
948 | else | ||
949 | AddToPhysicalScene(isFlying); | ||
868 | 950 | ||
869 | if (ForceFly) | 951 | if (ForceFly) |
870 | { | 952 | { |
871 | Flying = true; | 953 | Flying = true; |
872 | } | 954 | } |
873 | else if (FlyDisabled) | 955 | else if (FlyDisabled) |
874 | { | 956 | { |
875 | Flying = false; | 957 | Flying = false; |
958 | } | ||
876 | } | 959 | } |
877 | |||
878 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 960 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
879 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 961 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
880 | // elsewhere anyway | 962 | // elsewhere anyway |
@@ -892,14 +974,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
892 | { | 974 | { |
893 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); | 975 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); |
894 | // Resume scripts | 976 | // Resume scripts |
895 | foreach (SceneObjectGroup sog in m_attachments) | 977 | Util.FireAndForget(delegate(object x) { |
896 | { | 978 | foreach (SceneObjectGroup sog in m_attachments) |
897 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 979 | { |
898 | sog.ResumeScripts(); | 980 | sog.ScheduleGroupForFullUpdate(); |
899 | } | 981 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
982 | sog.ResumeScripts(); | ||
983 | } | ||
984 | }); | ||
900 | } | 985 | } |
901 | } | 986 | } |
902 | 987 | ||
988 | SendAvatarDataToAllAgents(); | ||
989 | |||
903 | // send the animations of the other presences to me | 990 | // send the animations of the other presences to me |
904 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 991 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
905 | { | 992 | { |
@@ -910,9 +997,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
910 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 997 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
911 | // stall on the border crossing since the existing child agent will still have the last movement | 998 | // stall on the border crossing since the existing child agent will still have the last movement |
912 | // recorded, which stops the input from being processed. | 999 | // recorded, which stops the input from being processed. |
1000 | |||
913 | MovementFlag = 0; | 1001 | MovementFlag = 0; |
914 | 1002 | ||
915 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1003 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1004 | |||
1005 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
916 | } | 1006 | } |
917 | 1007 | ||
918 | public int GetStateSource() | 1008 | public int GetStateSource() |
@@ -940,12 +1030,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
940 | /// </remarks> | 1030 | /// </remarks> |
941 | public void MakeChildAgent() | 1031 | public void MakeChildAgent() |
942 | { | 1032 | { |
1033 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1034 | |||
943 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1035 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
944 | 1036 | ||
945 | // Reset these so that teleporting in and walking out isn't seen | 1037 | // Reset these so that teleporting in and walking out isn't seen |
946 | // as teleporting back | 1038 | // as teleporting back |
947 | TeleportFlags = TeleportFlags.Default; | 1039 | TeleportFlags = TeleportFlags.Default; |
948 | 1040 | ||
1041 | MovementFlag = 0; | ||
1042 | |||
949 | // It looks like Animator is set to null somewhere, and MakeChild | 1043 | // It looks like Animator is set to null somewhere, and MakeChild |
950 | // is called after that. Probably in aborted teleports. | 1044 | // is called after that. Probably in aborted teleports. |
951 | if (Animator == null) | 1045 | if (Animator == null) |
@@ -953,6 +1047,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
953 | else | 1047 | else |
954 | Animator.ResetAnimations(); | 1048 | Animator.ResetAnimations(); |
955 | 1049 | ||
1050 | |||
956 | // m_log.DebugFormat( | 1051 | // m_log.DebugFormat( |
957 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1052 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
958 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1053 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -979,9 +1074,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
979 | { | 1074 | { |
980 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1075 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
981 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1076 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
982 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
983 | PhysicsActor.UnSubscribeEvents(); | ||
984 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1077 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1078 | PhysicsActor.UnSubscribeEvents(); | ||
1079 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
985 | PhysicsActor = null; | 1080 | PhysicsActor = null; |
986 | } | 1081 | } |
987 | // else | 1082 | // else |
@@ -998,7 +1093,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
998 | /// <param name="pos"></param> | 1093 | /// <param name="pos"></param> |
999 | public void Teleport(Vector3 pos) | 1094 | public void Teleport(Vector3 pos) |
1000 | { | 1095 | { |
1001 | TeleportWithMomentum(pos, null); | 1096 | TeleportWithMomentum(pos, Vector3.Zero); |
1002 | } | 1097 | } |
1003 | 1098 | ||
1004 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1099 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1022,6 +1117,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1022 | SendTerseUpdateToAllClients(); | 1117 | SendTerseUpdateToAllClients(); |
1023 | } | 1118 | } |
1024 | 1119 | ||
1120 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1121 | { | ||
1122 | CheckLandingPoint(ref newpos); | ||
1123 | AbsolutePosition = newpos; | ||
1124 | |||
1125 | if (newvel.HasValue) | ||
1126 | { | ||
1127 | if ((Vector3)newvel == Vector3.Zero) | ||
1128 | { | ||
1129 | if (PhysicsActor != null) | ||
1130 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1131 | m_velocity = Vector3.Zero; | ||
1132 | } | ||
1133 | else | ||
1134 | { | ||
1135 | if (PhysicsActor != null) | ||
1136 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1137 | m_velocity = (Vector3)newvel; | ||
1138 | |||
1139 | if (rotateToVelXY) | ||
1140 | { | ||
1141 | Vector3 lookAt = (Vector3)newvel; | ||
1142 | lookAt.Z = 0; | ||
1143 | lookAt.Normalize(); | ||
1144 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1145 | return; | ||
1146 | } | ||
1147 | } | ||
1148 | } | ||
1149 | |||
1150 | SendTerseUpdateToAllClients(); | ||
1151 | } | ||
1152 | |||
1153 | |||
1154 | |||
1025 | public void StopFlying() | 1155 | public void StopFlying() |
1026 | { | 1156 | { |
1027 | ControllingClient.StopFlying(this); | 1157 | ControllingClient.StopFlying(this); |
@@ -1337,8 +1467,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1337 | { | 1467 | { |
1338 | if (m_followCamAuto) | 1468 | if (m_followCamAuto) |
1339 | { | 1469 | { |
1340 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1470 | // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1341 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1471 | // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); |
1472 | |||
1473 | Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; | ||
1474 | Vector3 distTocam = CameraPosition - posAdjusted; | ||
1475 | float distTocamlen = distTocam.Length(); | ||
1476 | if (distTocamlen > 0) | ||
1477 | { | ||
1478 | distTocam *= 1.0f / distTocamlen; | ||
1479 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); | ||
1480 | } | ||
1481 | |||
1342 | } | 1482 | } |
1343 | } | 1483 | } |
1344 | 1484 | ||
@@ -1772,12 +1912,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1772 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1912 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1773 | 1913 | ||
1774 | SitGround = false; | 1914 | SitGround = false; |
1915 | |||
1916 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1775 | if (PhysicsActor == null) | 1917 | if (PhysicsActor == null) |
1776 | AddToPhysicalScene(false); | 1918 | AddToPhysicalScene(false); |
1919 | */ | ||
1777 | 1920 | ||
1778 | if (ParentID != 0) | 1921 | if (ParentID != 0) |
1779 | { | 1922 | { |
1780 | SceneObjectPart part = ParentPart; | 1923 | SceneObjectPart part = ParentPart; |
1924 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
1925 | |||
1781 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1926 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1782 | if (taskIDict != null) | 1927 | if (taskIDict != null) |
1783 | { | 1928 | { |
@@ -1797,6 +1942,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1797 | if (part.SitTargetAvatar == UUID) | 1942 | if (part.SitTargetAvatar == UUID) |
1798 | part.SitTargetAvatar = UUID.Zero; | 1943 | part.SitTargetAvatar = UUID.Zero; |
1799 | 1944 | ||
1945 | part.ParentGroup.DeleteAvatar(UUID); | ||
1800 | ParentPosition = part.GetWorldPosition(); | 1946 | ParentPosition = part.GetWorldPosition(); |
1801 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1947 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1802 | 1948 | ||
@@ -1805,6 +1951,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1805 | 1951 | ||
1806 | ParentID = 0; | 1952 | ParentID = 0; |
1807 | ParentPart = null; | 1953 | ParentPart = null; |
1954 | |||
1955 | if (PhysicsActor == null) | ||
1956 | AddToPhysicalScene(false); | ||
1957 | |||
1808 | SendAvatarDataToAllAgents(); | 1958 | SendAvatarDataToAllAgents(); |
1809 | m_requestedSitTargetID = 0; | 1959 | m_requestedSitTargetID = 0; |
1810 | 1960 | ||
@@ -1812,6 +1962,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1812 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1962 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1813 | } | 1963 | } |
1814 | 1964 | ||
1965 | else if (PhysicsActor == null) | ||
1966 | AddToPhysicalScene(false); | ||
1967 | |||
1815 | Animator.TrySetMovementAnimation("STAND"); | 1968 | Animator.TrySetMovementAnimation("STAND"); |
1816 | } | 1969 | } |
1817 | 1970 | ||
@@ -1890,7 +2043,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1890 | // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); | 2043 | // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); |
1891 | 2044 | ||
1892 | if (PhysicsActor != null) | 2045 | if (PhysicsActor != null) |
1893 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2046 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
1894 | 2047 | ||
1895 | bool canSit = false; | 2048 | bool canSit = false; |
1896 | pos = part.AbsolutePosition + offset; | 2049 | pos = part.AbsolutePosition + offset; |
@@ -1935,7 +2088,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1935 | forceMouselook = part.GetForceMouselook(); | 2088 | forceMouselook = part.GetForceMouselook(); |
1936 | 2089 | ||
1937 | ControllingClient.SendSitResponse( | 2090 | ControllingClient.SendSitResponse( |
1938 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2091 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1939 | 2092 | ||
1940 | m_requestedSitTargetUUID = targetID; | 2093 | m_requestedSitTargetUUID = targetID; |
1941 | 2094 | ||
@@ -2217,14 +2370,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
2217 | 2370 | ||
2218 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2371 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2219 | 2372 | ||
2220 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2373 | double x, y, z, m; |
2374 | |||
2375 | Quaternion r = sitTargetOrient; | ||
2376 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2377 | |||
2378 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2379 | { | ||
2380 | m = 1.0 / Math.Sqrt(m); | ||
2381 | r.X *= (float)m; | ||
2382 | r.Y *= (float)m; | ||
2383 | r.Z *= (float)m; | ||
2384 | r.W *= (float)m; | ||
2385 | } | ||
2386 | |||
2387 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2388 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2389 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2390 | |||
2391 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2392 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2393 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2221 | Rotation = sitTargetOrient; | 2394 | Rotation = sitTargetOrient; |
2222 | ParentPosition = part.AbsolutePosition; | 2395 | ParentPosition = part.AbsolutePosition; |
2396 | part.ParentGroup.AddAvatar(UUID); | ||
2223 | } | 2397 | } |
2224 | else | 2398 | else |
2225 | { | 2399 | { |
2226 | m_pos -= part.AbsolutePosition; | 2400 | m_pos -= part.AbsolutePosition; |
2227 | ParentPosition = part.AbsolutePosition; | 2401 | ParentPosition = part.AbsolutePosition; |
2402 | part.ParentGroup.AddAvatar(UUID); | ||
2228 | 2403 | ||
2229 | // m_log.DebugFormat( | 2404 | // m_log.DebugFormat( |
2230 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2405 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2269,6 +2444,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2269 | Animator.RemoveAnimation(animID); | 2444 | Animator.RemoveAnimation(animID); |
2270 | } | 2445 | } |
2271 | 2446 | ||
2447 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2448 | { | ||
2449 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2450 | } | ||
2451 | |||
2452 | |||
2453 | |||
2272 | /// <summary> | 2454 | /// <summary> |
2273 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2455 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2274 | /// </summary> | 2456 | /// </summary> |
@@ -2322,14 +2504,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2322 | direc.Z *= 2.6f; | 2504 | direc.Z *= 2.6f; |
2323 | 2505 | ||
2324 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2506 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2325 | Animator.TrySetMovementAnimation("PREJUMP"); | 2507 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2326 | Animator.TrySetMovementAnimation("JUMP"); | 2508 | // Animator.TrySetMovementAnimation("JUMP"); |
2327 | } | 2509 | } |
2328 | } | 2510 | } |
2329 | } | 2511 | } |
2330 | 2512 | ||
2331 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2513 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2332 | m_forceToApply = direc; | 2514 | m_forceToApply = direc; |
2515 | Animator.UpdateMovementAnimations(); | ||
2333 | } | 2516 | } |
2334 | 2517 | ||
2335 | #endregion | 2518 | #endregion |
@@ -3064,6 +3247,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3064 | cAgent.AlwaysRun = SetAlwaysRun; | 3247 | cAgent.AlwaysRun = SetAlwaysRun; |
3065 | 3248 | ||
3066 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3249 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3250 | |||
3251 | cAgent.ParentPart = ParentUUID; | ||
3252 | cAgent.SitOffset = m_pos; | ||
3067 | 3253 | ||
3068 | lock (scriptedcontrols) | 3254 | lock (scriptedcontrols) |
3069 | { | 3255 | { |
@@ -3072,7 +3258,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3072 | 3258 | ||
3073 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3259 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3074 | { | 3260 | { |
3075 | 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); |
3076 | } | 3262 | } |
3077 | cAgent.Controllers = controls; | 3263 | cAgent.Controllers = controls; |
3078 | } | 3264 | } |
@@ -3083,6 +3269,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3083 | cAgent.Anims = Animator.Animations.ToArray(); | 3269 | cAgent.Anims = Animator.Animations.ToArray(); |
3084 | } | 3270 | } |
3085 | catch { } | 3271 | catch { } |
3272 | cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; | ||
3086 | 3273 | ||
3087 | // Attachment objects | 3274 | // Attachment objects |
3088 | List<SceneObjectGroup> attachments = GetAttachments(); | 3275 | List<SceneObjectGroup> attachments = GetAttachments(); |
@@ -3126,6 +3313,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3126 | CameraAtAxis = cAgent.AtAxis; | 3313 | CameraAtAxis = cAgent.AtAxis; |
3127 | CameraLeftAxis = cAgent.LeftAxis; | 3314 | CameraLeftAxis = cAgent.LeftAxis; |
3128 | CameraUpAxis = cAgent.UpAxis; | 3315 | CameraUpAxis = cAgent.UpAxis; |
3316 | ParentUUID = cAgent.ParentPart; | ||
3317 | m_prevSitOffset = cAgent.SitOffset; | ||
3129 | 3318 | ||
3130 | // When we get to the point of re-computing neighbors everytime this | 3319 | // When we get to the point of re-computing neighbors everytime this |
3131 | // changes, then start using the agent's drawdistance rather than the | 3320 | // changes, then start using the agent's drawdistance rather than the |
@@ -3163,6 +3352,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3163 | foreach (ControllerData c in cAgent.Controllers) | 3352 | foreach (ControllerData c in cAgent.Controllers) |
3164 | { | 3353 | { |
3165 | ScriptControllers sc = new ScriptControllers(); | 3354 | ScriptControllers sc = new ScriptControllers(); |
3355 | sc.objectID = c.ObjectID; | ||
3166 | sc.itemID = c.ItemID; | 3356 | sc.itemID = c.ItemID; |
3167 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3357 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3168 | sc.eventControls = (ScriptControlled)c.EventControls; | 3358 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3177,6 +3367,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3177 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? | 3367 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? |
3178 | if (cAgent.Anims != null) | 3368 | if (cAgent.Anims != null) |
3179 | Animator.Animations.FromArray(cAgent.Anims); | 3369 | Animator.Animations.FromArray(cAgent.Anims); |
3370 | if (cAgent.DefaultAnim != null) | ||
3371 | Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); | ||
3180 | 3372 | ||
3181 | if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) | 3373 | if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) |
3182 | { | 3374 | { |
@@ -3249,7 +3441,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3249 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3441 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3250 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3442 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3251 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3443 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3252 | PhysicsActor.SubscribeEvents(500); | 3444 | PhysicsActor.SubscribeEvents(100); |
3253 | PhysicsActor.LocalID = LocalId; | 3445 | PhysicsActor.LocalID = LocalId; |
3254 | } | 3446 | } |
3255 | 3447 | ||
@@ -3279,18 +3471,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3279 | if (IsChildAgent) | 3471 | if (IsChildAgent) |
3280 | return; | 3472 | return; |
3281 | 3473 | ||
3282 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | ||
3283 | // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( | ||
3284 | // as of this comment the interval is set in AddToPhysicalScene | ||
3285 | if (Animator != null) | ||
3286 | { | ||
3287 | // if (m_updateCount > 0) | ||
3288 | // { | ||
3289 | Animator.UpdateMovementAnimations(); | ||
3290 | // m_updateCount--; | ||
3291 | // } | ||
3292 | } | ||
3293 | |||
3294 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3474 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3295 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3475 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3296 | 3476 | ||
@@ -3333,6 +3513,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3333 | } | 3513 | } |
3334 | } | 3514 | } |
3335 | 3515 | ||
3516 | RaiseCollisionScriptEvents(coldata); | ||
3517 | |||
3336 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3518 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3337 | if (Invulnerable || GodLevel > 0) | 3519 | if (Invulnerable || GodLevel > 0) |
3338 | return; | 3520 | return; |
@@ -3665,10 +3847,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3665 | 3847 | ||
3666 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 3848 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3667 | { | 3849 | { |
3850 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
3851 | if (p == null) | ||
3852 | return; | ||
3853 | |||
3668 | ScriptControllers obj = new ScriptControllers(); | 3854 | ScriptControllers obj = new ScriptControllers(); |
3669 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 3855 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3670 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 3856 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3671 | 3857 | ||
3858 | obj.objectID = p.ParentGroup.UUID; | ||
3672 | obj.itemID = Script_item_UUID; | 3859 | obj.itemID = Script_item_UUID; |
3673 | if (pass_on == 0 && accept == 0) | 3860 | if (pass_on == 0 && accept == 0) |
3674 | { | 3861 | { |
@@ -3717,6 +3904,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3717 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 3904 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3718 | } | 3905 | } |
3719 | 3906 | ||
3907 | private void UnRegisterSeatControls(UUID obj) | ||
3908 | { | ||
3909 | List<UUID> takers = new List<UUID>(); | ||
3910 | |||
3911 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
3912 | { | ||
3913 | if (c.objectID == obj) | ||
3914 | takers.Add(c.itemID); | ||
3915 | } | ||
3916 | foreach (UUID t in takers) | ||
3917 | { | ||
3918 | UnRegisterControlEventsToScript(0, t); | ||
3919 | } | ||
3920 | } | ||
3921 | |||
3720 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3922 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3721 | { | 3923 | { |
3722 | ScriptControllers takecontrols; | 3924 | ScriptControllers takecontrols; |
@@ -4035,6 +4237,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4035 | 4237 | ||
4036 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4238 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4037 | { | 4239 | { |
4240 | string reason; | ||
4241 | |||
4242 | // Honor bans | ||
4243 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4244 | return; | ||
4245 | |||
4038 | SceneObjectGroup telehub = null; | 4246 | SceneObjectGroup telehub = null; |
4039 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4247 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4040 | { | 4248 | { |
@@ -4074,11 +4282,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4074 | pos = land.LandData.UserLocation; | 4282 | pos = land.LandData.UserLocation; |
4075 | } | 4283 | } |
4076 | } | 4284 | } |
4077 | 4285 | ||
4078 | land.SendLandUpdateToClient(ControllingClient); | 4286 | land.SendLandUpdateToClient(ControllingClient); |
4079 | } | 4287 | } |
4080 | } | 4288 | } |
4081 | 4289 | ||
4290 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4291 | { | ||
4292 | DetectedObject detobj = new DetectedObject(); | ||
4293 | detobj.keyUUID = obj.UUID; | ||
4294 | detobj.nameStr = obj.Name; | ||
4295 | detobj.ownerUUID = obj.OwnerID; | ||
4296 | detobj.posVector = obj.AbsolutePosition; | ||
4297 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4298 | detobj.velVector = obj.Velocity; | ||
4299 | detobj.colliderType = 0; | ||
4300 | detobj.groupUUID = obj.GroupID; | ||
4301 | |||
4302 | return detobj; | ||
4303 | } | ||
4304 | |||
4305 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4306 | { | ||
4307 | DetectedObject detobj = new DetectedObject(); | ||
4308 | detobj.keyUUID = av.UUID; | ||
4309 | detobj.nameStr = av.ControllingClient.Name; | ||
4310 | detobj.ownerUUID = av.UUID; | ||
4311 | detobj.posVector = av.AbsolutePosition; | ||
4312 | detobj.rotQuat = av.Rotation; | ||
4313 | detobj.velVector = av.Velocity; | ||
4314 | detobj.colliderType = 0; | ||
4315 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4316 | |||
4317 | return detobj; | ||
4318 | } | ||
4319 | |||
4320 | private DetectedObject CreateDetObjectForGround() | ||
4321 | { | ||
4322 | DetectedObject detobj = new DetectedObject(); | ||
4323 | detobj.keyUUID = UUID.Zero; | ||
4324 | detobj.nameStr = ""; | ||
4325 | detobj.ownerUUID = UUID.Zero; | ||
4326 | detobj.posVector = AbsolutePosition; | ||
4327 | detobj.rotQuat = Quaternion.Identity; | ||
4328 | detobj.velVector = Vector3.Zero; | ||
4329 | detobj.colliderType = 0; | ||
4330 | detobj.groupUUID = UUID.Zero; | ||
4331 | |||
4332 | return detobj; | ||
4333 | } | ||
4334 | |||
4335 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4336 | { | ||
4337 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4338 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4339 | foreach (uint localId in colliders) | ||
4340 | { | ||
4341 | if (localId == 0) | ||
4342 | continue; | ||
4343 | |||
4344 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4345 | if (obj != null) | ||
4346 | { | ||
4347 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4348 | colliding.Add(CreateDetObject(obj)); | ||
4349 | } | ||
4350 | else | ||
4351 | { | ||
4352 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4353 | if (av != null && (!av.IsChildAgent)) | ||
4354 | { | ||
4355 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4356 | colliding.Add(CreateDetObject(av)); | ||
4357 | } | ||
4358 | } | ||
4359 | } | ||
4360 | |||
4361 | colliderArgs.Colliders = colliding; | ||
4362 | |||
4363 | return colliderArgs; | ||
4364 | } | ||
4365 | |||
4366 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4367 | |||
4368 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4369 | { | ||
4370 | ColliderArgs CollidingMessage; | ||
4371 | |||
4372 | if (colliders.Count > 0) | ||
4373 | { | ||
4374 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4375 | { | ||
4376 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4377 | |||
4378 | if (CollidingMessage.Colliders.Count > 0) | ||
4379 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4380 | } | ||
4381 | } | ||
4382 | } | ||
4383 | |||
4384 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4385 | { | ||
4386 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4387 | { | ||
4388 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4389 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4390 | |||
4391 | colliding.Add(CreateDetObjectForGround()); | ||
4392 | LandCollidingMessage.Colliders = colliding; | ||
4393 | |||
4394 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4395 | } | ||
4396 | } | ||
4397 | |||
4398 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4399 | { | ||
4400 | try | ||
4401 | { | ||
4402 | List<uint> thisHitColliders = new List<uint>(); | ||
4403 | List<uint> endedColliders = new List<uint>(); | ||
4404 | List<uint> startedColliders = new List<uint>(); | ||
4405 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4406 | CollisionForSoundInfo soundinfo; | ||
4407 | ContactPoint curcontact; | ||
4408 | |||
4409 | if (coldata.Count == 0) | ||
4410 | { | ||
4411 | if (m_lastColliders.Count == 0) | ||
4412 | return; // nothing to do | ||
4413 | |||
4414 | foreach (uint localID in m_lastColliders) | ||
4415 | { | ||
4416 | endedColliders.Add(localID); | ||
4417 | } | ||
4418 | m_lastColliders.Clear(); | ||
4419 | } | ||
4420 | |||
4421 | else | ||
4422 | { | ||
4423 | foreach (uint id in coldata.Keys) | ||
4424 | { | ||
4425 | thisHitColliders.Add(id); | ||
4426 | if (!m_lastColliders.Contains(id)) | ||
4427 | { | ||
4428 | startedColliders.Add(id); | ||
4429 | curcontact = coldata[id]; | ||
4430 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4431 | { | ||
4432 | soundinfo = new CollisionForSoundInfo(); | ||
4433 | soundinfo.colliderID = id; | ||
4434 | soundinfo.position = curcontact.Position; | ||
4435 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4436 | soundinfolist.Add(soundinfo); | ||
4437 | } | ||
4438 | } | ||
4439 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4440 | } | ||
4441 | |||
4442 | // calculate things that ended colliding | ||
4443 | foreach (uint localID in m_lastColliders) | ||
4444 | { | ||
4445 | if (!thisHitColliders.Contains(localID)) | ||
4446 | { | ||
4447 | endedColliders.Add(localID); | ||
4448 | } | ||
4449 | } | ||
4450 | //add the items that started colliding this time to the last colliders list. | ||
4451 | foreach (uint localID in startedColliders) | ||
4452 | { | ||
4453 | m_lastColliders.Add(localID); | ||
4454 | } | ||
4455 | // remove things that ended colliding from the last colliders list | ||
4456 | foreach (uint localID in endedColliders) | ||
4457 | { | ||
4458 | m_lastColliders.Remove(localID); | ||
4459 | } | ||
4460 | |||
4461 | if (soundinfolist.Count > 0) | ||
4462 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4463 | } | ||
4464 | |||
4465 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4466 | { | ||
4467 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4468 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4469 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4470 | |||
4471 | if (startedColliders.Contains(0)) | ||
4472 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4473 | if (m_lastColliders.Contains(0)) | ||
4474 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4475 | if (endedColliders.Contains(0)) | ||
4476 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4477 | } | ||
4478 | } | ||
4479 | finally | ||
4480 | { | ||
4481 | m_collisionEventFlag = false; | ||
4482 | } | ||
4483 | } | ||
4484 | |||
4082 | private void TeleportFlagsDebug() { | 4485 | private void TeleportFlagsDebug() { |
4083 | 4486 | ||
4084 | // Some temporary debugging help to show all the TeleportFlags we have... | 4487 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4103,6 +4506,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4103 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4506 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4104 | 4507 | ||
4105 | } | 4508 | } |
4106 | |||
4107 | } | 4509 | } |
4108 | } | 4510 | } |