diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1092 |
1 files changed, 783 insertions, 309 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6d96c93..5ed7b67 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 |
@@ -226,8 +230,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
226 | /// </summary> | 230 | /// </summary> |
227 | public bool LandAtTarget { get; private set; } | 231 | public bool LandAtTarget { get; private set; } |
228 | 232 | ||
229 | private bool m_followCamAuto; | ||
230 | |||
231 | private int m_movementUpdateCount; | 233 | private int m_movementUpdateCount; |
232 | private const int NumMovementsBetweenRayCast = 5; | 234 | private const int NumMovementsBetweenRayCast = 5; |
233 | 235 | ||
@@ -235,6 +237,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
235 | //private int m_moveToPositionStateStatus; | 237 | //private int m_moveToPositionStateStatus; |
236 | //***************************************************** | 238 | //***************************************************** |
237 | 239 | ||
240 | private bool m_collisionEventFlag = false; | ||
241 | private object m_collisionEventLock = new Object(); | ||
242 | |||
243 | private int m_movementAnimationUpdateCounter = 0; | ||
244 | |||
245 | private Vector3 m_prevSitOffset; | ||
246 | |||
238 | protected AvatarAppearance m_appearance; | 247 | protected AvatarAppearance m_appearance; |
239 | 248 | ||
240 | public AvatarAppearance Appearance | 249 | public AvatarAppearance Appearance |
@@ -349,6 +358,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
349 | /// </summary> | 358 | /// </summary> |
350 | protected Vector3 m_lastCameraPosition; | 359 | protected Vector3 m_lastCameraPosition; |
351 | 360 | ||
361 | private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1); | ||
362 | private bool m_doingCamRayCast = false; | ||
363 | |||
352 | public Vector3 CameraPosition { get; set; } | 364 | public Vector3 CameraPosition { get; set; } |
353 | 365 | ||
354 | public Quaternion CameraRotation | 366 | public Quaternion CameraRotation |
@@ -429,7 +441,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
429 | get { return (IClientCore)ControllingClient; } | 441 | get { return (IClientCore)ControllingClient; } |
430 | } | 442 | } |
431 | 443 | ||
432 | public Vector3 ParentPosition { get; set; } | 444 | public UUID COF { get; set; } |
445 | |||
446 | // public Vector3 ParentPosition { get; set; } | ||
433 | 447 | ||
434 | /// <summary> | 448 | /// <summary> |
435 | /// Position of this avatar relative to the region the avatar is in | 449 | /// Position of this avatar relative to the region the avatar is in |
@@ -487,7 +501,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | if (ParentID == 0) | 501 | if (ParentID == 0) |
488 | { | 502 | { |
489 | m_pos = value; | 503 | m_pos = value; |
490 | ParentPosition = Vector3.Zero; | 504 | // ParentPosition = Vector3.Zero; |
491 | } | 505 | } |
492 | 506 | ||
493 | //m_log.DebugFormat( | 507 | //m_log.DebugFormat( |
@@ -556,7 +570,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
556 | // Scene.RegionInfo.RegionName, Name, m_velocity); | 570 | // Scene.RegionInfo.RegionName, Name, m_velocity); |
557 | } | 571 | } |
558 | } | 572 | } |
573 | /* | ||
574 | public override Vector3 AngularVelocity | ||
575 | { | ||
576 | get | ||
577 | { | ||
578 | if (PhysicsActor != null) | ||
579 | { | ||
580 | m_rotationalvelocity = PhysicsActor.RotationalVelocity; | ||
559 | 581 | ||
582 | // m_log.DebugFormat( | ||
583 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
584 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
585 | } | ||
586 | |||
587 | return m_rotationalvelocity; | ||
588 | } | ||
589 | } | ||
590 | */ | ||
560 | private Quaternion m_bodyRot = Quaternion.Identity; | 591 | private Quaternion m_bodyRot = Quaternion.Identity; |
561 | 592 | ||
562 | /// <summary> | 593 | /// <summary> |
@@ -579,8 +610,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
579 | m_bodyRot = value; | 610 | m_bodyRot = value; |
580 | 611 | ||
581 | if (PhysicsActor != null) | 612 | if (PhysicsActor != null) |
582 | PhysicsActor.Orientation = m_bodyRot; | 613 | { |
583 | 614 | try | |
615 | { | ||
616 | PhysicsActor.Orientation = m_bodyRot; | ||
617 | } | ||
618 | catch (Exception e) | ||
619 | { | ||
620 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); | ||
621 | } | ||
622 | } | ||
584 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 623 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
585 | } | 624 | } |
586 | } | 625 | } |
@@ -594,12 +633,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
594 | } | 633 | } |
595 | 634 | ||
596 | public bool IsChildAgent { get; set; } | 635 | public bool IsChildAgent { get; set; } |
636 | public bool IsLoggingIn { get; set; } | ||
597 | 637 | ||
598 | /// <summary> | 638 | /// <summary> |
599 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. | 639 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. |
600 | /// </summary> | 640 | /// </summary> |
601 | public uint ParentID { get; set; } | 641 | public uint ParentID { get; set; } |
602 | 642 | ||
643 | public UUID ParentUUID | ||
644 | { | ||
645 | get { return m_parentUUID; } | ||
646 | set { m_parentUUID = value; } | ||
647 | } | ||
648 | private UUID m_parentUUID = UUID.Zero; | ||
649 | |||
603 | /// <summary> | 650 | /// <summary> |
604 | /// Are we sitting on an object? | 651 | /// Are we sitting on an object? |
605 | /// </summary> | 652 | /// </summary> |
@@ -749,6 +796,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
749 | AttachmentsSyncLock = new Object(); | 796 | AttachmentsSyncLock = new Object(); |
750 | AllowMovement = true; | 797 | AllowMovement = true; |
751 | IsChildAgent = true; | 798 | IsChildAgent = true; |
799 | IsLoggingIn = false; | ||
752 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; | 800 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; |
753 | Animator = new ScenePresenceAnimator(this); | 801 | Animator = new ScenePresenceAnimator(this); |
754 | PresenceType = type; | 802 | PresenceType = type; |
@@ -792,6 +840,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
792 | Appearance = appearance; | 840 | Appearance = appearance; |
793 | } | 841 | } |
794 | 842 | ||
843 | private void RegionHeartbeatEnd(Scene scene) | ||
844 | { | ||
845 | if (IsChildAgent) | ||
846 | return; | ||
847 | |||
848 | m_movementAnimationUpdateCounter ++; | ||
849 | if (m_movementAnimationUpdateCounter >= 2) | ||
850 | { | ||
851 | m_movementAnimationUpdateCounter = 0; | ||
852 | if (Animator != null) | ||
853 | { | ||
854 | // If the parentID == 0 we are not sitting | ||
855 | // if !SitGournd then we are not sitting on the ground | ||
856 | // Fairly straightforward, now here comes the twist | ||
857 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
858 | // be sat on an object that isn't there yet. Should | ||
859 | // be treated as if sat. | ||
860 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
861 | Animator.UpdateMovementAnimations(); | ||
862 | } | ||
863 | else | ||
864 | { | ||
865 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
866 | } | ||
867 | } | ||
868 | } | ||
869 | |||
795 | public void RegisterToEvents() | 870 | public void RegisterToEvents() |
796 | { | 871 | { |
797 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 872 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -801,8 +876,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
801 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 876 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
802 | ControllingClient.OnStartAnim += HandleStartAnim; | 877 | ControllingClient.OnStartAnim += HandleStartAnim; |
803 | ControllingClient.OnStopAnim += HandleStopAnim; | 878 | ControllingClient.OnStopAnim += HandleStopAnim; |
879 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
804 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 880 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
805 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 881 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
882 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
806 | 883 | ||
807 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 884 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
808 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 885 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -861,10 +938,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
861 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 938 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
862 | Name, m_scene.RegionInfo.RegionName); | 939 | Name, m_scene.RegionInfo.RegionName); |
863 | 940 | ||
864 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
865 | |||
866 | bool wasChild = IsChildAgent; | 941 | bool wasChild = IsChildAgent; |
867 | IsChildAgent = false; | 942 | |
943 | if (ParentUUID != UUID.Zero) | ||
944 | { | ||
945 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
946 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
947 | if (part == null) | ||
948 | { | ||
949 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
950 | } | ||
951 | else | ||
952 | { | ||
953 | part.ParentGroup.AddAvatar(UUID); | ||
954 | if (part.SitTargetPosition != Vector3.Zero) | ||
955 | part.SitTargetAvatar = UUID; | ||
956 | // ParentPosition = part.GetWorldPosition(); | ||
957 | ParentID = part.LocalId; | ||
958 | ParentPart = part; | ||
959 | m_pos = m_prevSitOffset; | ||
960 | // pos = ParentPosition; | ||
961 | pos = part.GetWorldPosition(); | ||
962 | } | ||
963 | ParentUUID = UUID.Zero; | ||
964 | |||
965 | IsChildAgent = false; | ||
966 | |||
967 | // Animator.TrySetMovementAnimation("SIT"); | ||
968 | } | ||
969 | else | ||
970 | { | ||
971 | IsChildAgent = false; | ||
972 | IsLoggingIn = false; | ||
973 | } | ||
974 | |||
868 | 975 | ||
869 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 976 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
870 | if (gm != null) | 977 | if (gm != null) |
@@ -874,62 +981,99 @@ namespace OpenSim.Region.Framework.Scenes | |||
874 | 981 | ||
875 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 982 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
876 | 983 | ||
877 | // Moved this from SendInitialData to ensure that Appearance is initialized | 984 | UUID groupUUID = UUID.Zero; |
878 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 985 | string GroupName = string.Empty; |
879 | // related to the handling of attachments | 986 | ulong groupPowers = 0; |
880 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | 987 | |
881 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 988 | // ---------------------------------- |
989 | // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status | ||
990 | try | ||
882 | { | 991 | { |
883 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 992 | if (gm != null) |
884 | pos.X = crossedBorder.BorderLine.Z - 1; | 993 | { |
994 | groupUUID = ControllingClient.ActiveGroupId; | ||
995 | GroupRecord record = gm.GetGroupRecord(groupUUID); | ||
996 | if (record != null) | ||
997 | GroupName = record.GroupName; | ||
998 | GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); | ||
999 | if (groupMembershipData != null) | ||
1000 | groupPowers = groupMembershipData.GroupPowers; | ||
1001 | } | ||
1002 | ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, | ||
1003 | Grouptitle); | ||
885 | } | 1004 | } |
886 | 1005 | catch (Exception e) | |
887 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | ||
888 | { | 1006 | { |
889 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 1007 | m_log.Debug("[AGENTUPDATE]: " + e.ToString()); |
890 | pos.Y = crossedBorder.BorderLine.Z - 1; | ||
891 | } | 1008 | } |
1009 | // ------------------------------------ | ||
892 | 1010 | ||
893 | CheckAndAdjustLandingPoint(ref pos); | 1011 | if (ParentID == 0) |
894 | |||
895 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | ||
896 | { | 1012 | { |
897 | m_log.WarnFormat( | 1013 | // Moved this from SendInitialData to ensure that Appearance is initialized |
898 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 1014 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
899 | pos, Name, UUID); | 1015 | // related to the handling of attachments |
1016 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
1017 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
1018 | { | ||
1019 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
1020 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
1021 | } | ||
900 | 1022 | ||
901 | if (pos.X < 0f) pos.X = 0f; | 1023 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
902 | if (pos.Y < 0f) pos.Y = 0f; | 1024 | { |
903 | if (pos.Z < 0f) pos.Z = 0f; | 1025 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
904 | } | 1026 | pos.Y = crossedBorder.BorderLine.Z - 1; |
1027 | } | ||
905 | 1028 | ||
906 | float localAVHeight = 1.56f; | 1029 | CheckAndAdjustLandingPoint(ref pos); |
907 | if (Appearance.AvatarHeight > 0) | ||
908 | localAVHeight = Appearance.AvatarHeight; | ||
909 | 1030 | ||
910 | float posZLimit = 0; | 1031 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
1032 | { | ||
1033 | m_log.WarnFormat( | ||
1034 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | ||
1035 | pos, Name, UUID); | ||
911 | 1036 | ||
912 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 1037 | if (pos.X < 0f) pos.X = 0f; |
913 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 1038 | if (pos.Y < 0f) pos.Y = 0f; |
914 | 1039 | if (pos.Z < 0f) pos.Z = 0f; | |
915 | float newPosZ = posZLimit + localAVHeight / 2; | 1040 | } |
916 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
917 | { | ||
918 | pos.Z = newPosZ; | ||
919 | } | ||
920 | AbsolutePosition = pos; | ||
921 | 1041 | ||
922 | AddToPhysicalScene(isFlying); | 1042 | float localAVHeight = 1.56f; |
1043 | if (Appearance.AvatarHeight > 0) | ||
1044 | localAVHeight = Appearance.AvatarHeight; | ||
923 | 1045 | ||
924 | if (ForceFly) | 1046 | float posZLimit = 0; |
925 | { | 1047 | |
926 | Flying = true; | 1048 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
927 | } | 1049 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
928 | else if (FlyDisabled) | 1050 | |
929 | { | 1051 | float newPosZ = posZLimit + localAVHeight / 2; |
930 | Flying = false; | 1052 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
931 | } | 1053 | { |
1054 | pos.Z = newPosZ; | ||
1055 | } | ||
1056 | AbsolutePosition = pos; | ||
932 | 1057 | ||
1058 | if (m_teleportFlags == TeleportFlags.Default) | ||
1059 | { | ||
1060 | Vector3 vel = Velocity; | ||
1061 | AddToPhysicalScene(isFlying); | ||
1062 | if (PhysicsActor != null) | ||
1063 | PhysicsActor.SetMomentum(vel); | ||
1064 | } | ||
1065 | else | ||
1066 | AddToPhysicalScene(isFlying); | ||
1067 | |||
1068 | if (ForceFly) | ||
1069 | { | ||
1070 | Flying = true; | ||
1071 | } | ||
1072 | else if (FlyDisabled) | ||
1073 | { | ||
1074 | Flying = false; | ||
1075 | } | ||
1076 | } | ||
933 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1077 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
934 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 1078 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
935 | // elsewhere anyway | 1079 | // elsewhere anyway |
@@ -949,14 +1093,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
949 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | 1093 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
950 | 1094 | ||
951 | // Resume scripts | 1095 | // Resume scripts |
952 | foreach (SceneObjectGroup sog in m_attachments) | 1096 | Util.FireAndForget(delegate(object x) { |
953 | { | 1097 | foreach (SceneObjectGroup sog in m_attachments) |
954 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 1098 | { |
955 | sog.ResumeScripts(); | 1099 | sog.ScheduleGroupForFullUpdate(); |
956 | } | 1100 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
1101 | sog.ResumeScripts(); | ||
1102 | } | ||
1103 | }); | ||
957 | } | 1104 | } |
958 | } | 1105 | } |
959 | 1106 | ||
1107 | SendAvatarDataToAllAgents(); | ||
1108 | |||
960 | // send the animations of the other presences to me | 1109 | // send the animations of the other presences to me |
961 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 1110 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
962 | { | 1111 | { |
@@ -967,9 +1116,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
967 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1116 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
968 | // stall on the border crossing since the existing child agent will still have the last movement | 1117 | // stall on the border crossing since the existing child agent will still have the last movement |
969 | // recorded, which stops the input from being processed. | 1118 | // recorded, which stops the input from being processed. |
1119 | |||
970 | MovementFlag = 0; | 1120 | MovementFlag = 0; |
971 | 1121 | ||
972 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1122 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1123 | |||
1124 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
973 | } | 1125 | } |
974 | 1126 | ||
975 | public int GetStateSource() | 1127 | public int GetStateSource() |
@@ -997,12 +1149,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
997 | /// </remarks> | 1149 | /// </remarks> |
998 | public void MakeChildAgent() | 1150 | public void MakeChildAgent() |
999 | { | 1151 | { |
1152 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1153 | |||
1000 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1154 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
1001 | 1155 | ||
1002 | // Reset these so that teleporting in and walking out isn't seen | 1156 | // Reset these so that teleporting in and walking out isn't seen |
1003 | // as teleporting back | 1157 | // as teleporting back |
1004 | TeleportFlags = TeleportFlags.Default; | 1158 | TeleportFlags = TeleportFlags.Default; |
1005 | 1159 | ||
1160 | MovementFlag = 0; | ||
1161 | |||
1006 | // It looks like Animator is set to null somewhere, and MakeChild | 1162 | // It looks like Animator is set to null somewhere, and MakeChild |
1007 | // is called after that. Probably in aborted teleports. | 1163 | // is called after that. Probably in aborted teleports. |
1008 | if (Animator == null) | 1164 | if (Animator == null) |
@@ -1010,6 +1166,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1010 | else | 1166 | else |
1011 | Animator.ResetAnimations(); | 1167 | Animator.ResetAnimations(); |
1012 | 1168 | ||
1169 | |||
1013 | // m_log.DebugFormat( | 1170 | // m_log.DebugFormat( |
1014 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1171 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
1015 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1172 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -1021,6 +1178,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1021 | IsChildAgent = true; | 1178 | IsChildAgent = true; |
1022 | m_scene.SwapRootAgentCount(true); | 1179 | m_scene.SwapRootAgentCount(true); |
1023 | RemoveFromPhysicalScene(); | 1180 | RemoveFromPhysicalScene(); |
1181 | ParentID = 0; // Child agents can't be sitting | ||
1024 | 1182 | ||
1025 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1183 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
1026 | 1184 | ||
@@ -1036,9 +1194,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1036 | { | 1194 | { |
1037 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1195 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
1038 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1196 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
1039 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1040 | PhysicsActor.UnSubscribeEvents(); | ||
1041 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1197 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1198 | PhysicsActor.UnSubscribeEvents(); | ||
1199 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1042 | PhysicsActor = null; | 1200 | PhysicsActor = null; |
1043 | } | 1201 | } |
1044 | // else | 1202 | // else |
@@ -1055,7 +1213,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1055 | /// <param name="pos"></param> | 1213 | /// <param name="pos"></param> |
1056 | public void Teleport(Vector3 pos) | 1214 | public void Teleport(Vector3 pos) |
1057 | { | 1215 | { |
1058 | TeleportWithMomentum(pos, null); | 1216 | TeleportWithMomentum(pos, Vector3.Zero); |
1059 | } | 1217 | } |
1060 | 1218 | ||
1061 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1219 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1079,6 +1237,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1079 | SendTerseUpdateToAllClients(); | 1237 | SendTerseUpdateToAllClients(); |
1080 | } | 1238 | } |
1081 | 1239 | ||
1240 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1241 | { | ||
1242 | CheckLandingPoint(ref newpos); | ||
1243 | AbsolutePosition = newpos; | ||
1244 | |||
1245 | if (newvel.HasValue) | ||
1246 | { | ||
1247 | if ((Vector3)newvel == Vector3.Zero) | ||
1248 | { | ||
1249 | if (PhysicsActor != null) | ||
1250 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1251 | m_velocity = Vector3.Zero; | ||
1252 | } | ||
1253 | else | ||
1254 | { | ||
1255 | if (PhysicsActor != null) | ||
1256 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1257 | m_velocity = (Vector3)newvel; | ||
1258 | |||
1259 | if (rotateToVelXY) | ||
1260 | { | ||
1261 | Vector3 lookAt = (Vector3)newvel; | ||
1262 | lookAt.Z = 0; | ||
1263 | lookAt.Normalize(); | ||
1264 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1265 | return; | ||
1266 | } | ||
1267 | } | ||
1268 | } | ||
1269 | |||
1270 | SendTerseUpdateToAllClients(); | ||
1271 | } | ||
1272 | |||
1273 | |||
1274 | |||
1082 | public void StopFlying() | 1275 | public void StopFlying() |
1083 | { | 1276 | { |
1084 | ControllingClient.StopFlying(this); | 1277 | ControllingClient.StopFlying(this); |
@@ -1248,6 +1441,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1248 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); | 1441 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); |
1249 | } | 1442 | } |
1250 | 1443 | ||
1444 | public void SetSize(Vector3 size, float feetoffset) | ||
1445 | { | ||
1446 | if (PhysicsActor != null && !IsChildAgent) | ||
1447 | PhysicsActor.setAvatarSize(size, feetoffset); | ||
1448 | |||
1449 | } | ||
1450 | |||
1251 | /// <summary> | 1451 | /// <summary> |
1252 | /// Complete Avatar's movement into the region. | 1452 | /// Complete Avatar's movement into the region. |
1253 | /// </summary> | 1453 | /// </summary> |
@@ -1267,7 +1467,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1267 | 1467 | ||
1268 | Vector3 look = Velocity; | 1468 | Vector3 look = Velocity; |
1269 | 1469 | ||
1270 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1470 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1471 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1271 | { | 1472 | { |
1272 | look = new Vector3(0.99f, 0.042f, 0); | 1473 | look = new Vector3(0.99f, 0.042f, 0); |
1273 | } | 1474 | } |
@@ -1317,13 +1518,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1317 | // Create child agents in neighbouring regions | 1518 | // Create child agents in neighbouring regions |
1318 | if (openChildAgents && !IsChildAgent) | 1519 | if (openChildAgents && !IsChildAgent) |
1319 | { | 1520 | { |
1521 | |||
1320 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1522 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1321 | if (m_agentTransfer != null) | 1523 | if (m_agentTransfer != null) |
1322 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1524 | m_agentTransfer.EnableChildAgents(this); |
1323 | 1525 | ||
1324 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1526 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1325 | if (friendsModule != null) | 1527 | if (friendsModule != null) |
1326 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1528 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1529 | |||
1327 | } | 1530 | } |
1328 | 1531 | ||
1329 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region | 1532 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region |
@@ -1348,36 +1551,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1348 | /// <param name="collisionPoint"></param> | 1551 | /// <param name="collisionPoint"></param> |
1349 | /// <param name="localid"></param> | 1552 | /// <param name="localid"></param> |
1350 | /// <param name="distance"></param> | 1553 | /// <param name="distance"></param> |
1554 | /// | ||
1555 | |||
1556 | private void UpdateCameraCollisionPlane(Vector4 plane) | ||
1557 | { | ||
1558 | if (m_lastCameraCollisionPlane != plane) | ||
1559 | { | ||
1560 | m_lastCameraCollisionPlane = plane; | ||
1561 | ControllingClient.SendCameraConstraint(plane); | ||
1562 | } | ||
1563 | } | ||
1564 | |||
1351 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) | 1565 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) |
1352 | { | 1566 | { |
1353 | const float POSITION_TOLERANCE = 0.02f; | 1567 | const float POSITION_TOLERANCE = 0.02f; |
1354 | const float VELOCITY_TOLERANCE = 0.02f; | ||
1355 | const float ROTATION_TOLERANCE = 0.02f; | 1568 | const float ROTATION_TOLERANCE = 0.02f; |
1356 | 1569 | ||
1357 | if (m_followCamAuto) | 1570 | m_doingCamRayCast = false; |
1571 | if (hitYN && localid != LocalId) | ||
1358 | { | 1572 | { |
1359 | if (hitYN) | 1573 | SceneObjectGroup group = m_scene.GetGroupByPrim(localid); |
1574 | bool IsPrim = group != null; | ||
1575 | if (IsPrim) | ||
1360 | { | 1576 | { |
1361 | CameraConstraintActive = true; | 1577 | SceneObjectPart part = group.GetPart(localid); |
1362 | //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); | 1578 | if (part != null && !part.VolumeDetectActive) |
1363 | 1579 | { | |
1364 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1580 | CameraConstraintActive = true; |
1365 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1581 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1582 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); | ||
1583 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); | ||
1584 | pNormal.Normalize(); | ||
1585 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); | ||
1586 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); | ||
1587 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); | ||
1588 | |||
1589 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, | ||
1590 | Vector3.Dot(collisionPoint, pNormal)); | ||
1591 | UpdateCameraCollisionPlane(plane); | ||
1592 | } | ||
1366 | } | 1593 | } |
1367 | else | 1594 | else |
1368 | { | 1595 | { |
1369 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 1596 | CameraConstraintActive = true; |
1370 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 1597 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1371 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | 1598 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); |
1372 | { | 1599 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); |
1373 | if (CameraConstraintActive) | 1600 | pNormal.Normalize(); |
1374 | { | 1601 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); |
1375 | ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); | 1602 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); |
1376 | CameraConstraintActive = false; | 1603 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); |
1377 | } | 1604 | |
1378 | } | 1605 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, |
1606 | Vector3.Dot(collisionPoint, pNormal)); | ||
1607 | UpdateCameraCollisionPlane(plane); | ||
1379 | } | 1608 | } |
1380 | } | 1609 | } |
1610 | else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | ||
1611 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | ||
1612 | { | ||
1613 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... | ||
1614 | UpdateCameraCollisionPlane(plane); | ||
1615 | CameraConstraintActive = false; | ||
1616 | } | ||
1381 | } | 1617 | } |
1382 | 1618 | ||
1383 | /// <summary> | 1619 | /// <summary> |
@@ -1451,12 +1687,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1451 | // DrawDistance = agentData.Far; | 1687 | // DrawDistance = agentData.Far; |
1452 | DrawDistance = Scene.DefaultDrawDistance; | 1688 | DrawDistance = Scene.DefaultDrawDistance; |
1453 | 1689 | ||
1454 | // Check if Client has camera in 'follow cam' or 'build' mode. | ||
1455 | Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); | ||
1456 | |||
1457 | m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) | ||
1458 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | ||
1459 | |||
1460 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | 1690 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; |
1461 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | 1691 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; |
1462 | 1692 | ||
@@ -1476,14 +1706,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
1476 | StandUp(); | 1706 | StandUp(); |
1477 | } | 1707 | } |
1478 | 1708 | ||
1479 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | ||
1480 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 1709 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
1481 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 1710 | // this exclude checks may not be complete |
1711 | |||
1712 | if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) | ||
1482 | { | 1713 | { |
1483 | if (m_followCamAuto) | 1714 | if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) |
1484 | { | 1715 | { |
1485 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1716 | Vector3 posAdjusted = AbsolutePosition; |
1486 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1717 | // posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; |
1718 | posAdjusted.Z += 1.0f; // viewer current camera focus point | ||
1719 | Vector3 tocam = CameraPosition - posAdjusted; | ||
1720 | tocam.X = (float)Math.Round(tocam.X, 1); | ||
1721 | tocam.Y = (float)Math.Round(tocam.Y, 1); | ||
1722 | tocam.Z = (float)Math.Round(tocam.Z, 1); | ||
1723 | |||
1724 | float distTocamlen = tocam.Length(); | ||
1725 | if (distTocamlen > 0.3f) | ||
1726 | { | ||
1727 | tocam *= (1.0f / distTocamlen); | ||
1728 | posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); | ||
1729 | posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); | ||
1730 | posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); | ||
1731 | |||
1732 | m_doingCamRayCast = true; | ||
1733 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); | ||
1734 | } | ||
1735 | } | ||
1736 | else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) | ||
1737 | { | ||
1738 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... | ||
1739 | UpdateCameraCollisionPlane(plane); | ||
1740 | CameraConstraintActive = false; | ||
1487 | } | 1741 | } |
1488 | } | 1742 | } |
1489 | 1743 | ||
@@ -1948,7 +2202,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1948 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); | 2202 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); |
1949 | 2203 | ||
1950 | MovingToTarget = false; | 2204 | MovingToTarget = false; |
1951 | MoveToPositionTarget = Vector3.Zero; | 2205 | // MoveToPositionTarget = Vector3.Zero; |
2206 | m_forceToApply = null; // cancel possible last action | ||
1952 | 2207 | ||
1953 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct | 2208 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct |
1954 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. | 2209 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. |
@@ -1966,12 +2221,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1966 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 2221 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1967 | 2222 | ||
1968 | SitGround = false; | 2223 | SitGround = false; |
2224 | |||
2225 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1969 | if (PhysicsActor == null) | 2226 | if (PhysicsActor == null) |
1970 | AddToPhysicalScene(false); | 2227 | AddToPhysicalScene(false); |
2228 | */ | ||
1971 | 2229 | ||
1972 | if (ParentID != 0) | 2230 | if (ParentID != 0) |
1973 | { | 2231 | { |
1974 | SceneObjectPart part = ParentPart; | 2232 | SceneObjectPart part = ParentPart; |
2233 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
2234 | |||
1975 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 2235 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1976 | if (taskIDict != null) | 2236 | if (taskIDict != null) |
1977 | { | 2237 | { |
@@ -1987,14 +2247,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1987 | } | 2247 | } |
1988 | } | 2248 | } |
1989 | 2249 | ||
1990 | ParentPosition = part.GetWorldPosition(); | 2250 | part.ParentGroup.DeleteAvatar(UUID); |
2251 | // ParentPosition = part.GetWorldPosition(); | ||
1991 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 2252 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1992 | 2253 | ||
1993 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 2254 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
1994 | ParentPosition = Vector3.Zero; | 2255 | // ParentPosition = Vector3.Zero; |
2256 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
2257 | if (part.SitTargetAvatar == UUID) | ||
2258 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
1995 | 2259 | ||
1996 | ParentID = 0; | 2260 | ParentID = 0; |
1997 | ParentPart = null; | 2261 | ParentPart = null; |
2262 | |||
2263 | if (PhysicsActor == null) | ||
2264 | AddToPhysicalScene(false); | ||
2265 | |||
1998 | SendAvatarDataToAllAgents(); | 2266 | SendAvatarDataToAllAgents(); |
1999 | m_requestedSitTargetID = 0; | 2267 | m_requestedSitTargetID = 0; |
2000 | 2268 | ||
@@ -2004,6 +2272,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2004 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2272 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2005 | } | 2273 | } |
2006 | 2274 | ||
2275 | else if (PhysicsActor == null) | ||
2276 | AddToPhysicalScene(false); | ||
2277 | |||
2007 | Animator.TrySetMovementAnimation("STAND"); | 2278 | Animator.TrySetMovementAnimation("STAND"); |
2008 | } | 2279 | } |
2009 | 2280 | ||
@@ -2051,11 +2322,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2051 | if (part == null) | 2322 | if (part == null) |
2052 | return; | 2323 | return; |
2053 | 2324 | ||
2054 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
2055 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
2056 | |||
2057 | if (PhysicsActor != null) | 2325 | if (PhysicsActor != null) |
2058 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2326 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2059 | 2327 | ||
2060 | bool canSit = false; | 2328 | bool canSit = false; |
2061 | Vector3 pos = part.AbsolutePosition + offset; | 2329 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -2072,31 +2340,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
2072 | } | 2340 | } |
2073 | else | 2341 | else |
2074 | { | 2342 | { |
2343 | if (PhysicsSit(part,offset)) // physics engine | ||
2344 | return; | ||
2345 | |||
2075 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2346 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2076 | { | 2347 | { |
2077 | // m_log.DebugFormat( | ||
2078 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | ||
2079 | // Name, part.Name, part.LocalId); | ||
2080 | 2348 | ||
2081 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2349 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2082 | canSit = true; | 2350 | canSit = true; |
2083 | } | 2351 | } |
2084 | // else | ||
2085 | // { | ||
2086 | // m_log.DebugFormat( | ||
2087 | // "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", | ||
2088 | // Name, part.Name, part.LocalId); | ||
2089 | // } | ||
2090 | } | 2352 | } |
2091 | 2353 | ||
2092 | if (canSit) | 2354 | if (canSit) |
2093 | { | 2355 | { |
2356 | |||
2094 | if (PhysicsActor != null) | 2357 | if (PhysicsActor != null) |
2095 | { | 2358 | { |
2096 | // We can remove the physicsActor until they stand up. | 2359 | // We can remove the physicsActor until they stand up. |
2097 | RemoveFromPhysicalScene(); | 2360 | RemoveFromPhysicalScene(); |
2098 | } | 2361 | } |
2099 | 2362 | ||
2363 | if (MovingToTarget) | ||
2364 | ResetMoveToTarget(); | ||
2365 | |||
2366 | Velocity = Vector3.Zero; | ||
2367 | |||
2100 | part.AddSittingAvatar(UUID); | 2368 | part.AddSittingAvatar(UUID); |
2101 | 2369 | ||
2102 | cameraAtOffset = part.GetCameraAtOffset(); | 2370 | cameraAtOffset = part.GetCameraAtOffset(); |
@@ -2104,7 +2372,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2104 | forceMouselook = part.GetForceMouselook(); | 2372 | forceMouselook = part.GetForceMouselook(); |
2105 | 2373 | ||
2106 | ControllingClient.SendSitResponse( | 2374 | ControllingClient.SendSitResponse( |
2107 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2375 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
2108 | 2376 | ||
2109 | m_requestedSitTargetUUID = targetID; | 2377 | m_requestedSitTargetUUID = targetID; |
2110 | 2378 | ||
@@ -2118,6 +2386,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2118 | 2386 | ||
2119 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2387 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
2120 | { | 2388 | { |
2389 | if (IsChildAgent) | ||
2390 | return; | ||
2391 | |||
2121 | if (ParentID != 0) | 2392 | if (ParentID != 0) |
2122 | { | 2393 | { |
2123 | if (ParentPart.UUID == targetID) | 2394 | if (ParentPart.UUID == targetID) |
@@ -2133,14 +2404,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2133 | m_requestedSitTargetID = part.LocalId; | 2404 | m_requestedSitTargetID = part.LocalId; |
2134 | m_requestedSitTargetUUID = targetID; | 2405 | m_requestedSitTargetUUID = targetID; |
2135 | 2406 | ||
2136 | // m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | ||
2137 | |||
2138 | if (m_scene.PhysicsScene.SupportsRayCast()) | ||
2139 | { | ||
2140 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); | ||
2141 | //SitRayCastAvatarPosition(part); | ||
2142 | //return; | ||
2143 | } | ||
2144 | } | 2407 | } |
2145 | else | 2408 | else |
2146 | { | 2409 | { |
@@ -2150,197 +2413,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2150 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2413 | SendSitResponse(targetID, offset, Quaternion.Identity); |
2151 | } | 2414 | } |
2152 | 2415 | ||
2153 | /* | 2416 | // returns false if does not suport so older sit can be tried |
2154 | public void SitRayCastAvatarPosition(SceneObjectPart part) | 2417 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2155 | { | 2418 | { |
2156 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2419 | if (part == null || part.ParentGroup.IsAttachment) |
2157 | Vector3 StartRayCastPosition = AbsolutePosition; | ||
2158 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2159 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2160 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | ||
2161 | } | ||
2162 | |||
2163 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | ||
2164 | { | ||
2165 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2166 | if (part != null) | ||
2167 | { | ||
2168 | if (hitYN) | ||
2169 | { | ||
2170 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2171 | { | ||
2172 | SitRaycastFindEdge(collisionPoint, normal); | ||
2173 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2174 | } | ||
2175 | else | ||
2176 | { | ||
2177 | SitRayCastAvatarPositionCameraZ(part); | ||
2178 | } | ||
2179 | } | ||
2180 | else | ||
2181 | { | ||
2182 | SitRayCastAvatarPositionCameraZ(part); | ||
2183 | } | ||
2184 | } | ||
2185 | else | ||
2186 | { | 2420 | { |
2187 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2421 | return true; |
2188 | m_requestedSitTargetUUID = UUID.Zero; | ||
2189 | m_requestedSitTargetID = 0; | ||
2190 | m_requestedSitOffset = Vector3.Zero; | ||
2191 | } | 2422 | } |
2192 | 2423 | ||
2193 | } | 2424 | if ( m_scene.PhysicsScene == null) |
2425 | return false; | ||
2194 | 2426 | ||
2195 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | 2427 | if (part.PhysActor == null) |
2196 | { | ||
2197 | // Next, try to raycast from the camera Z position | ||
2198 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2199 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | ||
2200 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2201 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2202 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | ||
2203 | } | ||
2204 | |||
2205 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | ||
2206 | { | ||
2207 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2208 | if (part != null) | ||
2209 | { | 2428 | { |
2210 | if (hitYN) | 2429 | // none physcis shape |
2211 | { | 2430 | if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) |
2212 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2431 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2213 | { | ||
2214 | SitRaycastFindEdge(collisionPoint, normal); | ||
2215 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2216 | } | ||
2217 | else | ||
2218 | { | ||
2219 | SitRayCastCameraPosition(part); | ||
2220 | } | ||
2221 | } | ||
2222 | else | 2432 | else |
2223 | { | 2433 | { // non physical phantom TODO |
2224 | SitRayCastCameraPosition(part); | 2434 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2435 | return false; | ||
2225 | } | 2436 | } |
2226 | } | 2437 | return true; |
2227 | else | ||
2228 | { | ||
2229 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2230 | m_requestedSitTargetUUID = UUID.Zero; | ||
2231 | m_requestedSitTargetID = 0; | ||
2232 | m_requestedSitOffset = Vector3.Zero; | ||
2233 | } | 2438 | } |
2234 | 2439 | ||
2235 | } | ||
2236 | 2440 | ||
2237 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2441 | // not doing autopilot |
2238 | { | 2442 | m_requestedSitTargetID = 0; |
2239 | // Next, try to raycast from the camera position | ||
2240 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2241 | Vector3 StartRayCastPosition = CameraPosition; | ||
2242 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2243 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2244 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | ||
2245 | } | ||
2246 | 2443 | ||
2247 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2444 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) |
2248 | { | 2445 | return true; |
2249 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2250 | if (part != null) | ||
2251 | { | ||
2252 | if (hitYN) | ||
2253 | { | ||
2254 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2255 | { | ||
2256 | SitRaycastFindEdge(collisionPoint, normal); | ||
2257 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2258 | } | ||
2259 | else | ||
2260 | { | ||
2261 | SitRayHorizontal(part); | ||
2262 | } | ||
2263 | } | ||
2264 | else | ||
2265 | { | ||
2266 | SitRayHorizontal(part); | ||
2267 | } | ||
2268 | } | ||
2269 | else | ||
2270 | { | ||
2271 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2272 | m_requestedSitTargetUUID = UUID.Zero; | ||
2273 | m_requestedSitTargetID = 0; | ||
2274 | m_requestedSitOffset = Vector3.Zero; | ||
2275 | } | ||
2276 | 2446 | ||
2447 | return false; | ||
2277 | } | 2448 | } |
2278 | 2449 | ||
2279 | public void SitRayHorizontal(SceneObjectPart part) | 2450 | |
2451 | private bool CanEnterLandPosition(Vector3 testPos) | ||
2280 | { | 2452 | { |
2281 | // Next, try to raycast from the avatar position to fwd | 2453 | ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); |
2282 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2454 | |
2283 | Vector3 StartRayCastPosition = CameraPosition; | 2455 | if (land == null || land.LandData.Name == "NO_LAND") |
2284 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2456 | return true; |
2285 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2457 | |
2286 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | 2458 | return land.CanBeOnThisLand(UUID,testPos.Z); |
2287 | } | 2459 | } |
2288 | 2460 | ||
2289 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2461 | // status |
2462 | // < 0 ignore | ||
2463 | // 0 bad sit spot | ||
2464 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) | ||
2290 | { | 2465 | { |
2291 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2466 | if (status < 0) |
2292 | if (part != null) | 2467 | return; |
2468 | |||
2469 | if (status == 0) | ||
2293 | { | 2470 | { |
2294 | if (hitYN) | 2471 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2295 | { | 2472 | return; |
2296 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2297 | { | ||
2298 | SitRaycastFindEdge(collisionPoint, normal); | ||
2299 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2300 | // Next, try to raycast from the camera position | ||
2301 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2302 | Vector3 StartRayCastPosition = CameraPosition; | ||
2303 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2304 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2305 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | ||
2306 | } | ||
2307 | else | ||
2308 | { | ||
2309 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2310 | m_requestedSitTargetUUID = UUID.Zero; | ||
2311 | m_requestedSitTargetID = 0; | ||
2312 | m_requestedSitOffset = Vector3.Zero; | ||
2313 | } | ||
2314 | } | ||
2315 | else | ||
2316 | { | ||
2317 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2318 | m_requestedSitTargetUUID = UUID.Zero; | ||
2319 | m_requestedSitTargetID = 0; | ||
2320 | m_requestedSitOffset = Vector3.Zero; | ||
2321 | } | ||
2322 | } | 2473 | } |
2323 | else | 2474 | |
2475 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); | ||
2476 | if (part == null) | ||
2477 | return; | ||
2478 | |||
2479 | Vector3 targetPos = part.GetWorldPosition() + offset * part.GetWorldRotation(); | ||
2480 | if(!CanEnterLandPosition(targetPos)) | ||
2324 | { | 2481 | { |
2325 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2482 | ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); |
2326 | m_requestedSitTargetUUID = UUID.Zero; | 2483 | return; |
2327 | m_requestedSitTargetID = 0; | ||
2328 | m_requestedSitOffset = Vector3.Zero; | ||
2329 | } | 2484 | } |
2330 | 2485 | ||
2331 | } | 2486 | RemoveFromPhysicalScene(); |
2332 | 2487 | ||
2333 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2488 | if (MovingToTarget) |
2334 | { | 2489 | ResetMoveToTarget(); |
2335 | int i = 0; | 2490 | |
2336 | //throw new NotImplementedException(); | 2491 | Velocity = Vector3.Zero; |
2337 | //m_requestedSitTargetUUID = UUID.Zero; | 2492 | |
2338 | //m_requestedSitTargetID = 0; | 2493 | part.AddSittingAvatar(UUID); |
2339 | //m_requestedSitOffset = Vector3.Zero; | ||
2340 | 2494 | ||
2341 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2495 | Vector3 cameraAtOffset = part.GetCameraAtOffset(); |
2496 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2497 | bool forceMouselook = part.GetForceMouselook(); | ||
2498 | |||
2499 | ControllingClient.SendSitResponse( | ||
2500 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2501 | |||
2502 | // not using autopilot | ||
2503 | |||
2504 | Rotation = Orientation; | ||
2505 | m_pos = offset; | ||
2506 | |||
2507 | m_requestedSitTargetID = 0; | ||
2508 | part.ParentGroup.AddAvatar(UUID); | ||
2509 | |||
2510 | ParentPart = part; | ||
2511 | ParentID = part.LocalId; | ||
2512 | if(status == 3) | ||
2513 | Animator.TrySetMovementAnimation("SIT_GROUND"); | ||
2514 | else | ||
2515 | Animator.TrySetMovementAnimation("SIT"); | ||
2516 | SendAvatarDataToAllAgents(); | ||
2517 | |||
2518 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
2342 | } | 2519 | } |
2343 | */ | 2520 | |
2344 | 2521 | ||
2345 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2522 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2346 | { | 2523 | { |
@@ -2357,6 +2534,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2357 | return; | 2534 | return; |
2358 | } | 2535 | } |
2359 | 2536 | ||
2537 | |||
2360 | if (part.SitTargetAvatar == UUID) | 2538 | if (part.SitTargetAvatar == UUID) |
2361 | { | 2539 | { |
2362 | Vector3 sitTargetPos = part.SitTargetPosition; | 2540 | Vector3 sitTargetPos = part.SitTargetPosition; |
@@ -2371,14 +2549,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2371 | 2549 | ||
2372 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2550 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2373 | 2551 | ||
2374 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2552 | double x, y, z, m; |
2553 | |||
2554 | Quaternion r = sitTargetOrient; | ||
2555 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2556 | |||
2557 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2558 | { | ||
2559 | m = 1.0 / Math.Sqrt(m); | ||
2560 | r.X *= (float)m; | ||
2561 | r.Y *= (float)m; | ||
2562 | r.Z *= (float)m; | ||
2563 | r.W *= (float)m; | ||
2564 | } | ||
2565 | |||
2566 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2567 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2568 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2569 | |||
2570 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2571 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2572 | |||
2573 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2574 | |||
2575 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2375 | Rotation = sitTargetOrient; | 2576 | Rotation = sitTargetOrient; |
2376 | ParentPosition = part.AbsolutePosition; | 2577 | // ParentPosition = part.AbsolutePosition; |
2578 | part.ParentGroup.AddAvatar(UUID); | ||
2377 | } | 2579 | } |
2378 | else | 2580 | else |
2379 | { | 2581 | { |
2380 | m_pos -= part.AbsolutePosition; | 2582 | m_pos -= part.AbsolutePosition; |
2381 | ParentPosition = part.AbsolutePosition; | 2583 | // ParentPosition = part.AbsolutePosition; |
2584 | part.ParentGroup.AddAvatar(UUID); | ||
2382 | 2585 | ||
2383 | // m_log.DebugFormat( | 2586 | // m_log.DebugFormat( |
2384 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2587 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2429,6 +2632,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2429 | Animator.RemoveAnimation(animID, false); | 2632 | Animator.RemoveAnimation(animID, false); |
2430 | } | 2633 | } |
2431 | 2634 | ||
2635 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2636 | { | ||
2637 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2638 | } | ||
2639 | |||
2640 | |||
2641 | |||
2432 | /// <summary> | 2642 | /// <summary> |
2433 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2643 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2434 | /// </summary> | 2644 | /// </summary> |
@@ -2485,8 +2695,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2485 | direc.Z *= 2.6f; | 2695 | direc.Z *= 2.6f; |
2486 | 2696 | ||
2487 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2697 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2488 | Animator.TrySetMovementAnimation("PREJUMP"); | 2698 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2489 | Animator.TrySetMovementAnimation("JUMP"); | 2699 | // Animator.TrySetMovementAnimation("JUMP"); |
2490 | } | 2700 | } |
2491 | } | 2701 | } |
2492 | } | 2702 | } |
@@ -2495,6 +2705,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2495 | 2705 | ||
2496 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2706 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2497 | m_forceToApply = direc; | 2707 | m_forceToApply = direc; |
2708 | Animator.UpdateMovementAnimations(); | ||
2498 | } | 2709 | } |
2499 | 2710 | ||
2500 | #endregion | 2711 | #endregion |
@@ -2512,16 +2723,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2512 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 2723 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2513 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 2724 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2514 | // storing a requested force instead of an actual traveling velocity | 2725 | // storing a requested force instead of an actual traveling velocity |
2726 | if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) | ||
2727 | SendAvatarDataToAllAgents(); | ||
2515 | 2728 | ||
2516 | // Throw away duplicate or insignificant updates | 2729 | if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2517 | if ( | 2730 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2518 | // If the velocity has become zero, send it no matter what. | 2731 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2519 | (Velocity != m_lastVelocity && Velocity == Vector3.Zero) | ||
2520 | // otherwise, if things have changed reasonably, send the update | ||
2521 | || (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) | ||
2522 | || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) | ||
2523 | || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))) | ||
2524 | |||
2525 | { | 2732 | { |
2526 | SendTerseUpdateToAllClients(); | 2733 | SendTerseUpdateToAllClients(); |
2527 | 2734 | ||
@@ -2710,6 +2917,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2710 | return; | 2917 | return; |
2711 | } | 2918 | } |
2712 | 2919 | ||
2920 | m_lastSize = Appearance.AvatarSize; | ||
2921 | |||
2713 | int count = 0; | 2922 | int count = 0; |
2714 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 2923 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
2715 | { | 2924 | { |
@@ -2817,6 +3026,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2817 | 3026 | ||
2818 | avatar.ControllingClient.SendAppearance( | 3027 | avatar.ControllingClient.SendAppearance( |
2819 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); | 3028 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
3029 | |||
3030 | |||
2820 | } | 3031 | } |
2821 | 3032 | ||
2822 | #endregion | 3033 | #endregion |
@@ -2891,8 +3102,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2891 | 3102 | ||
2892 | // If we don't have a PhysActor, we can't cross anyway | 3103 | // If we don't have a PhysActor, we can't cross anyway |
2893 | // Also don't do this while sat, sitting avatars cross with the | 3104 | // Also don't do this while sat, sitting avatars cross with the |
2894 | // object they sit on. | 3105 | // object they sit on. ParentUUID denoted a pending sit, don't |
2895 | if (ParentID != 0 || PhysicsActor == null) | 3106 | // interfere with it. |
3107 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2896 | return; | 3108 | return; |
2897 | 3109 | ||
2898 | if (!IsInTransit) | 3110 | if (!IsInTransit) |
@@ -3153,6 +3365,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3153 | } | 3365 | } |
3154 | 3366 | ||
3155 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3367 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3368 | private void RaiseUpdateThrottles() | ||
3369 | { | ||
3370 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3371 | } | ||
3156 | /// <summary> | 3372 | /// <summary> |
3157 | /// This updates important decision making data about a child agent | 3373 | /// This updates important decision making data about a child agent |
3158 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3374 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3233,6 +3449,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3233 | cAgent.AlwaysRun = SetAlwaysRun; | 3449 | cAgent.AlwaysRun = SetAlwaysRun; |
3234 | 3450 | ||
3235 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3451 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3452 | |||
3453 | cAgent.ParentPart = ParentUUID; | ||
3454 | cAgent.SitOffset = m_pos; | ||
3236 | 3455 | ||
3237 | lock (scriptedcontrols) | 3456 | lock (scriptedcontrols) |
3238 | { | 3457 | { |
@@ -3241,7 +3460,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3241 | 3460 | ||
3242 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3461 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3243 | { | 3462 | { |
3244 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3463 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3245 | } | 3464 | } |
3246 | cAgent.Controllers = controls; | 3465 | cAgent.Controllers = controls; |
3247 | } | 3466 | } |
@@ -3274,6 +3493,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3274 | CameraAtAxis = cAgent.AtAxis; | 3493 | CameraAtAxis = cAgent.AtAxis; |
3275 | CameraLeftAxis = cAgent.LeftAxis; | 3494 | CameraLeftAxis = cAgent.LeftAxis; |
3276 | CameraUpAxis = cAgent.UpAxis; | 3495 | CameraUpAxis = cAgent.UpAxis; |
3496 | ParentUUID = cAgent.ParentPart; | ||
3497 | m_prevSitOffset = cAgent.SitOffset; | ||
3277 | 3498 | ||
3278 | // When we get to the point of re-computing neighbors everytime this | 3499 | // When we get to the point of re-computing neighbors everytime this |
3279 | // changes, then start using the agent's drawdistance rather than the | 3500 | // changes, then start using the agent's drawdistance rather than the |
@@ -3311,6 +3532,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3311 | foreach (ControllerData c in cAgent.Controllers) | 3532 | foreach (ControllerData c in cAgent.Controllers) |
3312 | { | 3533 | { |
3313 | ScriptControllers sc = new ScriptControllers(); | 3534 | ScriptControllers sc = new ScriptControllers(); |
3535 | sc.objectID = c.ObjectID; | ||
3314 | sc.itemID = c.ItemID; | 3536 | sc.itemID = c.ItemID; |
3315 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3537 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3316 | sc.eventControls = (ScriptControlled)c.EventControls; | 3538 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3378,20 +3600,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3378 | } | 3600 | } |
3379 | 3601 | ||
3380 | if (Appearance.AvatarHeight == 0) | 3602 | if (Appearance.AvatarHeight == 0) |
3381 | Appearance.SetHeight(); | 3603 | // Appearance.SetHeight(); |
3604 | Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
3382 | 3605 | ||
3383 | PhysicsScene scene = m_scene.PhysicsScene; | 3606 | PhysicsScene scene = m_scene.PhysicsScene; |
3384 | 3607 | ||
3385 | Vector3 pVec = AbsolutePosition; | 3608 | Vector3 pVec = AbsolutePosition; |
3386 | 3609 | ||
3610 | /* | ||
3387 | PhysicsActor = scene.AddAvatar( | 3611 | PhysicsActor = scene.AddAvatar( |
3388 | LocalId, Firstname + "." + Lastname, pVec, | 3612 | LocalId, Firstname + "." + Lastname, pVec, |
3389 | new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); | 3613 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); |
3614 | */ | ||
3615 | |||
3616 | PhysicsActor = scene.AddAvatar( | ||
3617 | LocalId, Firstname + "." + Lastname, pVec, | ||
3618 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); | ||
3390 | 3619 | ||
3391 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3620 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3392 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3621 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3393 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3622 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3394 | PhysicsActor.SubscribeEvents(500); | 3623 | PhysicsActor.SubscribeEvents(100); |
3395 | PhysicsActor.LocalID = LocalId; | 3624 | PhysicsActor.LocalID = LocalId; |
3396 | } | 3625 | } |
3397 | 3626 | ||
@@ -3405,6 +3634,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3405 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); | 3634 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); |
3406 | } | 3635 | } |
3407 | 3636 | ||
3637 | |||
3408 | /// <summary> | 3638 | /// <summary> |
3409 | /// Event called by the physics plugin to tell the avatar about a collision. | 3639 | /// Event called by the physics plugin to tell the avatar about a collision. |
3410 | /// </summary> | 3640 | /// </summary> |
@@ -3418,7 +3648,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3418 | /// <param name="e"></param> | 3648 | /// <param name="e"></param> |
3419 | public void PhysicsCollisionUpdate(EventArgs e) | 3649 | public void PhysicsCollisionUpdate(EventArgs e) |
3420 | { | 3650 | { |
3421 | if (IsChildAgent) | 3651 | if (IsChildAgent || Animator == null) |
3422 | return; | 3652 | return; |
3423 | 3653 | ||
3424 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3654 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3434,7 +3664,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3434 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3664 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3435 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3665 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3436 | 3666 | ||
3437 | CollisionPlane = Vector4.UnitW; | ||
3438 | 3667 | ||
3439 | // // No collisions at all means we may be flying. Update always | 3668 | // // No collisions at all means we may be flying. Update always |
3440 | // // to make falling work | 3669 | // // to make falling work |
@@ -3446,6 +3675,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3446 | 3675 | ||
3447 | if (coldata.Count != 0) | 3676 | if (coldata.Count != 0) |
3448 | { | 3677 | { |
3678 | /* | ||
3449 | switch (Animator.CurrentMovementAnimation) | 3679 | switch (Animator.CurrentMovementAnimation) |
3450 | { | 3680 | { |
3451 | case "STAND": | 3681 | case "STAND": |
@@ -3454,24 +3684,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
3454 | case "CROUCH": | 3684 | case "CROUCH": |
3455 | case "CROUCHWALK": | 3685 | case "CROUCHWALK": |
3456 | { | 3686 | { |
3687 | */ | ||
3457 | ContactPoint lowest; | 3688 | ContactPoint lowest; |
3458 | lowest.SurfaceNormal = Vector3.Zero; | 3689 | lowest.SurfaceNormal = Vector3.Zero; |
3459 | lowest.Position = Vector3.Zero; | 3690 | lowest.Position = Vector3.Zero; |
3460 | lowest.Position.Z = Single.NaN; | 3691 | lowest.Position.Z = float.MaxValue; |
3461 | 3692 | ||
3462 | foreach (ContactPoint contact in coldata.Values) | 3693 | foreach (ContactPoint contact in coldata.Values) |
3463 | { | 3694 | { |
3464 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | 3695 | |
3696 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
3465 | { | 3697 | { |
3466 | lowest = contact; | 3698 | lowest = contact; |
3467 | } | 3699 | } |
3468 | } | 3700 | } |
3469 | 3701 | ||
3470 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | 3702 | if (lowest.Position.Z != float.MaxValue) |
3703 | { | ||
3704 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
3705 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3706 | } | ||
3707 | else | ||
3708 | CollisionPlane = Vector4.UnitW; | ||
3709 | /* | ||
3471 | } | 3710 | } |
3472 | break; | 3711 | break; |
3473 | } | 3712 | } |
3713 | */ | ||
3474 | } | 3714 | } |
3715 | else | ||
3716 | CollisionPlane = Vector4.UnitW; | ||
3717 | |||
3718 | RaiseCollisionScriptEvents(coldata); | ||
3475 | 3719 | ||
3476 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3720 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3477 | if (Invulnerable || GodLevel > 0) | 3721 | if (Invulnerable || GodLevel > 0) |
@@ -3570,6 +3814,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3570 | // m_reprioritizationTimer.Dispose(); | 3814 | // m_reprioritizationTimer.Dispose(); |
3571 | 3815 | ||
3572 | RemoveFromPhysicalScene(); | 3816 | RemoveFromPhysicalScene(); |
3817 | |||
3818 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3819 | |||
3820 | // if (Animator != null) | ||
3821 | // Animator.Close(); | ||
3822 | Animator = null; | ||
3823 | |||
3573 | } | 3824 | } |
3574 | 3825 | ||
3575 | public void AddAttachment(SceneObjectGroup gobj) | 3826 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3803,10 +4054,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3803 | 4054 | ||
3804 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 4055 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3805 | { | 4056 | { |
4057 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
4058 | if (p == null) | ||
4059 | return; | ||
4060 | |||
4061 | ControllingClient.SendTakeControls(controls, false, false); | ||
4062 | ControllingClient.SendTakeControls(controls, true, false); | ||
4063 | |||
3806 | ScriptControllers obj = new ScriptControllers(); | 4064 | ScriptControllers obj = new ScriptControllers(); |
3807 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 4065 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3808 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 4066 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3809 | 4067 | ||
4068 | obj.objectID = p.ParentGroup.UUID; | ||
3810 | obj.itemID = Script_item_UUID; | 4069 | obj.itemID = Script_item_UUID; |
3811 | if (pass_on == 0 && accept == 0) | 4070 | if (pass_on == 0 && accept == 0) |
3812 | { | 4071 | { |
@@ -3855,6 +4114,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3855 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 4114 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3856 | } | 4115 | } |
3857 | 4116 | ||
4117 | private void UnRegisterSeatControls(UUID obj) | ||
4118 | { | ||
4119 | List<UUID> takers = new List<UUID>(); | ||
4120 | |||
4121 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
4122 | { | ||
4123 | if (c.objectID == obj) | ||
4124 | takers.Add(c.itemID); | ||
4125 | } | ||
4126 | foreach (UUID t in takers) | ||
4127 | { | ||
4128 | UnRegisterControlEventsToScript(0, t); | ||
4129 | } | ||
4130 | } | ||
4131 | |||
3858 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 4132 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3859 | { | 4133 | { |
3860 | ScriptControllers takecontrols; | 4134 | ScriptControllers takecontrols; |
@@ -4184,6 +4458,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4184 | 4458 | ||
4185 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4459 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4186 | { | 4460 | { |
4461 | string reason; | ||
4462 | |||
4463 | // Honor bans | ||
4464 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4465 | return; | ||
4466 | |||
4187 | SceneObjectGroup telehub = null; | 4467 | SceneObjectGroup telehub = null; |
4188 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4468 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4189 | { | 4469 | { |
@@ -4223,11 +4503,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4223 | pos = land.LandData.UserLocation; | 4503 | pos = land.LandData.UserLocation; |
4224 | } | 4504 | } |
4225 | } | 4505 | } |
4226 | 4506 | ||
4227 | land.SendLandUpdateToClient(ControllingClient); | 4507 | land.SendLandUpdateToClient(ControllingClient); |
4228 | } | 4508 | } |
4229 | } | 4509 | } |
4230 | 4510 | ||
4511 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4512 | { | ||
4513 | DetectedObject detobj = new DetectedObject(); | ||
4514 | detobj.keyUUID = obj.UUID; | ||
4515 | detobj.nameStr = obj.Name; | ||
4516 | detobj.ownerUUID = obj.OwnerID; | ||
4517 | detobj.posVector = obj.AbsolutePosition; | ||
4518 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4519 | detobj.velVector = obj.Velocity; | ||
4520 | detobj.colliderType = 0; | ||
4521 | detobj.groupUUID = obj.GroupID; | ||
4522 | |||
4523 | return detobj; | ||
4524 | } | ||
4525 | |||
4526 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4527 | { | ||
4528 | DetectedObject detobj = new DetectedObject(); | ||
4529 | detobj.keyUUID = av.UUID; | ||
4530 | detobj.nameStr = av.ControllingClient.Name; | ||
4531 | detobj.ownerUUID = av.UUID; | ||
4532 | detobj.posVector = av.AbsolutePosition; | ||
4533 | detobj.rotQuat = av.Rotation; | ||
4534 | detobj.velVector = av.Velocity; | ||
4535 | detobj.colliderType = 0; | ||
4536 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4537 | |||
4538 | return detobj; | ||
4539 | } | ||
4540 | |||
4541 | private DetectedObject CreateDetObjectForGround() | ||
4542 | { | ||
4543 | DetectedObject detobj = new DetectedObject(); | ||
4544 | detobj.keyUUID = UUID.Zero; | ||
4545 | detobj.nameStr = ""; | ||
4546 | detobj.ownerUUID = UUID.Zero; | ||
4547 | detobj.posVector = AbsolutePosition; | ||
4548 | detobj.rotQuat = Quaternion.Identity; | ||
4549 | detobj.velVector = Vector3.Zero; | ||
4550 | detobj.colliderType = 0; | ||
4551 | detobj.groupUUID = UUID.Zero; | ||
4552 | |||
4553 | return detobj; | ||
4554 | } | ||
4555 | |||
4556 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4557 | { | ||
4558 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4559 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4560 | foreach (uint localId in colliders) | ||
4561 | { | ||
4562 | if (localId == 0) | ||
4563 | continue; | ||
4564 | |||
4565 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4566 | if (obj != null) | ||
4567 | { | ||
4568 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4569 | colliding.Add(CreateDetObject(obj)); | ||
4570 | } | ||
4571 | else | ||
4572 | { | ||
4573 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4574 | if (av != null && (!av.IsChildAgent)) | ||
4575 | { | ||
4576 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4577 | colliding.Add(CreateDetObject(av)); | ||
4578 | } | ||
4579 | } | ||
4580 | } | ||
4581 | |||
4582 | colliderArgs.Colliders = colliding; | ||
4583 | |||
4584 | return colliderArgs; | ||
4585 | } | ||
4586 | |||
4587 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4588 | |||
4589 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4590 | { | ||
4591 | ColliderArgs CollidingMessage; | ||
4592 | |||
4593 | if (colliders.Count > 0) | ||
4594 | { | ||
4595 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4596 | { | ||
4597 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4598 | |||
4599 | if (CollidingMessage.Colliders.Count > 0) | ||
4600 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4601 | } | ||
4602 | } | ||
4603 | } | ||
4604 | |||
4605 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4606 | { | ||
4607 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4608 | { | ||
4609 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4610 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4611 | |||
4612 | colliding.Add(CreateDetObjectForGround()); | ||
4613 | LandCollidingMessage.Colliders = colliding; | ||
4614 | |||
4615 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4616 | } | ||
4617 | } | ||
4618 | |||
4619 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4620 | { | ||
4621 | try | ||
4622 | { | ||
4623 | List<uint> thisHitColliders = new List<uint>(); | ||
4624 | List<uint> endedColliders = new List<uint>(); | ||
4625 | List<uint> startedColliders = new List<uint>(); | ||
4626 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4627 | CollisionForSoundInfo soundinfo; | ||
4628 | ContactPoint curcontact; | ||
4629 | |||
4630 | if (coldata.Count == 0) | ||
4631 | { | ||
4632 | if (m_lastColliders.Count == 0) | ||
4633 | return; // nothing to do | ||
4634 | |||
4635 | foreach (uint localID in m_lastColliders) | ||
4636 | { | ||
4637 | endedColliders.Add(localID); | ||
4638 | } | ||
4639 | m_lastColliders.Clear(); | ||
4640 | } | ||
4641 | |||
4642 | else | ||
4643 | { | ||
4644 | foreach (uint id in coldata.Keys) | ||
4645 | { | ||
4646 | thisHitColliders.Add(id); | ||
4647 | if (!m_lastColliders.Contains(id)) | ||
4648 | { | ||
4649 | startedColliders.Add(id); | ||
4650 | curcontact = coldata[id]; | ||
4651 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4652 | { | ||
4653 | soundinfo = new CollisionForSoundInfo(); | ||
4654 | soundinfo.colliderID = id; | ||
4655 | soundinfo.position = curcontact.Position; | ||
4656 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4657 | soundinfolist.Add(soundinfo); | ||
4658 | } | ||
4659 | } | ||
4660 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4661 | } | ||
4662 | |||
4663 | // calculate things that ended colliding | ||
4664 | foreach (uint localID in m_lastColliders) | ||
4665 | { | ||
4666 | if (!thisHitColliders.Contains(localID)) | ||
4667 | { | ||
4668 | endedColliders.Add(localID); | ||
4669 | } | ||
4670 | } | ||
4671 | //add the items that started colliding this time to the last colliders list. | ||
4672 | foreach (uint localID in startedColliders) | ||
4673 | { | ||
4674 | m_lastColliders.Add(localID); | ||
4675 | } | ||
4676 | // remove things that ended colliding from the last colliders list | ||
4677 | foreach (uint localID in endedColliders) | ||
4678 | { | ||
4679 | m_lastColliders.Remove(localID); | ||
4680 | } | ||
4681 | |||
4682 | if (soundinfolist.Count > 0) | ||
4683 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4684 | } | ||
4685 | |||
4686 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4687 | { | ||
4688 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4689 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4690 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4691 | |||
4692 | if (startedColliders.Contains(0)) | ||
4693 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4694 | if (m_lastColliders.Contains(0)) | ||
4695 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4696 | if (endedColliders.Contains(0)) | ||
4697 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4698 | } | ||
4699 | } | ||
4700 | finally | ||
4701 | { | ||
4702 | m_collisionEventFlag = false; | ||
4703 | } | ||
4704 | } | ||
4705 | |||
4231 | private void TeleportFlagsDebug() { | 4706 | private void TeleportFlagsDebug() { |
4232 | 4707 | ||
4233 | // Some temporary debugging help to show all the TeleportFlags we have... | 4708 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4252,6 +4727,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4252 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4727 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4253 | 4728 | ||
4254 | } | 4729 | } |
4255 | |||
4256 | } | 4730 | } |
4257 | } | 4731 | } |