aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs596
1 files changed, 516 insertions, 80 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 96bca3e..2c18397 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -63,6 +63,7 @@ namespace OpenSim.Region.Framework.Scenes
63 63
64 struct ScriptControllers 64 struct ScriptControllers
65 { 65 {
66 public UUID objectID;
66 public UUID itemID; 67 public UUID itemID;
67 public ScriptControlled ignoreControls; 68 public ScriptControlled ignoreControls;
68 public ScriptControlled eventControls; 69 public ScriptControlled eventControls;
@@ -99,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes
99 /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis 100 /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis
100 /// issue #1716 101 /// issue #1716
101 /// </summary> 102 /// </summary>
102 public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); 103 public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f);
103 104
104 /// <summary> 105 /// <summary>
105 /// Movement updates for agents in neighboring regions are sent directly to clients. 106 /// Movement updates for agents in neighboring regions are sent directly to clients.
@@ -171,6 +172,7 @@ namespace OpenSim.Region.Framework.Scenes
171// private int m_lastColCount = -1; //KF: Look for Collision chnages 172// private int m_lastColCount = -1; //KF: Look for Collision chnages
172// private int m_updateCount = 0; //KF: Update Anims for a while 173// private int m_updateCount = 0; //KF: Update Anims for a while
173// private static readonly int UPDATE_COUNT = 10; // how many frames to update for 174// private static readonly int UPDATE_COUNT = 10; // how many frames to update for
175 private List<uint> m_lastColliders = new List<uint>();
174 176
175 private TeleportFlags m_teleportFlags; 177 private TeleportFlags m_teleportFlags;
176 public TeleportFlags TeleportFlags 178 public TeleportFlags TeleportFlags
@@ -232,6 +234,13 @@ namespace OpenSim.Region.Framework.Scenes
232 //private int m_moveToPositionStateStatus; 234 //private int m_moveToPositionStateStatus;
233 //***************************************************** 235 //*****************************************************
234 236
237 private bool m_collisionEventFlag = false;
238 private object m_collisionEventLock = new Object();
239
240 private int m_movementAnimationUpdateCounter = 0;
241
242 private Vector3 m_prevSitOffset;
243
235 protected AvatarAppearance m_appearance; 244 protected AvatarAppearance m_appearance;
236 245
237 public AvatarAppearance Appearance 246 public AvatarAppearance Appearance
@@ -426,7 +435,7 @@ namespace OpenSim.Region.Framework.Scenes
426 get { return (IClientCore)ControllingClient; } 435 get { return (IClientCore)ControllingClient; }
427 } 436 }
428 437
429 public Vector3 ParentPosition { get; set; } 438// public Vector3 ParentPosition { get; set; }
430 439
431 /// <summary> 440 /// <summary>
432 /// Position of this avatar relative to the region the avatar is in 441 /// Position of this avatar relative to the region the avatar is in
@@ -484,7 +493,7 @@ namespace OpenSim.Region.Framework.Scenes
484 if (ParentID == 0) 493 if (ParentID == 0)
485 { 494 {
486 m_pos = value; 495 m_pos = value;
487 ParentPosition = Vector3.Zero; 496// ParentPosition = Vector3.Zero;
488 } 497 }
489 498
490 //m_log.DebugFormat( 499 //m_log.DebugFormat(
@@ -573,6 +582,13 @@ namespace OpenSim.Region.Framework.Scenes
573 /// </summary> 582 /// </summary>
574 public uint ParentID { get; set; } 583 public uint ParentID { get; set; }
575 584
585 public UUID ParentUUID
586 {
587 get { return m_parentUUID; }
588 set { m_parentUUID = value; }
589 }
590 private UUID m_parentUUID = UUID.Zero;
591
576 /// <summary> 592 /// <summary>
577 /// Are we sitting on an object? 593 /// Are we sitting on an object?
578 /// </summary> 594 /// </summary>
@@ -739,6 +755,33 @@ namespace OpenSim.Region.Framework.Scenes
739 Appearance = appearance; 755 Appearance = appearance;
740 } 756 }
741 757
758 private void RegionHeartbeatEnd(Scene scene)
759 {
760 if (IsChildAgent)
761 return;
762
763 m_movementAnimationUpdateCounter ++;
764 if (m_movementAnimationUpdateCounter >= 2)
765 {
766 m_movementAnimationUpdateCounter = 0;
767 if (Animator != null)
768 {
769 // If the parentID == 0 we are not sitting
770 // if !SitGournd then we are not sitting on the ground
771 // Fairly straightforward, now here comes the twist
772 // if ParentUUID is NOT UUID.Zero, we are looking to
773 // be sat on an object that isn't there yet. Should
774 // be treated as if sat.
775 if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting
776 Animator.UpdateMovementAnimations();
777 }
778 else
779 {
780 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
781 }
782 }
783 }
784
742 public void RegisterToEvents() 785 public void RegisterToEvents()
743 { 786 {
744 ControllingClient.OnCompleteMovementToRegion += CompleteMovement; 787 ControllingClient.OnCompleteMovementToRegion += CompleteMovement;
@@ -748,6 +791,7 @@ namespace OpenSim.Region.Framework.Scenes
748 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; 791 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
749 ControllingClient.OnStartAnim += HandleStartAnim; 792 ControllingClient.OnStartAnim += HandleStartAnim;
750 ControllingClient.OnStopAnim += HandleStopAnim; 793 ControllingClient.OnStopAnim += HandleStopAnim;
794 ControllingClient.OnChangeAnim += avnHandleChangeAnim;
751 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; 795 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls;
752 ControllingClient.OnAutoPilotGo += MoveToTarget; 796 ControllingClient.OnAutoPilotGo += MoveToTarget;
753 797
@@ -808,10 +852,39 @@ namespace OpenSim.Region.Framework.Scenes
808 "[SCENE]: Upgrading child to root agent for {0} in {1}", 852 "[SCENE]: Upgrading child to root agent for {0} in {1}",
809 Name, m_scene.RegionInfo.RegionName); 853 Name, m_scene.RegionInfo.RegionName);
810 854
811 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
812
813 bool wasChild = IsChildAgent; 855 bool wasChild = IsChildAgent;
814 IsChildAgent = false; 856
857 if (ParentUUID != UUID.Zero)
858 {
859 m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID);
860 SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID);
861 if (part == null)
862 {
863 m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID);
864 }
865 else
866 {
867 part.ParentGroup.AddAvatar(UUID);
868 if (part.SitTargetPosition != Vector3.Zero)
869 part.SitTargetAvatar = UUID;
870// ParentPosition = part.GetWorldPosition();
871 ParentID = part.LocalId;
872 ParentPart = part;
873 m_pos = m_prevSitOffset;
874// pos = ParentPosition;
875 pos = part.GetWorldPosition();
876 }
877 ParentUUID = UUID.Zero;
878
879 IsChildAgent = false;
880
881// Animator.TrySetMovementAnimation("SIT");
882 }
883 else
884 {
885 IsChildAgent = false;
886 }
887
815 888
816 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 889 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
817 if (gm != null) 890 if (gm != null)
@@ -821,62 +894,72 @@ namespace OpenSim.Region.Framework.Scenes
821 894
822 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 895 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
823 896
824 // Moved this from SendInitialData to ensure that Appearance is initialized 897 if (ParentID == 0)
825 // before the inventory is processed in MakeRootAgent. This fixes a race condition
826 // related to the handling of attachments
827 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
828 if (m_scene.TestBorderCross(pos, Cardinals.E))
829 { 898 {
830 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); 899 // Moved this from SendInitialData to ensure that Appearance is initialized
831 pos.X = crossedBorder.BorderLine.Z - 1; 900 // before the inventory is processed in MakeRootAgent. This fixes a race condition
832 } 901 // related to the handling of attachments
902 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
903 if (m_scene.TestBorderCross(pos, Cardinals.E))
904 {
905 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
906 pos.X = crossedBorder.BorderLine.Z - 1;
907 }
833 908
834 if (m_scene.TestBorderCross(pos, Cardinals.N)) 909 if (m_scene.TestBorderCross(pos, Cardinals.N))
835 { 910 {
836 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); 911 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
837 pos.Y = crossedBorder.BorderLine.Z - 1; 912 pos.Y = crossedBorder.BorderLine.Z - 1;
838 } 913 }
839 914
840 CheckAndAdjustLandingPoint(ref pos); 915 CheckAndAdjustLandingPoint(ref pos);
841 916
842 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 917 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
843 { 918 {
844 m_log.WarnFormat( 919 m_log.WarnFormat(
845 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", 920 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
846 pos, Name, UUID); 921 pos, Name, UUID);
847 922
848 if (pos.X < 0f) pos.X = 0f; 923 if (pos.X < 0f) pos.X = 0f;
849 if (pos.Y < 0f) pos.Y = 0f; 924 if (pos.Y < 0f) pos.Y = 0f;
850 if (pos.Z < 0f) pos.Z = 0f; 925 if (pos.Z < 0f) pos.Z = 0f;
851 } 926 }
852 927
853 float localAVHeight = 1.56f; 928 float localAVHeight = 1.56f;
854 if (Appearance.AvatarHeight > 0) 929 if (Appearance.AvatarHeight > 0)
855 localAVHeight = Appearance.AvatarHeight; 930 localAVHeight = Appearance.AvatarHeight;
856 931
857 float posZLimit = 0; 932 float posZLimit = 0;
858 933
859 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 934 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
860 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 935 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
861 936
862 float newPosZ = posZLimit + localAVHeight / 2; 937 float newPosZ = posZLimit + localAVHeight / 2;
863 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) 938 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
864 { 939 {
865 pos.Z = newPosZ; 940 pos.Z = newPosZ;
866 } 941 }
867 AbsolutePosition = pos; 942 AbsolutePosition = pos;
868 943
869 AddToPhysicalScene(isFlying); 944 if (m_teleportFlags == TeleportFlags.Default)
945 {
946 Vector3 vel = Velocity;
947 AddToPhysicalScene(isFlying);
948 if (PhysicsActor != null)
949 PhysicsActor.SetMomentum(vel);
950 }
951 else
952 AddToPhysicalScene(isFlying);
870 953
871 if (ForceFly) 954 if (ForceFly)
872 { 955 {
873 Flying = true; 956 Flying = true;
874 } 957 }
875 else if (FlyDisabled) 958 else if (FlyDisabled)
876 { 959 {
877 Flying = false; 960 Flying = false;
961 }
878 } 962 }
879
880 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 963 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
881 // avatar to return to the standing position in mid-air. On login it looks like this is being sent 964 // avatar to return to the standing position in mid-air. On login it looks like this is being sent
882 // elsewhere anyway 965 // elsewhere anyway
@@ -896,14 +979,19 @@ namespace OpenSim.Region.Framework.Scenes
896 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); 979 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
897 980
898 // Resume scripts 981 // Resume scripts
899 foreach (SceneObjectGroup sog in m_attachments) 982 Util.FireAndForget(delegate(object x) {
900 { 983 foreach (SceneObjectGroup sog in m_attachments)
901 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 984 {
902 sog.ResumeScripts(); 985 sog.ScheduleGroupForFullUpdate();
903 } 986 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
987 sog.ResumeScripts();
988 }
989 });
904 } 990 }
905 } 991 }
906 992
993 SendAvatarDataToAllAgents();
994
907 // send the animations of the other presences to me 995 // send the animations of the other presences to me
908 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) 996 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
909 { 997 {
@@ -914,9 +1002,12 @@ namespace OpenSim.Region.Framework.Scenes
914 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will 1002 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will
915 // stall on the border crossing since the existing child agent will still have the last movement 1003 // stall on the border crossing since the existing child agent will still have the last movement
916 // recorded, which stops the input from being processed. 1004 // recorded, which stops the input from being processed.
1005
917 MovementFlag = 0; 1006 MovementFlag = 0;
918 1007
919 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1008 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1009
1010 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
920 } 1011 }
921 1012
922 public int GetStateSource() 1013 public int GetStateSource()
@@ -944,12 +1035,16 @@ namespace OpenSim.Region.Framework.Scenes
944 /// </remarks> 1035 /// </remarks>
945 public void MakeChildAgent() 1036 public void MakeChildAgent()
946 { 1037 {
1038 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
1039
947 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); 1040 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName);
948 1041
949 // Reset these so that teleporting in and walking out isn't seen 1042 // Reset these so that teleporting in and walking out isn't seen
950 // as teleporting back 1043 // as teleporting back
951 TeleportFlags = TeleportFlags.Default; 1044 TeleportFlags = TeleportFlags.Default;
952 1045
1046 MovementFlag = 0;
1047
953 // It looks like Animator is set to null somewhere, and MakeChild 1048 // It looks like Animator is set to null somewhere, and MakeChild
954 // is called after that. Probably in aborted teleports. 1049 // is called after that. Probably in aborted teleports.
955 if (Animator == null) 1050 if (Animator == null)
@@ -957,6 +1052,7 @@ namespace OpenSim.Region.Framework.Scenes
957 else 1052 else
958 Animator.ResetAnimations(); 1053 Animator.ResetAnimations();
959 1054
1055
960// m_log.DebugFormat( 1056// m_log.DebugFormat(
961// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", 1057// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
962// Name, UUID, m_scene.RegionInfo.RegionName); 1058// Name, UUID, m_scene.RegionInfo.RegionName);
@@ -968,6 +1064,7 @@ namespace OpenSim.Region.Framework.Scenes
968 IsChildAgent = true; 1064 IsChildAgent = true;
969 m_scene.SwapRootAgentCount(true); 1065 m_scene.SwapRootAgentCount(true);
970 RemoveFromPhysicalScene(); 1066 RemoveFromPhysicalScene();
1067 ParentID = 0; // Child agents can't be sitting
971 1068
972 // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into 1069 // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into
973 1070
@@ -983,9 +1080,9 @@ namespace OpenSim.Region.Framework.Scenes
983 { 1080 {
984// PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; 1081// PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients;
985 PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; 1082 PhysicsActor.OnOutOfBounds -= OutOfBoundsCall;
986 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor);
987 PhysicsActor.UnSubscribeEvents();
988 PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; 1083 PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate;
1084 PhysicsActor.UnSubscribeEvents();
1085 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor);
989 PhysicsActor = null; 1086 PhysicsActor = null;
990 } 1087 }
991// else 1088// else
@@ -1002,7 +1099,7 @@ namespace OpenSim.Region.Framework.Scenes
1002 /// <param name="pos"></param> 1099 /// <param name="pos"></param>
1003 public void Teleport(Vector3 pos) 1100 public void Teleport(Vector3 pos)
1004 { 1101 {
1005 TeleportWithMomentum(pos, null); 1102 TeleportWithMomentum(pos, Vector3.Zero);
1006 } 1103 }
1007 1104
1008 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1105 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
@@ -1026,6 +1123,41 @@ namespace OpenSim.Region.Framework.Scenes
1026 SendTerseUpdateToAllClients(); 1123 SendTerseUpdateToAllClients();
1027 } 1124 }
1028 1125
1126 public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY)
1127 {
1128 CheckLandingPoint(ref newpos);
1129 AbsolutePosition = newpos;
1130
1131 if (newvel.HasValue)
1132 {
1133 if ((Vector3)newvel == Vector3.Zero)
1134 {
1135 if (PhysicsActor != null)
1136 PhysicsActor.SetMomentum(Vector3.Zero);
1137 m_velocity = Vector3.Zero;
1138 }
1139 else
1140 {
1141 if (PhysicsActor != null)
1142 PhysicsActor.SetMomentum((Vector3)newvel);
1143 m_velocity = (Vector3)newvel;
1144
1145 if (rotateToVelXY)
1146 {
1147 Vector3 lookAt = (Vector3)newvel;
1148 lookAt.Z = 0;
1149 lookAt.Normalize();
1150 ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation);
1151 return;
1152 }
1153 }
1154 }
1155
1156 SendTerseUpdateToAllClients();
1157 }
1158
1159
1160
1029 public void StopFlying() 1161 public void StopFlying()
1030 { 1162 {
1031 ControllingClient.StopFlying(this); 1163 ControllingClient.StopFlying(this);
@@ -1135,7 +1267,8 @@ namespace OpenSim.Region.Framework.Scenes
1135 1267
1136 Vector3 look = Velocity; 1268 Vector3 look = Velocity;
1137 1269
1138 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1270 // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1271 if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1))
1139 { 1272 {
1140 look = new Vector3(0.99f, 0.042f, 0); 1273 look = new Vector3(0.99f, 0.042f, 0);
1141 } 1274 }
@@ -1185,13 +1318,15 @@ namespace OpenSim.Region.Framework.Scenes
1185 // Create child agents in neighbouring regions 1318 // Create child agents in neighbouring regions
1186 if (openChildAgents && !IsChildAgent) 1319 if (openChildAgents && !IsChildAgent)
1187 { 1320 {
1321
1188 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); 1322 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1189 if (m_agentTransfer != null) 1323 if (m_agentTransfer != null)
1190 Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); 1324 m_agentTransfer.EnableChildAgents(this);
1191 1325
1192 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 1326 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1193 if (friendsModule != null) 1327 if (friendsModule != null)
1194 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1328 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1329
1195 } 1330 }
1196 1331
1197// m_log.DebugFormat( 1332// m_log.DebugFormat(
@@ -1341,8 +1476,18 @@ namespace OpenSim.Region.Framework.Scenes
1341 { 1476 {
1342 if (m_followCamAuto) 1477 if (m_followCamAuto)
1343 { 1478 {
1344 Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; 1479 // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT;
1345 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); 1480 // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback);
1481
1482 Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT;
1483 Vector3 distTocam = CameraPosition - posAdjusted;
1484 float distTocamlen = distTocam.Length();
1485 if (distTocamlen > 0)
1486 {
1487 distTocam *= 1.0f / distTocamlen;
1488 m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback);
1489 }
1490
1346 } 1491 }
1347 } 1492 }
1348 1493
@@ -1781,12 +1926,17 @@ namespace OpenSim.Region.Framework.Scenes
1781// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); 1926// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name);
1782 1927
1783 SitGround = false; 1928 SitGround = false;
1929
1930/* move this down so avatar gets physical in the new position and not where it is siting
1784 if (PhysicsActor == null) 1931 if (PhysicsActor == null)
1785 AddToPhysicalScene(false); 1932 AddToPhysicalScene(false);
1933 */
1786 1934
1787 if (ParentID != 0) 1935 if (ParentID != 0)
1788 { 1936 {
1789 SceneObjectPart part = ParentPart; 1937 SceneObjectPart part = ParentPart;
1938 UnRegisterSeatControls(part.ParentGroup.UUID);
1939
1790 TaskInventoryDictionary taskIDict = part.TaskInventory; 1940 TaskInventoryDictionary taskIDict = part.TaskInventory;
1791 if (taskIDict != null) 1941 if (taskIDict != null)
1792 { 1942 {
@@ -1802,14 +1952,22 @@ namespace OpenSim.Region.Framework.Scenes
1802 } 1952 }
1803 } 1953 }
1804 1954
1805 ParentPosition = part.GetWorldPosition(); 1955 part.ParentGroup.DeleteAvatar(UUID);
1956// ParentPosition = part.GetWorldPosition();
1806 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1957 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1807 1958
1808 m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); 1959// m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
1809 ParentPosition = Vector3.Zero; 1960// ParentPosition = Vector3.Zero;
1961 m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
1962 if (part.SitTargetAvatar == UUID)
1963 m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation;
1810 1964
1811 ParentID = 0; 1965 ParentID = 0;
1812 ParentPart = null; 1966 ParentPart = null;
1967
1968 if (PhysicsActor == null)
1969 AddToPhysicalScene(false);
1970
1813 SendAvatarDataToAllAgents(); 1971 SendAvatarDataToAllAgents();
1814 m_requestedSitTargetID = 0; 1972 m_requestedSitTargetID = 0;
1815 1973
@@ -1819,6 +1977,9 @@ namespace OpenSim.Region.Framework.Scenes
1819 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 1977 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
1820 } 1978 }
1821 1979
1980 else if (PhysicsActor == null)
1981 AddToPhysicalScene(false);
1982
1822 Animator.TrySetMovementAnimation("STAND"); 1983 Animator.TrySetMovementAnimation("STAND");
1823 } 1984 }
1824 1985
@@ -1870,7 +2031,7 @@ namespace OpenSim.Region.Framework.Scenes
1870 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it 2031 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
1871 2032
1872 if (PhysicsActor != null) 2033 if (PhysicsActor != null)
1873 m_sitAvatarHeight = PhysicsActor.Size.Z; 2034 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
1874 2035
1875 bool canSit = false; 2036 bool canSit = false;
1876 Vector3 pos = part.AbsolutePosition + offset; 2037 Vector3 pos = part.AbsolutePosition + offset;
@@ -1919,7 +2080,7 @@ namespace OpenSim.Region.Framework.Scenes
1919 forceMouselook = part.GetForceMouselook(); 2080 forceMouselook = part.GetForceMouselook();
1920 2081
1921 ControllingClient.SendSitResponse( 2082 ControllingClient.SendSitResponse(
1922 targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 2083 part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
1923 2084
1924 m_requestedSitTargetUUID = targetID; 2085 m_requestedSitTargetUUID = targetID;
1925 2086
@@ -1933,6 +2094,9 @@ namespace OpenSim.Region.Framework.Scenes
1933 2094
1934 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) 2095 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset)
1935 { 2096 {
2097 if (IsChildAgent)
2098 return;
2099
1936 if (ParentID != 0) 2100 if (ParentID != 0)
1937 { 2101 {
1938 StandUp(); 2102 StandUp();
@@ -2210,14 +2374,39 @@ namespace OpenSim.Region.Framework.Scenes
2210 2374
2211 //Quaternion result = (sitTargetOrient * vq) * nq; 2375 //Quaternion result = (sitTargetOrient * vq) * nq;
2212 2376
2213 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2377 double x, y, z, m;
2378
2379 Quaternion r = sitTargetOrient;
2380 m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W;
2381
2382 if (Math.Abs(1.0 - m) > 0.000001)
2383 {
2384 m = 1.0 / Math.Sqrt(m);
2385 r.X *= (float)m;
2386 r.Y *= (float)m;
2387 r.Z *= (float)m;
2388 r.W *= (float)m;
2389 }
2390
2391 x = 2 * (r.X * r.Z + r.Y * r.W);
2392 y = 2 * (-r.X * r.W + r.Y * r.Z);
2393 z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W;
2394
2395 Vector3 up = new Vector3((float)x, (float)y, (float)z);
2396 Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f;
2397
2398 m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT;
2399
2400// m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset;
2214 Rotation = sitTargetOrient; 2401 Rotation = sitTargetOrient;
2215 ParentPosition = part.AbsolutePosition; 2402// ParentPosition = part.AbsolutePosition;
2403 part.ParentGroup.AddAvatar(UUID);
2216 } 2404 }
2217 else 2405 else
2218 { 2406 {
2219 m_pos -= part.AbsolutePosition; 2407 m_pos -= part.AbsolutePosition;
2220 ParentPosition = part.AbsolutePosition; 2408// ParentPosition = part.AbsolutePosition;
2409 part.ParentGroup.AddAvatar(UUID);
2221 2410
2222// m_log.DebugFormat( 2411// m_log.DebugFormat(
2223// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", 2412// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
@@ -2262,6 +2451,13 @@ namespace OpenSim.Region.Framework.Scenes
2262 Animator.RemoveAnimation(animID); 2451 Animator.RemoveAnimation(animID);
2263 } 2452 }
2264 2453
2454 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack)
2455 {
2456 Animator.avnChangeAnim(animID, addRemove, sendPack);
2457 }
2458
2459
2460
2265 /// <summary> 2461 /// <summary>
2266 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector 2462 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector
2267 /// </summary> 2463 /// </summary>
@@ -2315,14 +2511,15 @@ namespace OpenSim.Region.Framework.Scenes
2315 direc.Z *= 2.6f; 2511 direc.Z *= 2.6f;
2316 2512
2317 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. 2513 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored.
2318 Animator.TrySetMovementAnimation("PREJUMP"); 2514// Animator.TrySetMovementAnimation("PREJUMP");
2319 Animator.TrySetMovementAnimation("JUMP"); 2515// Animator.TrySetMovementAnimation("JUMP");
2320 } 2516 }
2321 } 2517 }
2322 } 2518 }
2323 2519
2324 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2520 // TODO: Add the force instead of only setting it to support multiple forces per frame?
2325 m_forceToApply = direc; 2521 m_forceToApply = direc;
2522 Animator.UpdateMovementAnimations();
2326 } 2523 }
2327 2524
2328 #endregion 2525 #endregion
@@ -2714,8 +2911,9 @@ namespace OpenSim.Region.Framework.Scenes
2714 2911
2715 // If we don't have a PhysActor, we can't cross anyway 2912 // If we don't have a PhysActor, we can't cross anyway
2716 // Also don't do this while sat, sitting avatars cross with the 2913 // Also don't do this while sat, sitting avatars cross with the
2717 // object they sit on. 2914 // object they sit on. ParentUUID denoted a pending sit, don't
2718 if (ParentID != 0 || PhysicsActor == null) 2915 // interfere with it.
2916 if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero)
2719 return; 2917 return;
2720 2918
2721 if (!IsInTransit) 2919 if (!IsInTransit)
@@ -3056,6 +3254,9 @@ namespace OpenSim.Region.Framework.Scenes
3056 cAgent.AlwaysRun = SetAlwaysRun; 3254 cAgent.AlwaysRun = SetAlwaysRun;
3057 3255
3058 cAgent.Appearance = new AvatarAppearance(Appearance); 3256 cAgent.Appearance = new AvatarAppearance(Appearance);
3257
3258 cAgent.ParentPart = ParentUUID;
3259 cAgent.SitOffset = m_pos;
3059 3260
3060 lock (scriptedcontrols) 3261 lock (scriptedcontrols)
3061 { 3262 {
@@ -3064,7 +3265,7 @@ namespace OpenSim.Region.Framework.Scenes
3064 3265
3065 foreach (ScriptControllers c in scriptedcontrols.Values) 3266 foreach (ScriptControllers c in scriptedcontrols.Values)
3066 { 3267 {
3067 controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); 3268 controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls);
3068 } 3269 }
3069 cAgent.Controllers = controls; 3270 cAgent.Controllers = controls;
3070 } 3271 }
@@ -3097,6 +3298,8 @@ namespace OpenSim.Region.Framework.Scenes
3097 CameraAtAxis = cAgent.AtAxis; 3298 CameraAtAxis = cAgent.AtAxis;
3098 CameraLeftAxis = cAgent.LeftAxis; 3299 CameraLeftAxis = cAgent.LeftAxis;
3099 CameraUpAxis = cAgent.UpAxis; 3300 CameraUpAxis = cAgent.UpAxis;
3301 ParentUUID = cAgent.ParentPart;
3302 m_prevSitOffset = cAgent.SitOffset;
3100 3303
3101 // When we get to the point of re-computing neighbors everytime this 3304 // When we get to the point of re-computing neighbors everytime this
3102 // changes, then start using the agent's drawdistance rather than the 3305 // changes, then start using the agent's drawdistance rather than the
@@ -3134,6 +3337,7 @@ namespace OpenSim.Region.Framework.Scenes
3134 foreach (ControllerData c in cAgent.Controllers) 3337 foreach (ControllerData c in cAgent.Controllers)
3135 { 3338 {
3136 ScriptControllers sc = new ScriptControllers(); 3339 ScriptControllers sc = new ScriptControllers();
3340 sc.objectID = c.ObjectID;
3137 sc.itemID = c.ItemID; 3341 sc.itemID = c.ItemID;
3138 sc.ignoreControls = (ScriptControlled)c.IgnoreControls; 3342 sc.ignoreControls = (ScriptControlled)c.IgnoreControls;
3139 sc.eventControls = (ScriptControlled)c.EventControls; 3343 sc.eventControls = (ScriptControlled)c.EventControls;
@@ -3214,7 +3418,7 @@ namespace OpenSim.Region.Framework.Scenes
3214 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 3418 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
3215 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 3419 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
3216 PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong 3420 PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
3217 PhysicsActor.SubscribeEvents(500); 3421 PhysicsActor.SubscribeEvents(100);
3218 PhysicsActor.LocalID = LocalId; 3422 PhysicsActor.LocalID = LocalId;
3219 } 3423 }
3220 3424
@@ -3241,7 +3445,7 @@ namespace OpenSim.Region.Framework.Scenes
3241 /// <param name="e"></param> 3445 /// <param name="e"></param>
3242 public void PhysicsCollisionUpdate(EventArgs e) 3446 public void PhysicsCollisionUpdate(EventArgs e)
3243 { 3447 {
3244 if (IsChildAgent) 3448 if (IsChildAgent || Animator == null)
3245 return; 3449 return;
3246 3450
3247 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) 3451 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
@@ -3296,6 +3500,8 @@ namespace OpenSim.Region.Framework.Scenes
3296 } 3500 }
3297 } 3501 }
3298 3502
3503 RaiseCollisionScriptEvents(coldata);
3504
3299 // Gods do not take damage and Invulnerable is set depending on parcel/region flags 3505 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
3300 if (Invulnerable || GodLevel > 0) 3506 if (Invulnerable || GodLevel > 0)
3301 return; 3507 return;
@@ -3393,6 +3599,13 @@ namespace OpenSim.Region.Framework.Scenes
3393 // m_reprioritizationTimer.Dispose(); 3599 // m_reprioritizationTimer.Dispose();
3394 3600
3395 RemoveFromPhysicalScene(); 3601 RemoveFromPhysicalScene();
3602
3603 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
3604
3605// if (Animator != null)
3606// Animator.Close();
3607 Animator = null;
3608
3396 } 3609 }
3397 3610
3398 public void AddAttachment(SceneObjectGroup gobj) 3611 public void AddAttachment(SceneObjectGroup gobj)
@@ -3626,10 +3839,18 @@ namespace OpenSim.Region.Framework.Scenes
3626 3839
3627 public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) 3840 public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID)
3628 { 3841 {
3842 SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID);
3843 if (p == null)
3844 return;
3845
3846 ControllingClient.SendTakeControls(controls, false, false);
3847 ControllingClient.SendTakeControls(controls, true, false);
3848
3629 ScriptControllers obj = new ScriptControllers(); 3849 ScriptControllers obj = new ScriptControllers();
3630 obj.ignoreControls = ScriptControlled.CONTROL_ZERO; 3850 obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
3631 obj.eventControls = ScriptControlled.CONTROL_ZERO; 3851 obj.eventControls = ScriptControlled.CONTROL_ZERO;
3632 3852
3853 obj.objectID = p.ParentGroup.UUID;
3633 obj.itemID = Script_item_UUID; 3854 obj.itemID = Script_item_UUID;
3634 if (pass_on == 0 && accept == 0) 3855 if (pass_on == 0 && accept == 0)
3635 { 3856 {
@@ -3678,6 +3899,21 @@ namespace OpenSim.Region.Framework.Scenes
3678 ControllingClient.SendTakeControls(int.MaxValue, false, false); 3899 ControllingClient.SendTakeControls(int.MaxValue, false, false);
3679 } 3900 }
3680 3901
3902 private void UnRegisterSeatControls(UUID obj)
3903 {
3904 List<UUID> takers = new List<UUID>();
3905
3906 foreach (ScriptControllers c in scriptedcontrols.Values)
3907 {
3908 if (c.objectID == obj)
3909 takers.Add(c.itemID);
3910 }
3911 foreach (UUID t in takers)
3912 {
3913 UnRegisterControlEventsToScript(0, t);
3914 }
3915 }
3916
3681 public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) 3917 public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID)
3682 { 3918 {
3683 ScriptControllers takecontrols; 3919 ScriptControllers takecontrols;
@@ -3996,6 +4232,12 @@ namespace OpenSim.Region.Framework.Scenes
3996 4232
3997 private void CheckAndAdjustLandingPoint(ref Vector3 pos) 4233 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3998 { 4234 {
4235 string reason;
4236
4237 // Honor bans
4238 if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y))
4239 return;
4240
3999 SceneObjectGroup telehub = null; 4241 SceneObjectGroup telehub = null;
4000 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) 4242 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null)
4001 { 4243 {
@@ -4035,11 +4277,206 @@ namespace OpenSim.Region.Framework.Scenes
4035 pos = land.LandData.UserLocation; 4277 pos = land.LandData.UserLocation;
4036 } 4278 }
4037 } 4279 }
4038 4280
4039 land.SendLandUpdateToClient(ControllingClient); 4281 land.SendLandUpdateToClient(ControllingClient);
4040 } 4282 }
4041 } 4283 }
4042 4284
4285 private DetectedObject CreateDetObject(SceneObjectPart obj)
4286 {
4287 DetectedObject detobj = new DetectedObject();
4288 detobj.keyUUID = obj.UUID;
4289 detobj.nameStr = obj.Name;
4290 detobj.ownerUUID = obj.OwnerID;
4291 detobj.posVector = obj.AbsolutePosition;
4292 detobj.rotQuat = obj.GetWorldRotation();
4293 detobj.velVector = obj.Velocity;
4294 detobj.colliderType = 0;
4295 detobj.groupUUID = obj.GroupID;
4296
4297 return detobj;
4298 }
4299
4300 private DetectedObject CreateDetObject(ScenePresence av)
4301 {
4302 DetectedObject detobj = new DetectedObject();
4303 detobj.keyUUID = av.UUID;
4304 detobj.nameStr = av.ControllingClient.Name;
4305 detobj.ownerUUID = av.UUID;
4306 detobj.posVector = av.AbsolutePosition;
4307 detobj.rotQuat = av.Rotation;
4308 detobj.velVector = av.Velocity;
4309 detobj.colliderType = 0;
4310 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
4311
4312 return detobj;
4313 }
4314
4315 private DetectedObject CreateDetObjectForGround()
4316 {
4317 DetectedObject detobj = new DetectedObject();
4318 detobj.keyUUID = UUID.Zero;
4319 detobj.nameStr = "";
4320 detobj.ownerUUID = UUID.Zero;
4321 detobj.posVector = AbsolutePosition;
4322 detobj.rotQuat = Quaternion.Identity;
4323 detobj.velVector = Vector3.Zero;
4324 detobj.colliderType = 0;
4325 detobj.groupUUID = UUID.Zero;
4326
4327 return detobj;
4328 }
4329
4330 private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders)
4331 {
4332 ColliderArgs colliderArgs = new ColliderArgs();
4333 List<DetectedObject> colliding = new List<DetectedObject>();
4334 foreach (uint localId in colliders)
4335 {
4336 if (localId == 0)
4337 continue;
4338
4339 SceneObjectPart obj = m_scene.GetSceneObjectPart(localId);
4340 if (obj != null)
4341 {
4342 if (!dest.CollisionFilteredOut(obj.UUID, obj.Name))
4343 colliding.Add(CreateDetObject(obj));
4344 }
4345 else
4346 {
4347 ScenePresence av = m_scene.GetScenePresence(localId);
4348 if (av != null && (!av.IsChildAgent))
4349 {
4350 if (!dest.CollisionFilteredOut(av.UUID, av.Name))
4351 colliding.Add(CreateDetObject(av));
4352 }
4353 }
4354 }
4355
4356 colliderArgs.Colliders = colliding;
4357
4358 return colliderArgs;
4359 }
4360
4361 private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message);
4362
4363 private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify)
4364 {
4365 ColliderArgs CollidingMessage;
4366
4367 if (colliders.Count > 0)
4368 {
4369 if ((dest.RootPart.ScriptEvents & ev) != 0)
4370 {
4371 CollidingMessage = CreateColliderArgs(dest.RootPart, colliders);
4372
4373 if (CollidingMessage.Colliders.Count > 0)
4374 notify(dest.RootPart.LocalId, CollidingMessage);
4375 }
4376 }
4377 }
4378
4379 private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify)
4380 {
4381 if ((dest.RootPart.ScriptEvents & ev) != 0)
4382 {
4383 ColliderArgs LandCollidingMessage = new ColliderArgs();
4384 List<DetectedObject> colliding = new List<DetectedObject>();
4385
4386 colliding.Add(CreateDetObjectForGround());
4387 LandCollidingMessage.Colliders = colliding;
4388
4389 notify(dest.RootPart.LocalId, LandCollidingMessage);
4390 }
4391 }
4392
4393 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
4394 {
4395 try
4396 {
4397 List<uint> thisHitColliders = new List<uint>();
4398 List<uint> endedColliders = new List<uint>();
4399 List<uint> startedColliders = new List<uint>();
4400 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
4401 CollisionForSoundInfo soundinfo;
4402 ContactPoint curcontact;
4403
4404 if (coldata.Count == 0)
4405 {
4406 if (m_lastColliders.Count == 0)
4407 return; // nothing to do
4408
4409 foreach (uint localID in m_lastColliders)
4410 {
4411 endedColliders.Add(localID);
4412 }
4413 m_lastColliders.Clear();
4414 }
4415
4416 else
4417 {
4418 foreach (uint id in coldata.Keys)
4419 {
4420 thisHitColliders.Add(id);
4421 if (!m_lastColliders.Contains(id))
4422 {
4423 startedColliders.Add(id);
4424 curcontact = coldata[id];
4425 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
4426 {
4427 soundinfo = new CollisionForSoundInfo();
4428 soundinfo.colliderID = id;
4429 soundinfo.position = curcontact.Position;
4430 soundinfo.relativeVel = curcontact.RelativeSpeed;
4431 soundinfolist.Add(soundinfo);
4432 }
4433 }
4434 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
4435 }
4436
4437 // calculate things that ended colliding
4438 foreach (uint localID in m_lastColliders)
4439 {
4440 if (!thisHitColliders.Contains(localID))
4441 {
4442 endedColliders.Add(localID);
4443 }
4444 }
4445 //add the items that started colliding this time to the last colliders list.
4446 foreach (uint localID in startedColliders)
4447 {
4448 m_lastColliders.Add(localID);
4449 }
4450 // remove things that ended colliding from the last colliders list
4451 foreach (uint localID in endedColliders)
4452 {
4453 m_lastColliders.Remove(localID);
4454 }
4455
4456 if (soundinfolist.Count > 0)
4457 CollisionSounds.AvatarCollisionSound(this, soundinfolist);
4458 }
4459
4460 foreach (SceneObjectGroup att in GetAttachments())
4461 {
4462 SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart);
4463 SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding);
4464 SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd);
4465
4466 if (startedColliders.Contains(0))
4467 SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart);
4468 if (m_lastColliders.Contains(0))
4469 SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding);
4470 if (endedColliders.Contains(0))
4471 SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd);
4472 }
4473 }
4474 finally
4475 {
4476 m_collisionEventFlag = false;
4477 }
4478 }
4479
4043 private void TeleportFlagsDebug() { 4480 private void TeleportFlagsDebug() {
4044 4481
4045 // Some temporary debugging help to show all the TeleportFlags we have... 4482 // Some temporary debugging help to show all the TeleportFlags we have...
@@ -4064,6 +4501,5 @@ namespace OpenSim.Region.Framework.Scenes
4064 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); 4501 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
4065 4502
4066 } 4503 }
4067
4068 } 4504 }
4069} 4505}