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.cs900
1 files changed, 637 insertions, 263 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 0219540..fa1a5af 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.
@@ -139,6 +140,8 @@ namespace OpenSim.Region.Framework.Scenes
139 private Vector3 m_lastPosition; 140 private Vector3 m_lastPosition;
140 private Quaternion m_lastRotation; 141 private Quaternion m_lastRotation;
141 private Vector3 m_lastVelocity; 142 private Vector3 m_lastVelocity;
143 private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f);
144
142 145
143 private Vector3? m_forceToApply; 146 private Vector3? m_forceToApply;
144 private int m_userFlags; 147 private int m_userFlags;
@@ -171,6 +174,7 @@ namespace OpenSim.Region.Framework.Scenes
171// private int m_lastColCount = -1; //KF: Look for Collision chnages 174// private int m_lastColCount = -1; //KF: Look for Collision chnages
172// private int m_updateCount = 0; //KF: Update Anims for a while 175// 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 176// private static readonly int UPDATE_COUNT = 10; // how many frames to update for
177 private List<uint> m_lastColliders = new List<uint>();
174 178
175 private TeleportFlags m_teleportFlags; 179 private TeleportFlags m_teleportFlags;
176 public TeleportFlags TeleportFlags 180 public TeleportFlags TeleportFlags
@@ -230,6 +234,13 @@ namespace OpenSim.Region.Framework.Scenes
230 //private int m_moveToPositionStateStatus; 234 //private int m_moveToPositionStateStatus;
231 //***************************************************** 235 //*****************************************************
232 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
233 protected AvatarAppearance m_appearance; 244 protected AvatarAppearance m_appearance;
234 245
235 public AvatarAppearance Appearance 246 public AvatarAppearance Appearance
@@ -424,7 +435,7 @@ namespace OpenSim.Region.Framework.Scenes
424 get { return (IClientCore)ControllingClient; } 435 get { return (IClientCore)ControllingClient; }
425 } 436 }
426 437
427 public Vector3 ParentPosition { get; set; } 438// public Vector3 ParentPosition { get; set; }
428 439
429 /// <summary> 440 /// <summary>
430 /// 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
@@ -482,7 +493,7 @@ namespace OpenSim.Region.Framework.Scenes
482 if (ParentID == 0) 493 if (ParentID == 0)
483 { 494 {
484 m_pos = value; 495 m_pos = value;
485 ParentPosition = Vector3.Zero; 496// ParentPosition = Vector3.Zero;
486 } 497 }
487 498
488 //m_log.DebugFormat( 499 //m_log.DebugFormat(
@@ -551,7 +562,24 @@ namespace OpenSim.Region.Framework.Scenes
551// Scene.RegionInfo.RegionName, Name, m_velocity); 562// Scene.RegionInfo.RegionName, Name, m_velocity);
552 } 563 }
553 } 564 }
565/*
566 public override Vector3 AngularVelocity
567 {
568 get
569 {
570 if (PhysicsActor != null)
571 {
572 m_rotationalvelocity = PhysicsActor.RotationalVelocity;
554 573
574 // m_log.DebugFormat(
575 // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
576 // m_velocity, Name, Scene.RegionInfo.RegionName);
577 }
578
579 return m_rotationalvelocity;
580 }
581 }
582*/
555 private Quaternion m_bodyRot = Quaternion.Identity; 583 private Quaternion m_bodyRot = Quaternion.Identity;
556 584
557 public Quaternion Rotation 585 public Quaternion Rotation
@@ -562,7 +590,14 @@ namespace OpenSim.Region.Framework.Scenes
562 m_bodyRot = value; 590 m_bodyRot = value;
563 if (PhysicsActor != null) 591 if (PhysicsActor != null)
564 { 592 {
565 PhysicsActor.Orientation = m_bodyRot; 593 try
594 {
595 PhysicsActor.Orientation = m_bodyRot;
596 }
597 catch (Exception e)
598 {
599 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message);
600 }
566 } 601 }
567// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); 602// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
568 } 603 }
@@ -575,6 +610,13 @@ namespace OpenSim.Region.Framework.Scenes
575 /// </summary> 610 /// </summary>
576 public uint ParentID { get; set; } 611 public uint ParentID { get; set; }
577 612
613 public UUID ParentUUID
614 {
615 get { return m_parentUUID; }
616 set { m_parentUUID = value; }
617 }
618 private UUID m_parentUUID = UUID.Zero;
619
578 /// <summary> 620 /// <summary>
579 /// Are we sitting on an object? 621 /// Are we sitting on an object?
580 /// </summary> 622 /// </summary>
@@ -741,6 +783,33 @@ namespace OpenSim.Region.Framework.Scenes
741 Appearance = appearance; 783 Appearance = appearance;
742 } 784 }
743 785
786 private void RegionHeartbeatEnd(Scene scene)
787 {
788 if (IsChildAgent)
789 return;
790
791 m_movementAnimationUpdateCounter ++;
792 if (m_movementAnimationUpdateCounter >= 2)
793 {
794 m_movementAnimationUpdateCounter = 0;
795 if (Animator != null)
796 {
797 // If the parentID == 0 we are not sitting
798 // if !SitGournd then we are not sitting on the ground
799 // Fairly straightforward, now here comes the twist
800 // if ParentUUID is NOT UUID.Zero, we are looking to
801 // be sat on an object that isn't there yet. Should
802 // be treated as if sat.
803 if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting
804 Animator.UpdateMovementAnimations();
805 }
806 else
807 {
808 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
809 }
810 }
811 }
812
744 public void RegisterToEvents() 813 public void RegisterToEvents()
745 { 814 {
746 ControllingClient.OnCompleteMovementToRegion += CompleteMovement; 815 ControllingClient.OnCompleteMovementToRegion += CompleteMovement;
@@ -750,8 +819,10 @@ namespace OpenSim.Region.Framework.Scenes
750 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; 819 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
751 ControllingClient.OnStartAnim += HandleStartAnim; 820 ControllingClient.OnStartAnim += HandleStartAnim;
752 ControllingClient.OnStopAnim += HandleStopAnim; 821 ControllingClient.OnStopAnim += HandleStopAnim;
822 ControllingClient.OnChangeAnim += avnHandleChangeAnim;
753 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; 823 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls;
754 ControllingClient.OnAutoPilotGo += MoveToTarget; 824 ControllingClient.OnAutoPilotGo += MoveToTarget;
825 ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles;
755 826
756 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 827 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
757 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 828 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@@ -810,10 +881,39 @@ namespace OpenSim.Region.Framework.Scenes
810 "[SCENE]: Upgrading child to root agent for {0} in {1}", 881 "[SCENE]: Upgrading child to root agent for {0} in {1}",
811 Name, m_scene.RegionInfo.RegionName); 882 Name, m_scene.RegionInfo.RegionName);
812 883
813 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
814
815 bool wasChild = IsChildAgent; 884 bool wasChild = IsChildAgent;
816 IsChildAgent = false; 885
886 if (ParentUUID != UUID.Zero)
887 {
888 m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID);
889 SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID);
890 if (part == null)
891 {
892 m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID);
893 }
894 else
895 {
896 part.ParentGroup.AddAvatar(UUID);
897 if (part.SitTargetPosition != Vector3.Zero)
898 part.SitTargetAvatar = UUID;
899// ParentPosition = part.GetWorldPosition();
900 ParentID = part.LocalId;
901 ParentPart = part;
902 m_pos = m_prevSitOffset;
903// pos = ParentPosition;
904 pos = part.GetWorldPosition();
905 }
906 ParentUUID = UUID.Zero;
907
908 IsChildAgent = false;
909
910// Animator.TrySetMovementAnimation("SIT");
911 }
912 else
913 {
914 IsChildAgent = false;
915 }
916
817 917
818 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 918 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
819 if (gm != null) 919 if (gm != null)
@@ -823,62 +923,72 @@ namespace OpenSim.Region.Framework.Scenes
823 923
824 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 924 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
825 925
826 // Moved this from SendInitialData to ensure that Appearance is initialized 926 if (ParentID == 0)
827 // before the inventory is processed in MakeRootAgent. This fixes a race condition
828 // related to the handling of attachments
829 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
830 if (m_scene.TestBorderCross(pos, Cardinals.E))
831 { 927 {
832 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); 928 // Moved this from SendInitialData to ensure that Appearance is initialized
833 pos.X = crossedBorder.BorderLine.Z - 1; 929 // before the inventory is processed in MakeRootAgent. This fixes a race condition
834 } 930 // related to the handling of attachments
931 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
932 if (m_scene.TestBorderCross(pos, Cardinals.E))
933 {
934 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
935 pos.X = crossedBorder.BorderLine.Z - 1;
936 }
835 937
836 if (m_scene.TestBorderCross(pos, Cardinals.N)) 938 if (m_scene.TestBorderCross(pos, Cardinals.N))
837 { 939 {
838 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); 940 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
839 pos.Y = crossedBorder.BorderLine.Z - 1; 941 pos.Y = crossedBorder.BorderLine.Z - 1;
840 } 942 }
841 943
842 CheckAndAdjustLandingPoint(ref pos); 944 CheckAndAdjustLandingPoint(ref pos);
843 945
844 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 946 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
845 { 947 {
846 m_log.WarnFormat( 948 m_log.WarnFormat(
847 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", 949 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
848 pos, Name, UUID); 950 pos, Name, UUID);
849 951
850 if (pos.X < 0f) pos.X = 0f; 952 if (pos.X < 0f) pos.X = 0f;
851 if (pos.Y < 0f) pos.Y = 0f; 953 if (pos.Y < 0f) pos.Y = 0f;
852 if (pos.Z < 0f) pos.Z = 0f; 954 if (pos.Z < 0f) pos.Z = 0f;
853 } 955 }
854 956
855 float localAVHeight = 1.56f; 957 float localAVHeight = 1.56f;
856 if (Appearance.AvatarHeight > 0) 958 if (Appearance.AvatarHeight > 0)
857 localAVHeight = Appearance.AvatarHeight; 959 localAVHeight = Appearance.AvatarHeight;
858 960
859 float posZLimit = 0; 961 float posZLimit = 0;
860 962
861 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 963 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
862 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 964 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
863 965
864 float newPosZ = posZLimit + localAVHeight / 2; 966 float newPosZ = posZLimit + localAVHeight / 2;
865 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) 967 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
866 { 968 {
867 pos.Z = newPosZ; 969 pos.Z = newPosZ;
868 } 970 }
869 AbsolutePosition = pos; 971 AbsolutePosition = pos;
870 972
871 AddToPhysicalScene(isFlying); 973 if (m_teleportFlags == TeleportFlags.Default)
974 {
975 Vector3 vel = Velocity;
976 AddToPhysicalScene(isFlying);
977 if (PhysicsActor != null)
978 PhysicsActor.SetMomentum(vel);
979 }
980 else
981 AddToPhysicalScene(isFlying);
872 982
873 if (ForceFly) 983 if (ForceFly)
874 { 984 {
875 Flying = true; 985 Flying = true;
876 } 986 }
877 else if (FlyDisabled) 987 else if (FlyDisabled)
878 { 988 {
879 Flying = false; 989 Flying = false;
990 }
880 } 991 }
881
882 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 992 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
883 // avatar to return to the standing position in mid-air. On login it looks like this is being sent 993 // avatar to return to the standing position in mid-air. On login it looks like this is being sent
884 // elsewhere anyway 994 // elsewhere anyway
@@ -898,14 +1008,19 @@ namespace OpenSim.Region.Framework.Scenes
898 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); 1008 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
899 1009
900 // Resume scripts 1010 // Resume scripts
901 foreach (SceneObjectGroup sog in m_attachments) 1011 Util.FireAndForget(delegate(object x) {
902 { 1012 foreach (SceneObjectGroup sog in m_attachments)
903 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 1013 {
904 sog.ResumeScripts(); 1014 sog.ScheduleGroupForFullUpdate();
905 } 1015 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1016 sog.ResumeScripts();
1017 }
1018 });
906 } 1019 }
907 } 1020 }
908 1021
1022 SendAvatarDataToAllAgents();
1023
909 // send the animations of the other presences to me 1024 // send the animations of the other presences to me
910 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) 1025 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
911 { 1026 {
@@ -916,9 +1031,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 1031 // 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 1032 // 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. 1033 // recorded, which stops the input from being processed.
1034
919 MovementFlag = 0; 1035 MovementFlag = 0;
920 1036
921 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1037 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1038
1039 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
922 } 1040 }
923 1041
924 public int GetStateSource() 1042 public int GetStateSource()
@@ -946,12 +1064,16 @@ namespace OpenSim.Region.Framework.Scenes
946 /// </remarks> 1064 /// </remarks>
947 public void MakeChildAgent() 1065 public void MakeChildAgent()
948 { 1066 {
1067 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
1068
949 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); 1069 m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName);
950 1070
951 // Reset these so that teleporting in and walking out isn't seen 1071 // Reset these so that teleporting in and walking out isn't seen
952 // as teleporting back 1072 // as teleporting back
953 TeleportFlags = TeleportFlags.Default; 1073 TeleportFlags = TeleportFlags.Default;
954 1074
1075 MovementFlag = 0;
1076
955 // It looks like Animator is set to null somewhere, and MakeChild 1077 // It looks like Animator is set to null somewhere, and MakeChild
956 // is called after that. Probably in aborted teleports. 1078 // is called after that. Probably in aborted teleports.
957 if (Animator == null) 1079 if (Animator == null)
@@ -959,6 +1081,7 @@ namespace OpenSim.Region.Framework.Scenes
959 else 1081 else
960 Animator.ResetAnimations(); 1082 Animator.ResetAnimations();
961 1083
1084
962// m_log.DebugFormat( 1085// m_log.DebugFormat(
963// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", 1086// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
964// Name, UUID, m_scene.RegionInfo.RegionName); 1087// Name, UUID, m_scene.RegionInfo.RegionName);
@@ -970,6 +1093,7 @@ namespace OpenSim.Region.Framework.Scenes
970 IsChildAgent = true; 1093 IsChildAgent = true;
971 m_scene.SwapRootAgentCount(true); 1094 m_scene.SwapRootAgentCount(true);
972 RemoveFromPhysicalScene(); 1095 RemoveFromPhysicalScene();
1096 ParentID = 0; // Child agents can't be sitting
973 1097
974 // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into 1098 // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into
975 1099
@@ -985,9 +1109,9 @@ namespace OpenSim.Region.Framework.Scenes
985 { 1109 {
986// PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; 1110// PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients;
987 PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; 1111 PhysicsActor.OnOutOfBounds -= OutOfBoundsCall;
988 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor);
989 PhysicsActor.UnSubscribeEvents();
990 PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; 1112 PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate;
1113 PhysicsActor.UnSubscribeEvents();
1114 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor);
991 PhysicsActor = null; 1115 PhysicsActor = null;
992 } 1116 }
993// else 1117// else
@@ -1004,7 +1128,7 @@ namespace OpenSim.Region.Framework.Scenes
1004 /// <param name="pos"></param> 1128 /// <param name="pos"></param>
1005 public void Teleport(Vector3 pos) 1129 public void Teleport(Vector3 pos)
1006 { 1130 {
1007 TeleportWithMomentum(pos, null); 1131 TeleportWithMomentum(pos, Vector3.Zero);
1008 } 1132 }
1009 1133
1010 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1134 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
@@ -1028,6 +1152,41 @@ namespace OpenSim.Region.Framework.Scenes
1028 SendTerseUpdateToAllClients(); 1152 SendTerseUpdateToAllClients();
1029 } 1153 }
1030 1154
1155 public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY)
1156 {
1157 CheckLandingPoint(ref newpos);
1158 AbsolutePosition = newpos;
1159
1160 if (newvel.HasValue)
1161 {
1162 if ((Vector3)newvel == Vector3.Zero)
1163 {
1164 if (PhysicsActor != null)
1165 PhysicsActor.SetMomentum(Vector3.Zero);
1166 m_velocity = Vector3.Zero;
1167 }
1168 else
1169 {
1170 if (PhysicsActor != null)
1171 PhysicsActor.SetMomentum((Vector3)newvel);
1172 m_velocity = (Vector3)newvel;
1173
1174 if (rotateToVelXY)
1175 {
1176 Vector3 lookAt = (Vector3)newvel;
1177 lookAt.Z = 0;
1178 lookAt.Normalize();
1179 ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation);
1180 return;
1181 }
1182 }
1183 }
1184
1185 SendTerseUpdateToAllClients();
1186 }
1187
1188
1189
1031 public void StopFlying() 1190 public void StopFlying()
1032 { 1191 {
1033 ControllingClient.StopFlying(this); 1192 ControllingClient.StopFlying(this);
@@ -1118,6 +1277,13 @@ namespace OpenSim.Region.Framework.Scenes
1118 PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); 1277 PhysicsActor.Size = new Vector3(0.45f, 0.6f, height);
1119 } 1278 }
1120 1279
1280 public void SetSize(Vector3 size, float feetoffset)
1281 {
1282 if (PhysicsActor != null && !IsChildAgent)
1283 PhysicsActor.setAvatarSize(size, feetoffset);
1284
1285 }
1286
1121 /// <summary> 1287 /// <summary>
1122 /// Complete Avatar's movement into the region. 1288 /// Complete Avatar's movement into the region.
1123 /// </summary> 1289 /// </summary>
@@ -1137,7 +1303,8 @@ namespace OpenSim.Region.Framework.Scenes
1137 1303
1138 Vector3 look = Velocity; 1304 Vector3 look = Velocity;
1139 1305
1140 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1306 // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1307 if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1))
1141 { 1308 {
1142 look = new Vector3(0.99f, 0.042f, 0); 1309 look = new Vector3(0.99f, 0.042f, 0);
1143 } 1310 }
@@ -1187,13 +1354,15 @@ namespace OpenSim.Region.Framework.Scenes
1187 // Create child agents in neighbouring regions 1354 // Create child agents in neighbouring regions
1188 if (openChildAgents && !IsChildAgent) 1355 if (openChildAgents && !IsChildAgent)
1189 { 1356 {
1357
1190 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); 1358 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1191 if (m_agentTransfer != null) 1359 if (m_agentTransfer != null)
1192 Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); 1360 m_agentTransfer.EnableChildAgents(this);
1193 1361
1194 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 1362 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1195 if (friendsModule != null) 1363 if (friendsModule != null)
1196 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1364 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1365
1197 } 1366 }
1198 1367
1199// m_log.DebugFormat( 1368// m_log.DebugFormat(
@@ -1343,8 +1512,18 @@ namespace OpenSim.Region.Framework.Scenes
1343 { 1512 {
1344 if (m_followCamAuto) 1513 if (m_followCamAuto)
1345 { 1514 {
1346 Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; 1515 // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT;
1347 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); 1516 // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback);
1517
1518 Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT;
1519 Vector3 distTocam = CameraPosition - posAdjusted;
1520 float distTocamlen = distTocam.Length();
1521 if (distTocamlen > 0)
1522 {
1523 distTocam *= 1.0f / distTocamlen;
1524 m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback);
1525 }
1526
1348 } 1527 }
1349 } 1528 }
1350 1529
@@ -1800,12 +1979,17 @@ namespace OpenSim.Region.Framework.Scenes
1800// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); 1979// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name);
1801 1980
1802 SitGround = false; 1981 SitGround = false;
1982
1983/* move this down so avatar gets physical in the new position and not where it is siting
1803 if (PhysicsActor == null) 1984 if (PhysicsActor == null)
1804 AddToPhysicalScene(false); 1985 AddToPhysicalScene(false);
1986 */
1805 1987
1806 if (ParentID != 0) 1988 if (ParentID != 0)
1807 { 1989 {
1808 SceneObjectPart part = ParentPart; 1990 SceneObjectPart part = ParentPart;
1991 UnRegisterSeatControls(part.ParentGroup.UUID);
1992
1809 TaskInventoryDictionary taskIDict = part.TaskInventory; 1993 TaskInventoryDictionary taskIDict = part.TaskInventory;
1810 if (taskIDict != null) 1994 if (taskIDict != null)
1811 { 1995 {
@@ -1821,14 +2005,22 @@ namespace OpenSim.Region.Framework.Scenes
1821 } 2005 }
1822 } 2006 }
1823 2007
1824 ParentPosition = part.GetWorldPosition(); 2008 part.ParentGroup.DeleteAvatar(UUID);
2009// ParentPosition = part.GetWorldPosition();
1825 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 2010 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1826 2011
1827 m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); 2012// m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
1828 ParentPosition = Vector3.Zero; 2013// ParentPosition = Vector3.Zero;
2014 m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
2015 if (part.SitTargetAvatar == UUID)
2016 m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation;
1829 2017
1830 ParentID = 0; 2018 ParentID = 0;
1831 ParentPart = null; 2019 ParentPart = null;
2020
2021 if (PhysicsActor == null)
2022 AddToPhysicalScene(false);
2023
1832 SendAvatarDataToAllAgents(); 2024 SendAvatarDataToAllAgents();
1833 m_requestedSitTargetID = 0; 2025 m_requestedSitTargetID = 0;
1834 2026
@@ -1838,6 +2030,9 @@ namespace OpenSim.Region.Framework.Scenes
1838 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 2030 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
1839 } 2031 }
1840 2032
2033 else if (PhysicsActor == null)
2034 AddToPhysicalScene(false);
2035
1841 Animator.TrySetMovementAnimation("STAND"); 2036 Animator.TrySetMovementAnimation("STAND");
1842 } 2037 }
1843 2038
@@ -1889,7 +2084,7 @@ namespace OpenSim.Region.Framework.Scenes
1889 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it 2084 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
1890 2085
1891 if (PhysicsActor != null) 2086 if (PhysicsActor != null)
1892 m_sitAvatarHeight = PhysicsActor.Size.Z; 2087 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
1893 2088
1894 bool canSit = false; 2089 bool canSit = false;
1895 Vector3 pos = part.AbsolutePosition + offset; 2090 Vector3 pos = part.AbsolutePosition + offset;
@@ -1906,12 +2101,29 @@ namespace OpenSim.Region.Framework.Scenes
1906 } 2101 }
1907 else 2102 else
1908 { 2103 {
1909 if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) 2104// if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10)
1910 { 2105// {
1911// m_log.DebugFormat( 2106// m_log.DebugFormat(
1912// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", 2107// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m",
1913// Name, part.Name, part.LocalId); 2108// Name, part.Name, part.LocalId);
1914 2109
2110 if (m_scene.PhysicsScene != null &&
2111 part.PhysActor != null &&
2112 Util.GetDistanceTo(AbsolutePosition, pos) <= 30)
2113 {
2114
2115 Vector3 camdif = CameraPosition - part.AbsolutePosition;
2116 camdif.Normalize();
2117
2118// m_log.InfoFormat("sit {0} {1}", offset.ToString(), camdif.ToString());
2119
2120 if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0)
2121 return;
2122 }
2123
2124 if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10)
2125 {
2126
1915 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); 2127 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
1916 canSit = true; 2128 canSit = true;
1917 } 2129 }
@@ -1938,7 +2150,7 @@ namespace OpenSim.Region.Framework.Scenes
1938 forceMouselook = part.GetForceMouselook(); 2150 forceMouselook = part.GetForceMouselook();
1939 2151
1940 ControllingClient.SendSitResponse( 2152 ControllingClient.SendSitResponse(
1941 targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 2153 part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
1942 2154
1943 m_requestedSitTargetUUID = targetID; 2155 m_requestedSitTargetUUID = targetID;
1944 2156
@@ -1952,6 +2164,9 @@ namespace OpenSim.Region.Framework.Scenes
1952 2164
1953 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) 2165 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset)
1954 { 2166 {
2167 if (IsChildAgent)
2168 return;
2169
1955 if (ParentID != 0) 2170 if (ParentID != 0)
1956 { 2171 {
1957 StandUp(); 2172 StandUp();
@@ -1981,197 +2196,54 @@ namespace OpenSim.Region.Framework.Scenes
1981 SendSitResponse(targetID, offset, Quaternion.Identity); 2196 SendSitResponse(targetID, offset, Quaternion.Identity);
1982 } 2197 }
1983 2198
1984 /* 2199 public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation)
1985 public void SitRayCastAvatarPosition(SceneObjectPart part)
1986 { 2200 {
1987 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
1988 Vector3 StartRayCastPosition = AbsolutePosition;
1989 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
1990 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
1991 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse);
1992 }
1993 2201
1994 public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) 2202 if (status < 0)
1995 {
1996 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
1997 if (part != null)
1998 {
1999 if (hitYN)
2000 {
2001 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
2002 {
2003 SitRaycastFindEdge(collisionPoint, normal);
2004 m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
2005 }
2006 else
2007 {
2008 SitRayCastAvatarPositionCameraZ(part);
2009 }
2010 }
2011 else
2012 {
2013 SitRayCastAvatarPositionCameraZ(part);
2014 }
2015 }
2016 else
2017 { 2203 {
2018 ControllingClient.SendAlertMessage("Sit position no longer exists"); 2204 ControllingClient.SendAlertMessage("Sit position no longer exists");
2019 m_requestedSitTargetUUID = UUID.Zero; 2205 return;
2020 m_requestedSitTargetID = 0;
2021 m_requestedSitOffset = Vector3.Zero;
2022 } 2206 }
2023 2207
2024 } 2208 if (status == 0)
2025 2209 return;
2026 public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part)
2027 {
2028 // Next, try to raycast from the camera Z position
2029 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
2030 Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z;
2031 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
2032 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
2033 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse);
2034 }
2035 2210
2036 public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) 2211 SceneObjectPart part = m_scene.GetSceneObjectPart(partID);
2037 { 2212 if (part == null || part.ParentGroup.IsAttachment)
2038 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
2039 if (part != null)
2040 { 2213 {
2041 if (hitYN) 2214 return;
2042 {
2043 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
2044 {
2045 SitRaycastFindEdge(collisionPoint, normal);
2046 m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal);
2047 }
2048 else
2049 {
2050 SitRayCastCameraPosition(part);
2051 }
2052 }
2053 else
2054 {
2055 SitRayCastCameraPosition(part);
2056 }
2057 }
2058 else
2059 {
2060 ControllingClient.SendAlertMessage("Sit position no longer exists");
2061 m_requestedSitTargetUUID = UUID.Zero;
2062 m_requestedSitTargetID = 0;
2063 m_requestedSitOffset = Vector3.Zero;
2064 } 2215 }
2065 2216
2066 } 2217// m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString());
2067 2218
2068 public void SitRayCastCameraPosition(SceneObjectPart part) 2219 part.AddSittingAvatar(UUID);
2069 {
2070 // Next, try to raycast from the camera position
2071 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
2072 Vector3 StartRayCastPosition = CameraPosition;
2073 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
2074 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
2075 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse);
2076 }
2077 2220
2078 public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) 2221 Vector3 cameraAtOffset = part.GetCameraAtOffset();
2079 { 2222 Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
2080 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); 2223 bool forceMouselook = part.GetForceMouselook();
2081 if (part != null)
2082 {
2083 if (hitYN)
2084 {
2085 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
2086 {
2087 SitRaycastFindEdge(collisionPoint, normal);
2088 m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
2089 }
2090 else
2091 {
2092 SitRayHorizontal(part);
2093 }
2094 }
2095 else
2096 {
2097 SitRayHorizontal(part);
2098 }
2099 }
2100 else
2101 {
2102 ControllingClient.SendAlertMessage("Sit position no longer exists");
2103 m_requestedSitTargetUUID = UUID.Zero;
2104 m_requestedSitTargetID = 0;
2105 m_requestedSitOffset = Vector3.Zero;
2106 }
2107 2224
2108 } 2225 ControllingClient.SendSitResponse(
2226 part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
2109 2227
2110 public void SitRayHorizontal(SceneObjectPart part) 2228 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
2111 {
2112 // Next, try to raycast from the avatar position to fwd
2113 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
2114 Vector3 StartRayCastPosition = CameraPosition;
2115 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
2116 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
2117 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse);
2118 }
2119 2229
2120 public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) 2230 // assuming no autopilot in use
2121 { 2231 Velocity = Vector3.Zero;
2122 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); 2232 RemoveFromPhysicalScene();
2123 if (part != null)
2124 {
2125 if (hitYN)
2126 {
2127 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
2128 {
2129 SitRaycastFindEdge(collisionPoint, normal);
2130 m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
2131 // Next, try to raycast from the camera position
2132 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
2133 Vector3 StartRayCastPosition = CameraPosition;
2134 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
2135 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
2136 //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition);
2137 }
2138 else
2139 {
2140 ControllingClient.SendAlertMessage("Sit position not accessable.");
2141 m_requestedSitTargetUUID = UUID.Zero;
2142 m_requestedSitTargetID = 0;
2143 m_requestedSitOffset = Vector3.Zero;
2144 }
2145 }
2146 else
2147 {
2148 ControllingClient.SendAlertMessage("Sit position not accessable.");
2149 m_requestedSitTargetUUID = UUID.Zero;
2150 m_requestedSitTargetID = 0;
2151 m_requestedSitOffset = Vector3.Zero;
2152 }
2153 }
2154 else
2155 {
2156 ControllingClient.SendAlertMessage("Sit position no longer exists");
2157 m_requestedSitTargetUUID = UUID.Zero;
2158 m_requestedSitTargetID = 0;
2159 m_requestedSitOffset = Vector3.Zero;
2160 }
2161 2233
2162 } 2234 Rotation = Orientation;
2235 m_pos = offset;
2163 2236
2164 private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) 2237 m_requestedSitTargetID = 0; // invalidate the viewer sit comand for now
2165 { 2238 part.ParentGroup.AddAvatar(UUID);
2166 int i = 0;
2167 //throw new NotImplementedException();
2168 //m_requestedSitTargetUUID = UUID.Zero;
2169 //m_requestedSitTargetID = 0;
2170 //m_requestedSitOffset = Vector3.Zero;
2171 2239
2172 SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); 2240 ParentPart = part;
2241 ParentID = part.LocalId;
2242
2243 Animator.TrySetMovementAnimation("SIT");
2244 SendAvatarDataToAllAgents();
2173 } 2245 }
2174 */ 2246
2175 2247
2176 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) 2248 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
2177 { 2249 {
@@ -2202,14 +2274,39 @@ namespace OpenSim.Region.Framework.Scenes
2202 2274
2203 //Quaternion result = (sitTargetOrient * vq) * nq; 2275 //Quaternion result = (sitTargetOrient * vq) * nq;
2204 2276
2205 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2277 double x, y, z, m;
2278
2279 Quaternion r = sitTargetOrient;
2280 m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W;
2281
2282 if (Math.Abs(1.0 - m) > 0.000001)
2283 {
2284 m = 1.0 / Math.Sqrt(m);
2285 r.X *= (float)m;
2286 r.Y *= (float)m;
2287 r.Z *= (float)m;
2288 r.W *= (float)m;
2289 }
2290
2291 x = 2 * (r.X * r.Z + r.Y * r.W);
2292 y = 2 * (-r.X * r.W + r.Y * r.Z);
2293 z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W;
2294
2295 Vector3 up = new Vector3((float)x, (float)y, (float)z);
2296 Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f;
2297
2298 m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT;
2299
2300// m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset;
2206 Rotation = sitTargetOrient; 2301 Rotation = sitTargetOrient;
2207 ParentPosition = part.AbsolutePosition; 2302// ParentPosition = part.AbsolutePosition;
2303 part.ParentGroup.AddAvatar(UUID);
2208 } 2304 }
2209 else 2305 else
2210 { 2306 {
2211 m_pos -= part.AbsolutePosition; 2307 m_pos -= part.AbsolutePosition;
2212 ParentPosition = part.AbsolutePosition; 2308// ParentPosition = part.AbsolutePosition;
2309 part.ParentGroup.AddAvatar(UUID);
2213 2310
2214// m_log.DebugFormat( 2311// m_log.DebugFormat(
2215// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", 2312// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
@@ -2259,6 +2356,13 @@ namespace OpenSim.Region.Framework.Scenes
2259 Animator.RemoveAnimation(animID); 2356 Animator.RemoveAnimation(animID);
2260 } 2357 }
2261 2358
2359 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack)
2360 {
2361 Animator.avnChangeAnim(animID, addRemove, sendPack);
2362 }
2363
2364
2365
2262 /// <summary> 2366 /// <summary>
2263 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector 2367 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector
2264 /// </summary> 2368 /// </summary>
@@ -2312,14 +2416,15 @@ namespace OpenSim.Region.Framework.Scenes
2312 direc.Z *= 2.6f; 2416 direc.Z *= 2.6f;
2313 2417
2314 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. 2418 // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored.
2315 Animator.TrySetMovementAnimation("PREJUMP"); 2419// Animator.TrySetMovementAnimation("PREJUMP");
2316 Animator.TrySetMovementAnimation("JUMP"); 2420// Animator.TrySetMovementAnimation("JUMP");
2317 } 2421 }
2318 } 2422 }
2319 } 2423 }
2320 2424
2321 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2425 // TODO: Add the force instead of only setting it to support multiple forces per frame?
2322 m_forceToApply = direc; 2426 m_forceToApply = direc;
2427 Animator.UpdateMovementAnimations();
2323 } 2428 }
2324 2429
2325 #endregion 2430 #endregion
@@ -2337,9 +2442,13 @@ namespace OpenSim.Region.Framework.Scenes
2337 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to 2442 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to
2338 // grab the latest PhysicsActor velocity, whereas m_velocity is often 2443 // grab the latest PhysicsActor velocity, whereas m_velocity is often
2339 // storing a requested force instead of an actual traveling velocity 2444 // storing a requested force instead of an actual traveling velocity
2340 2445 if (Appearance.AvatarSize != m_lastSize)
2446 {
2447 m_lastSize = Appearance.AvatarSize;
2448 SendAvatarDataToAllAgents();
2449 }
2341 // Throw away duplicate or insignificant updates 2450 // Throw away duplicate or insignificant updates
2342 if ( 2451 else if (
2343 // If the velocity has become zero, send it no matter what. 2452 // If the velocity has become zero, send it no matter what.
2344 (Velocity != m_lastVelocity && Velocity == Vector3.Zero) 2453 (Velocity != m_lastVelocity && Velocity == Vector3.Zero)
2345 // otherwise, if things have changed reasonably, send the update 2454 // otherwise, if things have changed reasonably, send the update
@@ -2642,6 +2751,8 @@ namespace OpenSim.Region.Framework.Scenes
2642 2751
2643 avatar.ControllingClient.SendAppearance( 2752 avatar.ControllingClient.SendAppearance(
2644 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); 2753 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes());
2754
2755
2645 } 2756 }
2646 2757
2647 #endregion 2758 #endregion
@@ -2716,8 +2827,9 @@ namespace OpenSim.Region.Framework.Scenes
2716 2827
2717 // If we don't have a PhysActor, we can't cross anyway 2828 // If we don't have a PhysActor, we can't cross anyway
2718 // Also don't do this while sat, sitting avatars cross with the 2829 // Also don't do this while sat, sitting avatars cross with the
2719 // object they sit on. 2830 // object they sit on. ParentUUID denoted a pending sit, don't
2720 if (ParentID != 0 || PhysicsActor == null) 2831 // interfere with it.
2832 if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero)
2721 return; 2833 return;
2722 2834
2723 if (!IsInTransit) 2835 if (!IsInTransit)
@@ -2978,6 +3090,10 @@ namespace OpenSim.Region.Framework.Scenes
2978 } 3090 }
2979 3091
2980 private static Vector3 marker = new Vector3(-1f, -1f, -1f); 3092 private static Vector3 marker = new Vector3(-1f, -1f, -1f);
3093 private void RaiseUpdateThrottles()
3094 {
3095 m_scene.EventManager.TriggerThrottleUpdate(this);
3096 }
2981 /// <summary> 3097 /// <summary>
2982 /// This updates important decision making data about a child agent 3098 /// This updates important decision making data about a child agent
2983 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region 3099 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
@@ -3058,6 +3174,9 @@ namespace OpenSim.Region.Framework.Scenes
3058 cAgent.AlwaysRun = SetAlwaysRun; 3174 cAgent.AlwaysRun = SetAlwaysRun;
3059 3175
3060 cAgent.Appearance = new AvatarAppearance(Appearance); 3176 cAgent.Appearance = new AvatarAppearance(Appearance);
3177
3178 cAgent.ParentPart = ParentUUID;
3179 cAgent.SitOffset = m_pos;
3061 3180
3062 lock (scriptedcontrols) 3181 lock (scriptedcontrols)
3063 { 3182 {
@@ -3066,7 +3185,7 @@ namespace OpenSim.Region.Framework.Scenes
3066 3185
3067 foreach (ScriptControllers c in scriptedcontrols.Values) 3186 foreach (ScriptControllers c in scriptedcontrols.Values)
3068 { 3187 {
3069 controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); 3188 controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls);
3070 } 3189 }
3071 cAgent.Controllers = controls; 3190 cAgent.Controllers = controls;
3072 } 3191 }
@@ -3099,6 +3218,8 @@ namespace OpenSim.Region.Framework.Scenes
3099 CameraAtAxis = cAgent.AtAxis; 3218 CameraAtAxis = cAgent.AtAxis;
3100 CameraLeftAxis = cAgent.LeftAxis; 3219 CameraLeftAxis = cAgent.LeftAxis;
3101 CameraUpAxis = cAgent.UpAxis; 3220 CameraUpAxis = cAgent.UpAxis;
3221 ParentUUID = cAgent.ParentPart;
3222 m_prevSitOffset = cAgent.SitOffset;
3102 3223
3103 // When we get to the point of re-computing neighbors everytime this 3224 // When we get to the point of re-computing neighbors everytime this
3104 // changes, then start using the agent's drawdistance rather than the 3225 // changes, then start using the agent's drawdistance rather than the
@@ -3136,6 +3257,7 @@ namespace OpenSim.Region.Framework.Scenes
3136 foreach (ControllerData c in cAgent.Controllers) 3257 foreach (ControllerData c in cAgent.Controllers)
3137 { 3258 {
3138 ScriptControllers sc = new ScriptControllers(); 3259 ScriptControllers sc = new ScriptControllers();
3260 sc.objectID = c.ObjectID;
3139 sc.itemID = c.ItemID; 3261 sc.itemID = c.ItemID;
3140 sc.ignoreControls = (ScriptControlled)c.IgnoreControls; 3262 sc.ignoreControls = (ScriptControlled)c.IgnoreControls;
3141 sc.eventControls = (ScriptControlled)c.EventControls; 3263 sc.eventControls = (ScriptControlled)c.EventControls;
@@ -3203,20 +3325,27 @@ namespace OpenSim.Region.Framework.Scenes
3203 } 3325 }
3204 3326
3205 if (Appearance.AvatarHeight == 0) 3327 if (Appearance.AvatarHeight == 0)
3206 Appearance.SetHeight(); 3328// Appearance.SetHeight();
3329 Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f));
3207 3330
3208 PhysicsScene scene = m_scene.PhysicsScene; 3331 PhysicsScene scene = m_scene.PhysicsScene;
3209 3332
3210 Vector3 pVec = AbsolutePosition; 3333 Vector3 pVec = AbsolutePosition;
3211 3334
3335/*
3336 PhysicsActor = scene.AddAvatar(
3337 LocalId, Firstname + "." + Lastname, pVec,
3338 new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying);
3339*/
3340
3212 PhysicsActor = scene.AddAvatar( 3341 PhysicsActor = scene.AddAvatar(
3213 LocalId, Firstname + "." + Lastname, pVec, 3342 LocalId, Firstname + "." + Lastname, pVec,
3214 new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); 3343 Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying);
3215 3344
3216 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 3345 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
3217 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 3346 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
3218 PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong 3347 PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
3219 PhysicsActor.SubscribeEvents(500); 3348 PhysicsActor.SubscribeEvents(100);
3220 PhysicsActor.LocalID = LocalId; 3349 PhysicsActor.LocalID = LocalId;
3221 } 3350 }
3222 3351
@@ -3230,6 +3359,7 @@ namespace OpenSim.Region.Framework.Scenes
3230 ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); 3359 ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true);
3231 } 3360 }
3232 3361
3362
3233 /// <summary> 3363 /// <summary>
3234 /// Event called by the physics plugin to tell the avatar about a collision. 3364 /// Event called by the physics plugin to tell the avatar about a collision.
3235 /// </summary> 3365 /// </summary>
@@ -3243,7 +3373,7 @@ namespace OpenSim.Region.Framework.Scenes
3243 /// <param name="e"></param> 3373 /// <param name="e"></param>
3244 public void PhysicsCollisionUpdate(EventArgs e) 3374 public void PhysicsCollisionUpdate(EventArgs e)
3245 { 3375 {
3246 if (IsChildAgent) 3376 if (IsChildAgent || Animator == null)
3247 return; 3377 return;
3248 3378
3249 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) 3379 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
@@ -3259,7 +3389,6 @@ namespace OpenSim.Region.Framework.Scenes
3259 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 3389 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
3260 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 3390 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
3261 3391
3262 CollisionPlane = Vector4.UnitW;
3263 3392
3264// // No collisions at all means we may be flying. Update always 3393// // No collisions at all means we may be flying. Update always
3265// // to make falling work 3394// // to make falling work
@@ -3271,6 +3400,7 @@ namespace OpenSim.Region.Framework.Scenes
3271 3400
3272 if (coldata.Count != 0) 3401 if (coldata.Count != 0)
3273 { 3402 {
3403/*
3274 switch (Animator.CurrentMovementAnimation) 3404 switch (Animator.CurrentMovementAnimation)
3275 { 3405 {
3276 case "STAND": 3406 case "STAND":
@@ -3279,24 +3409,38 @@ namespace OpenSim.Region.Framework.Scenes
3279 case "CROUCH": 3409 case "CROUCH":
3280 case "CROUCHWALK": 3410 case "CROUCHWALK":
3281 { 3411 {
3412 */
3282 ContactPoint lowest; 3413 ContactPoint lowest;
3283 lowest.SurfaceNormal = Vector3.Zero; 3414 lowest.SurfaceNormal = Vector3.Zero;
3284 lowest.Position = Vector3.Zero; 3415 lowest.Position = Vector3.Zero;
3285 lowest.Position.Z = Single.NaN; 3416 lowest.Position.Z = float.MaxValue;
3286 3417
3287 foreach (ContactPoint contact in coldata.Values) 3418 foreach (ContactPoint contact in coldata.Values)
3288 { 3419 {
3289 if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) 3420
3421 if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z)
3290 { 3422 {
3291 lowest = contact; 3423 lowest = contact;
3292 } 3424 }
3293 } 3425 }
3294 3426
3295 CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); 3427 if (lowest.Position.Z != float.MaxValue)
3428 {
3429 lowest.SurfaceNormal = -lowest.SurfaceNormal;
3430 CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal));
3431 }
3432 else
3433 CollisionPlane = Vector4.UnitW;
3434/*
3296 } 3435 }
3297 break; 3436 break;
3298 } 3437 }
3438*/
3299 } 3439 }
3440 else
3441 CollisionPlane = Vector4.UnitW;
3442
3443 RaiseCollisionScriptEvents(coldata);
3300 3444
3301 // Gods do not take damage and Invulnerable is set depending on parcel/region flags 3445 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
3302 if (Invulnerable || GodLevel > 0) 3446 if (Invulnerable || GodLevel > 0)
@@ -3395,6 +3539,13 @@ namespace OpenSim.Region.Framework.Scenes
3395 // m_reprioritizationTimer.Dispose(); 3539 // m_reprioritizationTimer.Dispose();
3396 3540
3397 RemoveFromPhysicalScene(); 3541 RemoveFromPhysicalScene();
3542
3543 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
3544
3545// if (Animator != null)
3546// Animator.Close();
3547 Animator = null;
3548
3398 } 3549 }
3399 3550
3400 public void AddAttachment(SceneObjectGroup gobj) 3551 public void AddAttachment(SceneObjectGroup gobj)
@@ -3628,10 +3779,18 @@ namespace OpenSim.Region.Framework.Scenes
3628 3779
3629 public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) 3780 public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID)
3630 { 3781 {
3782 SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID);
3783 if (p == null)
3784 return;
3785
3786 ControllingClient.SendTakeControls(controls, false, false);
3787 ControllingClient.SendTakeControls(controls, true, false);
3788
3631 ScriptControllers obj = new ScriptControllers(); 3789 ScriptControllers obj = new ScriptControllers();
3632 obj.ignoreControls = ScriptControlled.CONTROL_ZERO; 3790 obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
3633 obj.eventControls = ScriptControlled.CONTROL_ZERO; 3791 obj.eventControls = ScriptControlled.CONTROL_ZERO;
3634 3792
3793 obj.objectID = p.ParentGroup.UUID;
3635 obj.itemID = Script_item_UUID; 3794 obj.itemID = Script_item_UUID;
3636 if (pass_on == 0 && accept == 0) 3795 if (pass_on == 0 && accept == 0)
3637 { 3796 {
@@ -3680,6 +3839,21 @@ namespace OpenSim.Region.Framework.Scenes
3680 ControllingClient.SendTakeControls(int.MaxValue, false, false); 3839 ControllingClient.SendTakeControls(int.MaxValue, false, false);
3681 } 3840 }
3682 3841
3842 private void UnRegisterSeatControls(UUID obj)
3843 {
3844 List<UUID> takers = new List<UUID>();
3845
3846 foreach (ScriptControllers c in scriptedcontrols.Values)
3847 {
3848 if (c.objectID == obj)
3849 takers.Add(c.itemID);
3850 }
3851 foreach (UUID t in takers)
3852 {
3853 UnRegisterControlEventsToScript(0, t);
3854 }
3855 }
3856
3683 public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) 3857 public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID)
3684 { 3858 {
3685 ScriptControllers takecontrols; 3859 ScriptControllers takecontrols;
@@ -3998,6 +4172,12 @@ namespace OpenSim.Region.Framework.Scenes
3998 4172
3999 private void CheckAndAdjustLandingPoint(ref Vector3 pos) 4173 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
4000 { 4174 {
4175 string reason;
4176
4177 // Honor bans
4178 if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y))
4179 return;
4180
4001 SceneObjectGroup telehub = null; 4181 SceneObjectGroup telehub = null;
4002 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) 4182 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null)
4003 { 4183 {
@@ -4037,11 +4217,206 @@ namespace OpenSim.Region.Framework.Scenes
4037 pos = land.LandData.UserLocation; 4217 pos = land.LandData.UserLocation;
4038 } 4218 }
4039 } 4219 }
4040 4220
4041 land.SendLandUpdateToClient(ControllingClient); 4221 land.SendLandUpdateToClient(ControllingClient);
4042 } 4222 }
4043 } 4223 }
4044 4224
4225 private DetectedObject CreateDetObject(SceneObjectPart obj)
4226 {
4227 DetectedObject detobj = new DetectedObject();
4228 detobj.keyUUID = obj.UUID;
4229 detobj.nameStr = obj.Name;
4230 detobj.ownerUUID = obj.OwnerID;
4231 detobj.posVector = obj.AbsolutePosition;
4232 detobj.rotQuat = obj.GetWorldRotation();
4233 detobj.velVector = obj.Velocity;
4234 detobj.colliderType = 0;
4235 detobj.groupUUID = obj.GroupID;
4236
4237 return detobj;
4238 }
4239
4240 private DetectedObject CreateDetObject(ScenePresence av)
4241 {
4242 DetectedObject detobj = new DetectedObject();
4243 detobj.keyUUID = av.UUID;
4244 detobj.nameStr = av.ControllingClient.Name;
4245 detobj.ownerUUID = av.UUID;
4246 detobj.posVector = av.AbsolutePosition;
4247 detobj.rotQuat = av.Rotation;
4248 detobj.velVector = av.Velocity;
4249 detobj.colliderType = 0;
4250 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
4251
4252 return detobj;
4253 }
4254
4255 private DetectedObject CreateDetObjectForGround()
4256 {
4257 DetectedObject detobj = new DetectedObject();
4258 detobj.keyUUID = UUID.Zero;
4259 detobj.nameStr = "";
4260 detobj.ownerUUID = UUID.Zero;
4261 detobj.posVector = AbsolutePosition;
4262 detobj.rotQuat = Quaternion.Identity;
4263 detobj.velVector = Vector3.Zero;
4264 detobj.colliderType = 0;
4265 detobj.groupUUID = UUID.Zero;
4266
4267 return detobj;
4268 }
4269
4270 private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders)
4271 {
4272 ColliderArgs colliderArgs = new ColliderArgs();
4273 List<DetectedObject> colliding = new List<DetectedObject>();
4274 foreach (uint localId in colliders)
4275 {
4276 if (localId == 0)
4277 continue;
4278
4279 SceneObjectPart obj = m_scene.GetSceneObjectPart(localId);
4280 if (obj != null)
4281 {
4282 if (!dest.CollisionFilteredOut(obj.UUID, obj.Name))
4283 colliding.Add(CreateDetObject(obj));
4284 }
4285 else
4286 {
4287 ScenePresence av = m_scene.GetScenePresence(localId);
4288 if (av != null && (!av.IsChildAgent))
4289 {
4290 if (!dest.CollisionFilteredOut(av.UUID, av.Name))
4291 colliding.Add(CreateDetObject(av));
4292 }
4293 }
4294 }
4295
4296 colliderArgs.Colliders = colliding;
4297
4298 return colliderArgs;
4299 }
4300
4301 private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message);
4302
4303 private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify)
4304 {
4305 ColliderArgs CollidingMessage;
4306
4307 if (colliders.Count > 0)
4308 {
4309 if ((dest.RootPart.ScriptEvents & ev) != 0)
4310 {
4311 CollidingMessage = CreateColliderArgs(dest.RootPart, colliders);
4312
4313 if (CollidingMessage.Colliders.Count > 0)
4314 notify(dest.RootPart.LocalId, CollidingMessage);
4315 }
4316 }
4317 }
4318
4319 private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify)
4320 {
4321 if ((dest.RootPart.ScriptEvents & ev) != 0)
4322 {
4323 ColliderArgs LandCollidingMessage = new ColliderArgs();
4324 List<DetectedObject> colliding = new List<DetectedObject>();
4325
4326 colliding.Add(CreateDetObjectForGround());
4327 LandCollidingMessage.Colliders = colliding;
4328
4329 notify(dest.RootPart.LocalId, LandCollidingMessage);
4330 }
4331 }
4332
4333 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
4334 {
4335 try
4336 {
4337 List<uint> thisHitColliders = new List<uint>();
4338 List<uint> endedColliders = new List<uint>();
4339 List<uint> startedColliders = new List<uint>();
4340 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
4341 CollisionForSoundInfo soundinfo;
4342 ContactPoint curcontact;
4343
4344 if (coldata.Count == 0)
4345 {
4346 if (m_lastColliders.Count == 0)
4347 return; // nothing to do
4348
4349 foreach (uint localID in m_lastColliders)
4350 {
4351 endedColliders.Add(localID);
4352 }
4353 m_lastColliders.Clear();
4354 }
4355
4356 else
4357 {
4358 foreach (uint id in coldata.Keys)
4359 {
4360 thisHitColliders.Add(id);
4361 if (!m_lastColliders.Contains(id))
4362 {
4363 startedColliders.Add(id);
4364 curcontact = coldata[id];
4365 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
4366 {
4367 soundinfo = new CollisionForSoundInfo();
4368 soundinfo.colliderID = id;
4369 soundinfo.position = curcontact.Position;
4370 soundinfo.relativeVel = curcontact.RelativeSpeed;
4371 soundinfolist.Add(soundinfo);
4372 }
4373 }
4374 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
4375 }
4376
4377 // calculate things that ended colliding
4378 foreach (uint localID in m_lastColliders)
4379 {
4380 if (!thisHitColliders.Contains(localID))
4381 {
4382 endedColliders.Add(localID);
4383 }
4384 }
4385 //add the items that started colliding this time to the last colliders list.
4386 foreach (uint localID in startedColliders)
4387 {
4388 m_lastColliders.Add(localID);
4389 }
4390 // remove things that ended colliding from the last colliders list
4391 foreach (uint localID in endedColliders)
4392 {
4393 m_lastColliders.Remove(localID);
4394 }
4395
4396 if (soundinfolist.Count > 0)
4397 CollisionSounds.AvatarCollisionSound(this, soundinfolist);
4398 }
4399
4400 foreach (SceneObjectGroup att in GetAttachments())
4401 {
4402 SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart);
4403 SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding);
4404 SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd);
4405
4406 if (startedColliders.Contains(0))
4407 SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart);
4408 if (m_lastColliders.Contains(0))
4409 SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding);
4410 if (endedColliders.Contains(0))
4411 SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd);
4412 }
4413 }
4414 finally
4415 {
4416 m_collisionEventFlag = false;
4417 }
4418 }
4419
4045 private void TeleportFlagsDebug() { 4420 private void TeleportFlagsDebug() {
4046 4421
4047 // Some temporary debugging help to show all the TeleportFlags we have... 4422 // Some temporary debugging help to show all the TeleportFlags we have...
@@ -4066,6 +4441,5 @@ namespace OpenSim.Region.Framework.Scenes
4066 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); 4441 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
4067 4442
4068 } 4443 }
4069
4070 } 4444 }
4071} 4445}