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.cs904
1 files changed, 641 insertions, 263 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 58721b0..041eac2 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
@@ -560,7 +588,18 @@ namespace OpenSim.Region.Framework.Scenes
560 set 588 set
561 { 589 {
562 m_bodyRot = value; 590 m_bodyRot = value;
563// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); 591 // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
592 if (PhysicsActor != null)
593 {
594 try
595 {
596 PhysicsActor.Orientation = value;
597 }
598 catch (Exception e)
599 {
600 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message);
601 }
602 }
564 } 603 }
565 } 604 }
566 605
@@ -571,6 +610,13 @@ namespace OpenSim.Region.Framework.Scenes
571 /// </summary> 610 /// </summary>
572 public uint ParentID { get; set; } 611 public uint ParentID { get; set; }
573 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
574 /// <summary> 620 /// <summary>
575 /// Are we sitting on an object? 621 /// Are we sitting on an object?
576 /// </summary> 622 /// </summary>
@@ -737,6 +783,33 @@ namespace OpenSim.Region.Framework.Scenes
737 Appearance = appearance; 783 Appearance = appearance;
738 } 784 }
739 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
740 public void RegisterToEvents() 813 public void RegisterToEvents()
741 { 814 {
742 ControllingClient.OnCompleteMovementToRegion += CompleteMovement; 815 ControllingClient.OnCompleteMovementToRegion += CompleteMovement;
@@ -746,8 +819,10 @@ namespace OpenSim.Region.Framework.Scenes
746 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; 819 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
747 ControllingClient.OnStartAnim += HandleStartAnim; 820 ControllingClient.OnStartAnim += HandleStartAnim;
748 ControllingClient.OnStopAnim += HandleStopAnim; 821 ControllingClient.OnStopAnim += HandleStopAnim;
822 ControllingClient.OnChangeAnim += avnHandleChangeAnim;
749 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; 823 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls;
750 ControllingClient.OnAutoPilotGo += MoveToTarget; 824 ControllingClient.OnAutoPilotGo += MoveToTarget;
825 ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles;
751 826
752 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 827 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
753 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 828 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@@ -806,10 +881,39 @@ namespace OpenSim.Region.Framework.Scenes
806 "[SCENE]: Upgrading child to root agent for {0} in {1}", 881 "[SCENE]: Upgrading child to root agent for {0} in {1}",
807 Name, m_scene.RegionInfo.RegionName); 882 Name, m_scene.RegionInfo.RegionName);
808 883
809 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
810
811 bool wasChild = IsChildAgent; 884 bool wasChild = IsChildAgent;
812 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
813 917
814 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 918 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
815 if (gm != null) 919 if (gm != null)
@@ -819,62 +923,72 @@ namespace OpenSim.Region.Framework.Scenes
819 923
820 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 924 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
821 925
822 // Moved this from SendInitialData to ensure that Appearance is initialized 926 if (ParentID == 0)
823 // before the inventory is processed in MakeRootAgent. This fixes a race condition
824 // related to the handling of attachments
825 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
826 if (m_scene.TestBorderCross(pos, Cardinals.E))
827 { 927 {
828 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); 928 // Moved this from SendInitialData to ensure that Appearance is initialized
829 pos.X = crossedBorder.BorderLine.Z - 1; 929 // before the inventory is processed in MakeRootAgent. This fixes a race condition
830 } 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 }
831 937
832 if (m_scene.TestBorderCross(pos, Cardinals.N)) 938 if (m_scene.TestBorderCross(pos, Cardinals.N))
833 { 939 {
834 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); 940 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
835 pos.Y = crossedBorder.BorderLine.Z - 1; 941 pos.Y = crossedBorder.BorderLine.Z - 1;
836 } 942 }
837 943
838 CheckAndAdjustLandingPoint(ref pos); 944 CheckAndAdjustLandingPoint(ref pos);
839 945
840 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 946 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
841 { 947 {
842 m_log.WarnFormat( 948 m_log.WarnFormat(
843 "[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",
844 pos, Name, UUID); 950 pos, Name, UUID);
845 951
846 if (pos.X < 0f) pos.X = 0f; 952 if (pos.X < 0f) pos.X = 0f;
847 if (pos.Y < 0f) pos.Y = 0f; 953 if (pos.Y < 0f) pos.Y = 0f;
848 if (pos.Z < 0f) pos.Z = 0f; 954 if (pos.Z < 0f) pos.Z = 0f;
849 } 955 }
850 956
851 float localAVHeight = 1.56f; 957 float localAVHeight = 1.56f;
852 if (Appearance.AvatarHeight > 0) 958 if (Appearance.AvatarHeight > 0)
853 localAVHeight = Appearance.AvatarHeight; 959 localAVHeight = Appearance.AvatarHeight;
854 960
855 float posZLimit = 0; 961 float posZLimit = 0;
856 962
857 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 963 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
858 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 964 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
859 965
860 float newPosZ = posZLimit + localAVHeight / 2; 966 float newPosZ = posZLimit + localAVHeight / 2;
861 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)))
862 { 968 {
863 pos.Z = newPosZ; 969 pos.Z = newPosZ;
864 } 970 }
865 AbsolutePosition = pos; 971 AbsolutePosition = pos;
866 972
867 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);
868 982
869 if (ForceFly) 983 if (ForceFly)
870 { 984 {
871 Flying = true; 985 Flying = true;
872 } 986 }
873 else if (FlyDisabled) 987 else if (FlyDisabled)
874 { 988 {
875 Flying = false; 989 Flying = false;
990 }
876 } 991 }
877
878 // 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
879 // 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
880 // elsewhere anyway 994 // elsewhere anyway
@@ -894,14 +1008,19 @@ namespace OpenSim.Region.Framework.Scenes
894 "[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);
895 1009
896 // Resume scripts 1010 // Resume scripts
897 foreach (SceneObjectGroup sog in m_attachments) 1011 Util.FireAndForget(delegate(object x) {
898 { 1012 foreach (SceneObjectGroup sog in m_attachments)
899 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 1013 {
900 sog.ResumeScripts(); 1014 sog.ScheduleGroupForFullUpdate();
901 } 1015 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1016 sog.ResumeScripts();
1017 }
1018 });
902 } 1019 }
903 } 1020 }
904 1021
1022 SendAvatarDataToAllAgents();
1023
905 // send the animations of the other presences to me 1024 // send the animations of the other presences to me
906 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) 1025 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
907 { 1026 {
@@ -912,9 +1031,12 @@ namespace OpenSim.Region.Framework.Scenes
912 // 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
913 // 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
914 // recorded, which stops the input from being processed. 1033 // recorded, which stops the input from being processed.
1034
915 MovementFlag = 0; 1035 MovementFlag = 0;
916 1036
917 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1037 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1038
1039 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
918 } 1040 }
919 1041
920 public int GetStateSource() 1042 public int GetStateSource()
@@ -942,12 +1064,16 @@ namespace OpenSim.Region.Framework.Scenes
942 /// </remarks> 1064 /// </remarks>
943 public void MakeChildAgent() 1065 public void MakeChildAgent()
944 { 1066 {
1067 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
1068
945 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);
946 1070
947 // 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
948 // as teleporting back 1072 // as teleporting back
949 TeleportFlags = TeleportFlags.Default; 1073 TeleportFlags = TeleportFlags.Default;
950 1074
1075 MovementFlag = 0;
1076
951 // It looks like Animator is set to null somewhere, and MakeChild 1077 // It looks like Animator is set to null somewhere, and MakeChild
952 // is called after that. Probably in aborted teleports. 1078 // is called after that. Probably in aborted teleports.
953 if (Animator == null) 1079 if (Animator == null)
@@ -955,6 +1081,7 @@ namespace OpenSim.Region.Framework.Scenes
955 else 1081 else
956 Animator.ResetAnimations(); 1082 Animator.ResetAnimations();
957 1083
1084
958// m_log.DebugFormat( 1085// m_log.DebugFormat(
959// "[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}",
960// Name, UUID, m_scene.RegionInfo.RegionName); 1087// Name, UUID, m_scene.RegionInfo.RegionName);
@@ -966,6 +1093,7 @@ namespace OpenSim.Region.Framework.Scenes
966 IsChildAgent = true; 1093 IsChildAgent = true;
967 m_scene.SwapRootAgentCount(true); 1094 m_scene.SwapRootAgentCount(true);
968 RemoveFromPhysicalScene(); 1095 RemoveFromPhysicalScene();
1096 ParentID = 0; // Child agents can't be sitting
969 1097
970 // 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
971 1099
@@ -981,9 +1109,9 @@ namespace OpenSim.Region.Framework.Scenes
981 { 1109 {
982// PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; 1110// PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients;
983 PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; 1111 PhysicsActor.OnOutOfBounds -= OutOfBoundsCall;
984 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor);
985 PhysicsActor.UnSubscribeEvents();
986 PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; 1112 PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate;
1113 PhysicsActor.UnSubscribeEvents();
1114 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor);
987 PhysicsActor = null; 1115 PhysicsActor = null;
988 } 1116 }
989// else 1117// else
@@ -1000,7 +1128,7 @@ namespace OpenSim.Region.Framework.Scenes
1000 /// <param name="pos"></param> 1128 /// <param name="pos"></param>
1001 public void Teleport(Vector3 pos) 1129 public void Teleport(Vector3 pos)
1002 { 1130 {
1003 TeleportWithMomentum(pos, null); 1131 TeleportWithMomentum(pos, Vector3.Zero);
1004 } 1132 }
1005 1133
1006 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1134 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
@@ -1024,6 +1152,41 @@ namespace OpenSim.Region.Framework.Scenes
1024 SendTerseUpdateToAllClients(); 1152 SendTerseUpdateToAllClients();
1025 } 1153 }
1026 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
1027 public void StopFlying() 1190 public void StopFlying()
1028 { 1191 {
1029 ControllingClient.StopFlying(this); 1192 ControllingClient.StopFlying(this);
@@ -1114,6 +1277,13 @@ namespace OpenSim.Region.Framework.Scenes
1114 PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); 1277 PhysicsActor.Size = new Vector3(0.45f, 0.6f, height);
1115 } 1278 }
1116 1279
1280 public void SetSize(Vector3 size, float feetoffset)
1281 {
1282 if (PhysicsActor != null && !IsChildAgent)
1283 PhysicsActor.setAvatarSize(size, feetoffset);
1284
1285 }
1286
1117 /// <summary> 1287 /// <summary>
1118 /// Complete Avatar's movement into the region. 1288 /// Complete Avatar's movement into the region.
1119 /// </summary> 1289 /// </summary>
@@ -1133,7 +1303,8 @@ namespace OpenSim.Region.Framework.Scenes
1133 1303
1134 Vector3 look = Velocity; 1304 Vector3 look = Velocity;
1135 1305
1136 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))
1137 { 1308 {
1138 look = new Vector3(0.99f, 0.042f, 0); 1309 look = new Vector3(0.99f, 0.042f, 0);
1139 } 1310 }
@@ -1183,13 +1354,15 @@ namespace OpenSim.Region.Framework.Scenes
1183 // Create child agents in neighbouring regions 1354 // Create child agents in neighbouring regions
1184 if (openChildAgents && !IsChildAgent) 1355 if (openChildAgents && !IsChildAgent)
1185 { 1356 {
1357
1186 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); 1358 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1187 if (m_agentTransfer != null) 1359 if (m_agentTransfer != null)
1188 Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); 1360 m_agentTransfer.EnableChildAgents(this);
1189 1361
1190 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 1362 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1191 if (friendsModule != null) 1363 if (friendsModule != null)
1192 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1364 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1365
1193 } 1366 }
1194 1367
1195// m_log.DebugFormat( 1368// m_log.DebugFormat(
@@ -1339,8 +1512,18 @@ namespace OpenSim.Region.Framework.Scenes
1339 { 1512 {
1340 if (m_followCamAuto) 1513 if (m_followCamAuto)
1341 { 1514 {
1342 Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; 1515 // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT;
1343 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
1344 } 1527 }
1345 } 1528 }
1346 1529
@@ -1796,12 +1979,17 @@ namespace OpenSim.Region.Framework.Scenes
1796// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); 1979// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name);
1797 1980
1798 SitGround = false; 1981 SitGround = false;
1982
1983/* move this down so avatar gets physical in the new position and not where it is siting
1799 if (PhysicsActor == null) 1984 if (PhysicsActor == null)
1800 AddToPhysicalScene(false); 1985 AddToPhysicalScene(false);
1986 */
1801 1987
1802 if (ParentID != 0) 1988 if (ParentID != 0)
1803 { 1989 {
1804 SceneObjectPart part = ParentPart; 1990 SceneObjectPart part = ParentPart;
1991 UnRegisterSeatControls(part.ParentGroup.UUID);
1992
1805 TaskInventoryDictionary taskIDict = part.TaskInventory; 1993 TaskInventoryDictionary taskIDict = part.TaskInventory;
1806 if (taskIDict != null) 1994 if (taskIDict != null)
1807 { 1995 {
@@ -1817,14 +2005,22 @@ namespace OpenSim.Region.Framework.Scenes
1817 } 2005 }
1818 } 2006 }
1819 2007
1820 ParentPosition = part.GetWorldPosition(); 2008 part.ParentGroup.DeleteAvatar(UUID);
2009// ParentPosition = part.GetWorldPosition();
1821 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 2010 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1822 2011
1823 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);
1824 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;
1825 2017
1826 ParentID = 0; 2018 ParentID = 0;
1827 ParentPart = null; 2019 ParentPart = null;
2020
2021 if (PhysicsActor == null)
2022 AddToPhysicalScene(false);
2023
1828 SendAvatarDataToAllAgents(); 2024 SendAvatarDataToAllAgents();
1829 m_requestedSitTargetID = 0; 2025 m_requestedSitTargetID = 0;
1830 2026
@@ -1834,6 +2030,9 @@ namespace OpenSim.Region.Framework.Scenes
1834 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 2030 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
1835 } 2031 }
1836 2032
2033 else if (PhysicsActor == null)
2034 AddToPhysicalScene(false);
2035
1837 Animator.TrySetMovementAnimation("STAND"); 2036 Animator.TrySetMovementAnimation("STAND");
1838 } 2037 }
1839 2038
@@ -1885,7 +2084,7 @@ namespace OpenSim.Region.Framework.Scenes
1885 // 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
1886 2085
1887 if (PhysicsActor != null) 2086 if (PhysicsActor != null)
1888 m_sitAvatarHeight = PhysicsActor.Size.Z; 2087 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
1889 2088
1890 bool canSit = false; 2089 bool canSit = false;
1891 Vector3 pos = part.AbsolutePosition + offset; 2090 Vector3 pos = part.AbsolutePosition + offset;
@@ -1902,12 +2101,29 @@ namespace OpenSim.Region.Framework.Scenes
1902 } 2101 }
1903 else 2102 else
1904 { 2103 {
1905 if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) 2104// if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10)
1906 { 2105// {
1907// m_log.DebugFormat( 2106// m_log.DebugFormat(
1908// "[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",
1909// Name, part.Name, part.LocalId); 2108// Name, part.Name, part.LocalId);
1910 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
1911 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); 2127 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
1912 canSit = true; 2128 canSit = true;
1913 } 2129 }
@@ -1934,7 +2150,7 @@ namespace OpenSim.Region.Framework.Scenes
1934 forceMouselook = part.GetForceMouselook(); 2150 forceMouselook = part.GetForceMouselook();
1935 2151
1936 ControllingClient.SendSitResponse( 2152 ControllingClient.SendSitResponse(
1937 targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 2153 part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
1938 2154
1939 m_requestedSitTargetUUID = targetID; 2155 m_requestedSitTargetUUID = targetID;
1940 2156
@@ -1948,6 +2164,9 @@ namespace OpenSim.Region.Framework.Scenes
1948 2164
1949 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) 2165 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset)
1950 { 2166 {
2167 if (IsChildAgent)
2168 return;
2169
1951 if (ParentID != 0) 2170 if (ParentID != 0)
1952 { 2171 {
1953 StandUp(); 2172 StandUp();
@@ -1977,197 +2196,54 @@ namespace OpenSim.Region.Framework.Scenes
1977 SendSitResponse(targetID, offset, Quaternion.Identity); 2196 SendSitResponse(targetID, offset, Quaternion.Identity);
1978 } 2197 }
1979 2198
1980 /* 2199 public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation)
1981 public void SitRayCastAvatarPosition(SceneObjectPart part)
1982 { 2200 {
1983 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
1984 Vector3 StartRayCastPosition = AbsolutePosition;
1985 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
1986 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
1987 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse);
1988 }
1989 2201
1990 public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) 2202 if (status < 0)
1991 {
1992 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
1993 if (part != null)
1994 {
1995 if (hitYN)
1996 {
1997 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
1998 {
1999 SitRaycastFindEdge(collisionPoint, normal);
2000 m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
2001 }
2002 else
2003 {
2004 SitRayCastAvatarPositionCameraZ(part);
2005 }
2006 }
2007 else
2008 {
2009 SitRayCastAvatarPositionCameraZ(part);
2010 }
2011 }
2012 else
2013 { 2203 {
2014 ControllingClient.SendAlertMessage("Sit position no longer exists"); 2204 ControllingClient.SendAlertMessage("Sit position no longer exists");
2015 m_requestedSitTargetUUID = UUID.Zero; 2205 return;
2016 m_requestedSitTargetID = 0;
2017 m_requestedSitOffset = Vector3.Zero;
2018 } 2206 }
2019 2207
2020 } 2208 if (status == 0)
2021 2209 return;
2022 public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part)
2023 {
2024 // Next, try to raycast from the camera Z position
2025 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
2026 Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z;
2027 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
2028 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
2029 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse);
2030 }
2031 2210
2032 public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) 2211 SceneObjectPart part = m_scene.GetSceneObjectPart(partID);
2033 { 2212 if (part == null || part.ParentGroup.IsAttachment)
2034 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID);
2035 if (part != null)
2036 { 2213 {
2037 if (hitYN) 2214 return;
2038 {
2039 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
2040 {
2041 SitRaycastFindEdge(collisionPoint, normal);
2042 m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal);
2043 }
2044 else
2045 {
2046 SitRayCastCameraPosition(part);
2047 }
2048 }
2049 else
2050 {
2051 SitRayCastCameraPosition(part);
2052 }
2053 }
2054 else
2055 {
2056 ControllingClient.SendAlertMessage("Sit position no longer exists");
2057 m_requestedSitTargetUUID = UUID.Zero;
2058 m_requestedSitTargetID = 0;
2059 m_requestedSitOffset = Vector3.Zero;
2060 } 2215 }
2061 2216
2062 } 2217// m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString());
2063 2218
2064 public void SitRayCastCameraPosition(SceneObjectPart part) 2219 part.AddSittingAvatar(UUID);
2065 {
2066 // Next, try to raycast from the camera position
2067 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
2068 Vector3 StartRayCastPosition = CameraPosition;
2069 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
2070 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
2071 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse);
2072 }
2073 2220
2074 public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) 2221 Vector3 cameraAtOffset = part.GetCameraAtOffset();
2075 { 2222 Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
2076 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); 2223 bool forceMouselook = part.GetForceMouselook();
2077 if (part != null)
2078 {
2079 if (hitYN)
2080 {
2081 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
2082 {
2083 SitRaycastFindEdge(collisionPoint, normal);
2084 m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
2085 }
2086 else
2087 {
2088 SitRayHorizontal(part);
2089 }
2090 }
2091 else
2092 {
2093 SitRayHorizontal(part);
2094 }
2095 }
2096 else
2097 {
2098 ControllingClient.SendAlertMessage("Sit position no longer exists");
2099 m_requestedSitTargetUUID = UUID.Zero;
2100 m_requestedSitTargetID = 0;
2101 m_requestedSitOffset = Vector3.Zero;
2102 }
2103 2224
2104 } 2225 ControllingClient.SendSitResponse(
2226 part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
2105 2227
2106 public void SitRayHorizontal(SceneObjectPart part) 2228 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
2107 {
2108 // Next, try to raycast from the avatar position to fwd
2109 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
2110 Vector3 StartRayCastPosition = CameraPosition;
2111 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
2112 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
2113 m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse);
2114 }
2115 2229
2116 public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) 2230 // assuming no autopilot in use
2117 { 2231 Velocity = Vector3.Zero;
2118 SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); 2232 RemoveFromPhysicalScene();
2119 if (part != null)
2120 {
2121 if (hitYN)
2122 {
2123 if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f))
2124 {
2125 SitRaycastFindEdge(collisionPoint, normal);
2126 m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal);
2127 // Next, try to raycast from the camera position
2128 Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset;
2129 Vector3 StartRayCastPosition = CameraPosition;
2130 Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition);
2131 float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition);
2132 //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition);
2133 }
2134 else
2135 {
2136 ControllingClient.SendAlertMessage("Sit position not accessable.");
2137 m_requestedSitTargetUUID = UUID.Zero;
2138 m_requestedSitTargetID = 0;
2139 m_requestedSitOffset = Vector3.Zero;
2140 }
2141 }
2142 else
2143 {
2144 ControllingClient.SendAlertMessage("Sit position not accessable.");
2145 m_requestedSitTargetUUID = UUID.Zero;
2146 m_requestedSitTargetID = 0;
2147 m_requestedSitOffset = Vector3.Zero;
2148 }
2149 }
2150 else
2151 {
2152 ControllingClient.SendAlertMessage("Sit position no longer exists");
2153 m_requestedSitTargetUUID = UUID.Zero;
2154 m_requestedSitTargetID = 0;
2155 m_requestedSitOffset = Vector3.Zero;
2156 }
2157 2233
2158 } 2234 Rotation = Orientation;
2235 m_pos = offset;
2159 2236
2160 private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) 2237 m_requestedSitTargetID = 0; // invalidate the viewer sit comand for now
2161 { 2238 part.ParentGroup.AddAvatar(UUID);
2162 int i = 0; 2239
2163 //throw new NotImplementedException(); 2240 ParentPart = part;
2164 //m_requestedSitTargetUUID = UUID.Zero; 2241 ParentID = part.LocalId;
2165 //m_requestedSitTargetID = 0;
2166 //m_requestedSitOffset = Vector3.Zero;
2167 2242
2168 SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); 2243 Animator.TrySetMovementAnimation("SIT");
2244 SendAvatarDataToAllAgents();
2169 } 2245 }
2170 */ 2246
2171 2247
2172 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) 2248 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
2173 { 2249 {
@@ -2198,14 +2274,39 @@ namespace OpenSim.Region.Framework.Scenes
2198 2274
2199 //Quaternion result = (sitTargetOrient * vq) * nq; 2275 //Quaternion result = (sitTargetOrient * vq) * nq;
2200 2276
2201 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;
2202 Rotation = sitTargetOrient; 2301 Rotation = sitTargetOrient;
2203 ParentPosition = part.AbsolutePosition; 2302// ParentPosition = part.AbsolutePosition;
2303 part.ParentGroup.AddAvatar(UUID);
2204 } 2304 }
2205 else 2305 else
2206 { 2306 {
2207 m_pos -= part.AbsolutePosition; 2307 m_pos -= part.AbsolutePosition;
2208 ParentPosition = part.AbsolutePosition; 2308// ParentPosition = part.AbsolutePosition;
2309 part.ParentGroup.AddAvatar(UUID);
2209 2310
2210// m_log.DebugFormat( 2311// m_log.DebugFormat(
2211// "[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",
@@ -2255,6 +2356,13 @@ namespace OpenSim.Region.Framework.Scenes
2255 Animator.RemoveAnimation(animID); 2356 Animator.RemoveAnimation(animID);
2256 } 2357 }
2257 2358
2359 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack)
2360 {
2361 Animator.avnChangeAnim(animID, addRemove, sendPack);
2362 }
2363
2364
2365
2258 /// <summary> 2366 /// <summary>
2259 /// 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
2260 /// </summary> 2368 /// </summary>
@@ -2308,14 +2416,15 @@ namespace OpenSim.Region.Framework.Scenes
2308 direc.Z *= 2.6f; 2416 direc.Z *= 2.6f;
2309 2417
2310 // 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.
2311 Animator.TrySetMovementAnimation("PREJUMP"); 2419// Animator.TrySetMovementAnimation("PREJUMP");
2312 Animator.TrySetMovementAnimation("JUMP"); 2420// Animator.TrySetMovementAnimation("JUMP");
2313 } 2421 }
2314 } 2422 }
2315 } 2423 }
2316 2424
2317 // 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?
2318 m_forceToApply = direc; 2426 m_forceToApply = direc;
2427 Animator.UpdateMovementAnimations();
2319 } 2428 }
2320 2429
2321 #endregion 2430 #endregion
@@ -2333,9 +2442,13 @@ namespace OpenSim.Region.Framework.Scenes
2333 // 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
2334 // grab the latest PhysicsActor velocity, whereas m_velocity is often 2443 // grab the latest PhysicsActor velocity, whereas m_velocity is often
2335 // storing a requested force instead of an actual traveling velocity 2444 // storing a requested force instead of an actual traveling velocity
2445 if (Appearance.AvatarSize != m_lastSize)
2446 {
2447 m_lastSize = Appearance.AvatarSize;
2448 SendAvatarDataToAllAgents();
2449 }
2336 2450
2337 // Throw away duplicate or insignificant updates 2451 else if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
2338 if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
2339 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || 2452 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
2340 !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) 2453 !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
2341 { 2454 {
@@ -2633,6 +2746,8 @@ namespace OpenSim.Region.Framework.Scenes
2633 2746
2634 avatar.ControllingClient.SendAppearance( 2747 avatar.ControllingClient.SendAppearance(
2635 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); 2748 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes());
2749
2750
2636 } 2751 }
2637 2752
2638 #endregion 2753 #endregion
@@ -2707,8 +2822,9 @@ namespace OpenSim.Region.Framework.Scenes
2707 2822
2708 // If we don't have a PhysActor, we can't cross anyway 2823 // If we don't have a PhysActor, we can't cross anyway
2709 // Also don't do this while sat, sitting avatars cross with the 2824 // Also don't do this while sat, sitting avatars cross with the
2710 // object they sit on. 2825 // object they sit on. ParentUUID denoted a pending sit, don't
2711 if (ParentID != 0 || PhysicsActor == null) 2826 // interfere with it.
2827 if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero)
2712 return; 2828 return;
2713 2829
2714 if (!IsInTransit) 2830 if (!IsInTransit)
@@ -2969,6 +3085,10 @@ namespace OpenSim.Region.Framework.Scenes
2969 } 3085 }
2970 3086
2971 private static Vector3 marker = new Vector3(-1f, -1f, -1f); 3087 private static Vector3 marker = new Vector3(-1f, -1f, -1f);
3088 private void RaiseUpdateThrottles()
3089 {
3090 m_scene.EventManager.TriggerThrottleUpdate(this);
3091 }
2972 /// <summary> 3092 /// <summary>
2973 /// This updates important decision making data about a child agent 3093 /// This updates important decision making data about a child agent
2974 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region 3094 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
@@ -3049,6 +3169,9 @@ namespace OpenSim.Region.Framework.Scenes
3049 cAgent.AlwaysRun = SetAlwaysRun; 3169 cAgent.AlwaysRun = SetAlwaysRun;
3050 3170
3051 cAgent.Appearance = new AvatarAppearance(Appearance); 3171 cAgent.Appearance = new AvatarAppearance(Appearance);
3172
3173 cAgent.ParentPart = ParentUUID;
3174 cAgent.SitOffset = m_pos;
3052 3175
3053 lock (scriptedcontrols) 3176 lock (scriptedcontrols)
3054 { 3177 {
@@ -3057,7 +3180,7 @@ namespace OpenSim.Region.Framework.Scenes
3057 3180
3058 foreach (ScriptControllers c in scriptedcontrols.Values) 3181 foreach (ScriptControllers c in scriptedcontrols.Values)
3059 { 3182 {
3060 controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); 3183 controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls);
3061 } 3184 }
3062 cAgent.Controllers = controls; 3185 cAgent.Controllers = controls;
3063 } 3186 }
@@ -3090,6 +3213,8 @@ namespace OpenSim.Region.Framework.Scenes
3090 CameraAtAxis = cAgent.AtAxis; 3213 CameraAtAxis = cAgent.AtAxis;
3091 CameraLeftAxis = cAgent.LeftAxis; 3214 CameraLeftAxis = cAgent.LeftAxis;
3092 CameraUpAxis = cAgent.UpAxis; 3215 CameraUpAxis = cAgent.UpAxis;
3216 ParentUUID = cAgent.ParentPart;
3217 m_prevSitOffset = cAgent.SitOffset;
3093 3218
3094 // When we get to the point of re-computing neighbors everytime this 3219 // When we get to the point of re-computing neighbors everytime this
3095 // changes, then start using the agent's drawdistance rather than the 3220 // changes, then start using the agent's drawdistance rather than the
@@ -3127,6 +3252,7 @@ namespace OpenSim.Region.Framework.Scenes
3127 foreach (ControllerData c in cAgent.Controllers) 3252 foreach (ControllerData c in cAgent.Controllers)
3128 { 3253 {
3129 ScriptControllers sc = new ScriptControllers(); 3254 ScriptControllers sc = new ScriptControllers();
3255 sc.objectID = c.ObjectID;
3130 sc.itemID = c.ItemID; 3256 sc.itemID = c.ItemID;
3131 sc.ignoreControls = (ScriptControlled)c.IgnoreControls; 3257 sc.ignoreControls = (ScriptControlled)c.IgnoreControls;
3132 sc.eventControls = (ScriptControlled)c.EventControls; 3258 sc.eventControls = (ScriptControlled)c.EventControls;
@@ -3194,20 +3320,27 @@ namespace OpenSim.Region.Framework.Scenes
3194 } 3320 }
3195 3321
3196 if (Appearance.AvatarHeight == 0) 3322 if (Appearance.AvatarHeight == 0)
3197 Appearance.SetHeight(); 3323// Appearance.SetHeight();
3324 Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f));
3198 3325
3199 PhysicsScene scene = m_scene.PhysicsScene; 3326 PhysicsScene scene = m_scene.PhysicsScene;
3200 3327
3201 Vector3 pVec = AbsolutePosition; 3328 Vector3 pVec = AbsolutePosition;
3202 3329
3330/*
3331 PhysicsActor = scene.AddAvatar(
3332 LocalId, Firstname + "." + Lastname, pVec,
3333 new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying);
3334*/
3335
3203 PhysicsActor = scene.AddAvatar( 3336 PhysicsActor = scene.AddAvatar(
3204 LocalId, Firstname + "." + Lastname, pVec, 3337 LocalId, Firstname + "." + Lastname, pVec,
3205 new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); 3338 Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying);
3206 3339
3207 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 3340 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
3208 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 3341 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
3209 PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong 3342 PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
3210 PhysicsActor.SubscribeEvents(500); 3343 PhysicsActor.SubscribeEvents(100);
3211 PhysicsActor.LocalID = LocalId; 3344 PhysicsActor.LocalID = LocalId;
3212 } 3345 }
3213 3346
@@ -3221,6 +3354,7 @@ namespace OpenSim.Region.Framework.Scenes
3221 ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); 3354 ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true);
3222 } 3355 }
3223 3356
3357
3224 /// <summary> 3358 /// <summary>
3225 /// Event called by the physics plugin to tell the avatar about a collision. 3359 /// Event called by the physics plugin to tell the avatar about a collision.
3226 /// </summary> 3360 /// </summary>
@@ -3234,7 +3368,7 @@ namespace OpenSim.Region.Framework.Scenes
3234 /// <param name="e"></param> 3368 /// <param name="e"></param>
3235 public void PhysicsCollisionUpdate(EventArgs e) 3369 public void PhysicsCollisionUpdate(EventArgs e)
3236 { 3370 {
3237 if (IsChildAgent) 3371 if (IsChildAgent || Animator == null)
3238 return; 3372 return;
3239 3373
3240 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) 3374 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
@@ -3250,7 +3384,6 @@ namespace OpenSim.Region.Framework.Scenes
3250 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 3384 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
3251 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 3385 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
3252 3386
3253 CollisionPlane = Vector4.UnitW;
3254 3387
3255// // No collisions at all means we may be flying. Update always 3388// // No collisions at all means we may be flying. Update always
3256// // to make falling work 3389// // to make falling work
@@ -3262,6 +3395,7 @@ namespace OpenSim.Region.Framework.Scenes
3262 3395
3263 if (coldata.Count != 0) 3396 if (coldata.Count != 0)
3264 { 3397 {
3398/*
3265 switch (Animator.CurrentMovementAnimation) 3399 switch (Animator.CurrentMovementAnimation)
3266 { 3400 {
3267 case "STAND": 3401 case "STAND":
@@ -3270,24 +3404,38 @@ namespace OpenSim.Region.Framework.Scenes
3270 case "CROUCH": 3404 case "CROUCH":
3271 case "CROUCHWALK": 3405 case "CROUCHWALK":
3272 { 3406 {
3407 */
3273 ContactPoint lowest; 3408 ContactPoint lowest;
3274 lowest.SurfaceNormal = Vector3.Zero; 3409 lowest.SurfaceNormal = Vector3.Zero;
3275 lowest.Position = Vector3.Zero; 3410 lowest.Position = Vector3.Zero;
3276 lowest.Position.Z = Single.NaN; 3411 lowest.Position.Z = float.MaxValue;
3277 3412
3278 foreach (ContactPoint contact in coldata.Values) 3413 foreach (ContactPoint contact in coldata.Values)
3279 { 3414 {
3280 if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) 3415
3416 if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z)
3281 { 3417 {
3282 lowest = contact; 3418 lowest = contact;
3283 } 3419 }
3284 } 3420 }
3285 3421
3286 CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); 3422 if (lowest.Position.Z != float.MaxValue)
3423 {
3424 lowest.SurfaceNormal = -lowest.SurfaceNormal;
3425 CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal));
3426 }
3427 else
3428 CollisionPlane = Vector4.UnitW;
3429/*
3287 } 3430 }
3288 break; 3431 break;
3289 } 3432 }
3433*/
3290 } 3434 }
3435 else
3436 CollisionPlane = Vector4.UnitW;
3437
3438 RaiseCollisionScriptEvents(coldata);
3291 3439
3292 // Gods do not take damage and Invulnerable is set depending on parcel/region flags 3440 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
3293 if (Invulnerable || GodLevel > 0) 3441 if (Invulnerable || GodLevel > 0)
@@ -3386,6 +3534,13 @@ namespace OpenSim.Region.Framework.Scenes
3386 // m_reprioritizationTimer.Dispose(); 3534 // m_reprioritizationTimer.Dispose();
3387 3535
3388 RemoveFromPhysicalScene(); 3536 RemoveFromPhysicalScene();
3537
3538 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
3539
3540// if (Animator != null)
3541// Animator.Close();
3542 Animator = null;
3543
3389 } 3544 }
3390 3545
3391 public void AddAttachment(SceneObjectGroup gobj) 3546 public void AddAttachment(SceneObjectGroup gobj)
@@ -3619,10 +3774,18 @@ namespace OpenSim.Region.Framework.Scenes
3619 3774
3620 public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) 3775 public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID)
3621 { 3776 {
3777 SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID);
3778 if (p == null)
3779 return;
3780
3781 ControllingClient.SendTakeControls(controls, false, false);
3782 ControllingClient.SendTakeControls(controls, true, false);
3783
3622 ScriptControllers obj = new ScriptControllers(); 3784 ScriptControllers obj = new ScriptControllers();
3623 obj.ignoreControls = ScriptControlled.CONTROL_ZERO; 3785 obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
3624 obj.eventControls = ScriptControlled.CONTROL_ZERO; 3786 obj.eventControls = ScriptControlled.CONTROL_ZERO;
3625 3787
3788 obj.objectID = p.ParentGroup.UUID;
3626 obj.itemID = Script_item_UUID; 3789 obj.itemID = Script_item_UUID;
3627 if (pass_on == 0 && accept == 0) 3790 if (pass_on == 0 && accept == 0)
3628 { 3791 {
@@ -3671,6 +3834,21 @@ namespace OpenSim.Region.Framework.Scenes
3671 ControllingClient.SendTakeControls(int.MaxValue, false, false); 3834 ControllingClient.SendTakeControls(int.MaxValue, false, false);
3672 } 3835 }
3673 3836
3837 private void UnRegisterSeatControls(UUID obj)
3838 {
3839 List<UUID> takers = new List<UUID>();
3840
3841 foreach (ScriptControllers c in scriptedcontrols.Values)
3842 {
3843 if (c.objectID == obj)
3844 takers.Add(c.itemID);
3845 }
3846 foreach (UUID t in takers)
3847 {
3848 UnRegisterControlEventsToScript(0, t);
3849 }
3850 }
3851
3674 public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) 3852 public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID)
3675 { 3853 {
3676 ScriptControllers takecontrols; 3854 ScriptControllers takecontrols;
@@ -3989,6 +4167,12 @@ namespace OpenSim.Region.Framework.Scenes
3989 4167
3990 private void CheckAndAdjustLandingPoint(ref Vector3 pos) 4168 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3991 { 4169 {
4170 string reason;
4171
4172 // Honor bans
4173 if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y))
4174 return;
4175
3992 SceneObjectGroup telehub = null; 4176 SceneObjectGroup telehub = null;
3993 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) 4177 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null)
3994 { 4178 {
@@ -4028,11 +4212,206 @@ namespace OpenSim.Region.Framework.Scenes
4028 pos = land.LandData.UserLocation; 4212 pos = land.LandData.UserLocation;
4029 } 4213 }
4030 } 4214 }
4031 4215
4032 land.SendLandUpdateToClient(ControllingClient); 4216 land.SendLandUpdateToClient(ControllingClient);
4033 } 4217 }
4034 } 4218 }
4035 4219
4220 private DetectedObject CreateDetObject(SceneObjectPart obj)
4221 {
4222 DetectedObject detobj = new DetectedObject();
4223 detobj.keyUUID = obj.UUID;
4224 detobj.nameStr = obj.Name;
4225 detobj.ownerUUID = obj.OwnerID;
4226 detobj.posVector = obj.AbsolutePosition;
4227 detobj.rotQuat = obj.GetWorldRotation();
4228 detobj.velVector = obj.Velocity;
4229 detobj.colliderType = 0;
4230 detobj.groupUUID = obj.GroupID;
4231
4232 return detobj;
4233 }
4234
4235 private DetectedObject CreateDetObject(ScenePresence av)
4236 {
4237 DetectedObject detobj = new DetectedObject();
4238 detobj.keyUUID = av.UUID;
4239 detobj.nameStr = av.ControllingClient.Name;
4240 detobj.ownerUUID = av.UUID;
4241 detobj.posVector = av.AbsolutePosition;
4242 detobj.rotQuat = av.Rotation;
4243 detobj.velVector = av.Velocity;
4244 detobj.colliderType = 0;
4245 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
4246
4247 return detobj;
4248 }
4249
4250 private DetectedObject CreateDetObjectForGround()
4251 {
4252 DetectedObject detobj = new DetectedObject();
4253 detobj.keyUUID = UUID.Zero;
4254 detobj.nameStr = "";
4255 detobj.ownerUUID = UUID.Zero;
4256 detobj.posVector = AbsolutePosition;
4257 detobj.rotQuat = Quaternion.Identity;
4258 detobj.velVector = Vector3.Zero;
4259 detobj.colliderType = 0;
4260 detobj.groupUUID = UUID.Zero;
4261
4262 return detobj;
4263 }
4264
4265 private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders)
4266 {
4267 ColliderArgs colliderArgs = new ColliderArgs();
4268 List<DetectedObject> colliding = new List<DetectedObject>();
4269 foreach (uint localId in colliders)
4270 {
4271 if (localId == 0)
4272 continue;
4273
4274 SceneObjectPart obj = m_scene.GetSceneObjectPart(localId);
4275 if (obj != null)
4276 {
4277 if (!dest.CollisionFilteredOut(obj.UUID, obj.Name))
4278 colliding.Add(CreateDetObject(obj));
4279 }
4280 else
4281 {
4282 ScenePresence av = m_scene.GetScenePresence(localId);
4283 if (av != null && (!av.IsChildAgent))
4284 {
4285 if (!dest.CollisionFilteredOut(av.UUID, av.Name))
4286 colliding.Add(CreateDetObject(av));
4287 }
4288 }
4289 }
4290
4291 colliderArgs.Colliders = colliding;
4292
4293 return colliderArgs;
4294 }
4295
4296 private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message);
4297
4298 private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify)
4299 {
4300 ColliderArgs CollidingMessage;
4301
4302 if (colliders.Count > 0)
4303 {
4304 if ((dest.RootPart.ScriptEvents & ev) != 0)
4305 {
4306 CollidingMessage = CreateColliderArgs(dest.RootPart, colliders);
4307
4308 if (CollidingMessage.Colliders.Count > 0)
4309 notify(dest.RootPart.LocalId, CollidingMessage);
4310 }
4311 }
4312 }
4313
4314 private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify)
4315 {
4316 if ((dest.RootPart.ScriptEvents & ev) != 0)
4317 {
4318 ColliderArgs LandCollidingMessage = new ColliderArgs();
4319 List<DetectedObject> colliding = new List<DetectedObject>();
4320
4321 colliding.Add(CreateDetObjectForGround());
4322 LandCollidingMessage.Colliders = colliding;
4323
4324 notify(dest.RootPart.LocalId, LandCollidingMessage);
4325 }
4326 }
4327
4328 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
4329 {
4330 try
4331 {
4332 List<uint> thisHitColliders = new List<uint>();
4333 List<uint> endedColliders = new List<uint>();
4334 List<uint> startedColliders = new List<uint>();
4335 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
4336 CollisionForSoundInfo soundinfo;
4337 ContactPoint curcontact;
4338
4339 if (coldata.Count == 0)
4340 {
4341 if (m_lastColliders.Count == 0)
4342 return; // nothing to do
4343
4344 foreach (uint localID in m_lastColliders)
4345 {
4346 endedColliders.Add(localID);
4347 }
4348 m_lastColliders.Clear();
4349 }
4350
4351 else
4352 {
4353 foreach (uint id in coldata.Keys)
4354 {
4355 thisHitColliders.Add(id);
4356 if (!m_lastColliders.Contains(id))
4357 {
4358 startedColliders.Add(id);
4359 curcontact = coldata[id];
4360 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
4361 {
4362 soundinfo = new CollisionForSoundInfo();
4363 soundinfo.colliderID = id;
4364 soundinfo.position = curcontact.Position;
4365 soundinfo.relativeVel = curcontact.RelativeSpeed;
4366 soundinfolist.Add(soundinfo);
4367 }
4368 }
4369 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
4370 }
4371
4372 // calculate things that ended colliding
4373 foreach (uint localID in m_lastColliders)
4374 {
4375 if (!thisHitColliders.Contains(localID))
4376 {
4377 endedColliders.Add(localID);
4378 }
4379 }
4380 //add the items that started colliding this time to the last colliders list.
4381 foreach (uint localID in startedColliders)
4382 {
4383 m_lastColliders.Add(localID);
4384 }
4385 // remove things that ended colliding from the last colliders list
4386 foreach (uint localID in endedColliders)
4387 {
4388 m_lastColliders.Remove(localID);
4389 }
4390
4391 if (soundinfolist.Count > 0)
4392 CollisionSounds.AvatarCollisionSound(this, soundinfolist);
4393 }
4394
4395 foreach (SceneObjectGroup att in GetAttachments())
4396 {
4397 SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart);
4398 SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding);
4399 SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd);
4400
4401 if (startedColliders.Contains(0))
4402 SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart);
4403 if (m_lastColliders.Contains(0))
4404 SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding);
4405 if (endedColliders.Contains(0))
4406 SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd);
4407 }
4408 }
4409 finally
4410 {
4411 m_collisionEventFlag = false;
4412 }
4413 }
4414
4036 private void TeleportFlagsDebug() { 4415 private void TeleportFlagsDebug() {
4037 4416
4038 // Some temporary debugging help to show all the TeleportFlags we have... 4417 // Some temporary debugging help to show all the TeleportFlags we have...
@@ -4057,6 +4436,5 @@ namespace OpenSim.Region.Framework.Scenes
4057 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); 4436 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
4058 4437
4059 } 4438 }
4060
4061 } 4439 }
4062} 4440}