diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1100 |
1 files changed, 786 insertions, 314 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b8ff7f7..1859cb1 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 |
@@ -490,7 +504,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
490 | if (ParentID == 0) | 504 | if (ParentID == 0) |
491 | { | 505 | { |
492 | m_pos = value; | 506 | m_pos = value; |
493 | ParentPosition = Vector3.Zero; | 507 | // ParentPosition = Vector3.Zero; |
494 | } | 508 | } |
495 | 509 | ||
496 | //m_log.DebugFormat( | 510 | //m_log.DebugFormat( |
@@ -559,7 +573,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
559 | // Scene.RegionInfo.RegionName, Name, m_velocity); | 573 | // Scene.RegionInfo.RegionName, Name, m_velocity); |
560 | } | 574 | } |
561 | } | 575 | } |
576 | /* | ||
577 | public override Vector3 AngularVelocity | ||
578 | { | ||
579 | get | ||
580 | { | ||
581 | if (PhysicsActor != null) | ||
582 | { | ||
583 | m_rotationalvelocity = PhysicsActor.RotationalVelocity; | ||
562 | 584 | ||
585 | // m_log.DebugFormat( | ||
586 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
587 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
588 | } | ||
589 | |||
590 | return m_rotationalvelocity; | ||
591 | } | ||
592 | } | ||
593 | */ | ||
563 | private Quaternion m_bodyRot = Quaternion.Identity; | 594 | private Quaternion m_bodyRot = Quaternion.Identity; |
564 | 595 | ||
565 | /// <summary> | 596 | /// <summary> |
@@ -582,8 +613,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
582 | m_bodyRot = value; | 613 | m_bodyRot = value; |
583 | 614 | ||
584 | if (PhysicsActor != null) | 615 | if (PhysicsActor != null) |
585 | PhysicsActor.Orientation = m_bodyRot; | 616 | { |
586 | 617 | try | |
618 | { | ||
619 | PhysicsActor.Orientation = m_bodyRot; | ||
620 | } | ||
621 | catch (Exception e) | ||
622 | { | ||
623 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); | ||
624 | } | ||
625 | } | ||
587 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 626 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
588 | } | 627 | } |
589 | } | 628 | } |
@@ -597,12 +636,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
597 | } | 636 | } |
598 | 637 | ||
599 | public bool IsChildAgent { get; set; } | 638 | public bool IsChildAgent { get; set; } |
639 | public bool IsLoggingIn { get; set; } | ||
600 | 640 | ||
601 | /// <summary> | 641 | /// <summary> |
602 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. | 642 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. |
603 | /// </summary> | 643 | /// </summary> |
604 | public uint ParentID { get; set; } | 644 | public uint ParentID { get; set; } |
605 | 645 | ||
646 | public UUID ParentUUID | ||
647 | { | ||
648 | get { return m_parentUUID; } | ||
649 | set { m_parentUUID = value; } | ||
650 | } | ||
651 | private UUID m_parentUUID = UUID.Zero; | ||
652 | |||
606 | /// <summary> | 653 | /// <summary> |
607 | /// Are we sitting on an object? | 654 | /// Are we sitting on an object? |
608 | /// </summary> | 655 | /// </summary> |
@@ -752,6 +799,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
752 | AttachmentsSyncLock = new Object(); | 799 | AttachmentsSyncLock = new Object(); |
753 | AllowMovement = true; | 800 | AllowMovement = true; |
754 | IsChildAgent = true; | 801 | IsChildAgent = true; |
802 | IsLoggingIn = false; | ||
755 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; | 803 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; |
756 | Animator = new ScenePresenceAnimator(this); | 804 | Animator = new ScenePresenceAnimator(this); |
757 | PresenceType = type; | 805 | PresenceType = type; |
@@ -795,6 +843,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
795 | Appearance = appearance; | 843 | Appearance = appearance; |
796 | } | 844 | } |
797 | 845 | ||
846 | private void RegionHeartbeatEnd(Scene scene) | ||
847 | { | ||
848 | if (IsChildAgent) | ||
849 | return; | ||
850 | |||
851 | m_movementAnimationUpdateCounter ++; | ||
852 | if (m_movementAnimationUpdateCounter >= 2) | ||
853 | { | ||
854 | m_movementAnimationUpdateCounter = 0; | ||
855 | if (Animator != null) | ||
856 | { | ||
857 | // If the parentID == 0 we are not sitting | ||
858 | // if !SitGournd then we are not sitting on the ground | ||
859 | // Fairly straightforward, now here comes the twist | ||
860 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
861 | // be sat on an object that isn't there yet. Should | ||
862 | // be treated as if sat. | ||
863 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
864 | Animator.UpdateMovementAnimations(); | ||
865 | } | ||
866 | else | ||
867 | { | ||
868 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
869 | } | ||
870 | } | ||
871 | } | ||
872 | |||
798 | public void RegisterToEvents() | 873 | public void RegisterToEvents() |
799 | { | 874 | { |
800 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 875 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -804,8 +879,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
804 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 879 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
805 | ControllingClient.OnStartAnim += HandleStartAnim; | 880 | ControllingClient.OnStartAnim += HandleStartAnim; |
806 | ControllingClient.OnStopAnim += HandleStopAnim; | 881 | ControllingClient.OnStopAnim += HandleStopAnim; |
882 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
807 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 883 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
808 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 884 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
885 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
809 | 886 | ||
810 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 887 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
811 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 888 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -864,6 +941,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
864 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 941 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
865 | Name, m_scene.RegionInfo.RegionName); | 942 | Name, m_scene.RegionInfo.RegionName); |
866 | 943 | ||
944 | if (ParentUUID != UUID.Zero) | ||
945 | { | ||
946 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
947 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
948 | if (part == null) | ||
949 | { | ||
950 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
951 | } | ||
952 | else | ||
953 | { | ||
954 | part.ParentGroup.AddAvatar(UUID); | ||
955 | if (part.SitTargetPosition != Vector3.Zero) | ||
956 | part.SitTargetAvatar = UUID; | ||
957 | // ParentPosition = part.GetWorldPosition(); | ||
958 | ParentID = part.LocalId; | ||
959 | ParentPart = part; | ||
960 | m_pos = m_prevSitOffset; | ||
961 | // pos = ParentPosition; | ||
962 | pos = part.GetWorldPosition(); | ||
963 | } | ||
964 | ParentUUID = UUID.Zero; | ||
965 | |||
966 | IsChildAgent = false; | ||
967 | |||
968 | // Animator.TrySetMovementAnimation("SIT"); | ||
969 | } | ||
970 | else | ||
971 | { | ||
972 | IsChildAgent = false; | ||
973 | IsLoggingIn = false; | ||
974 | } | ||
975 | |||
867 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | 976 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); |
868 | 977 | ||
869 | IsChildAgent = false; | 978 | IsChildAgent = false; |
@@ -876,70 +985,106 @@ namespace OpenSim.Region.Framework.Scenes | |||
876 | 985 | ||
877 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 986 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
878 | 987 | ||
879 | // Moved this from SendInitialData to ensure that Appearance is initialized | 988 | UUID groupUUID = UUID.Zero; |
880 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 989 | string GroupName = string.Empty; |
881 | // related to the handling of attachments | 990 | ulong groupPowers = 0; |
882 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
883 | 991 | ||
884 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 992 | // ---------------------------------- |
993 | // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status | ||
994 | try | ||
885 | { | 995 | { |
886 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 996 | if (gm != null) |
887 | pos.X = crossedBorder.BorderLine.Z - 1; | 997 | { |
998 | groupUUID = ControllingClient.ActiveGroupId; | ||
999 | GroupRecord record = gm.GetGroupRecord(groupUUID); | ||
1000 | if (record != null) | ||
1001 | GroupName = record.GroupName; | ||
1002 | GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); | ||
1003 | if (groupMembershipData != null) | ||
1004 | groupPowers = groupMembershipData.GroupPowers; | ||
1005 | } | ||
1006 | ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, | ||
1007 | Grouptitle); | ||
888 | } | 1008 | } |
889 | 1009 | catch (Exception e) | |
890 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | ||
891 | { | 1010 | { |
892 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 1011 | m_log.Debug("[AGENTUPDATE]: " + e.ToString()); |
893 | pos.Y = crossedBorder.BorderLine.Z - 1; | ||
894 | } | 1012 | } |
1013 | // ------------------------------------ | ||
895 | 1014 | ||
896 | CheckAndAdjustLandingPoint(ref pos); | 1015 | if (ParentID == 0) |
897 | |||
898 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | ||
899 | { | 1016 | { |
900 | m_log.WarnFormat( | 1017 | // Moved this from SendInitialData to ensure that Appearance is initialized |
901 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 1018 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
902 | pos, Name, UUID); | 1019 | // related to the handling of attachments |
1020 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
1021 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
1022 | { | ||
1023 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
1024 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
1025 | } | ||
903 | 1026 | ||
904 | if (pos.X < 0f) pos.X = 0f; | 1027 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
905 | if (pos.Y < 0f) pos.Y = 0f; | 1028 | { |
906 | if (pos.Z < 0f) pos.Z = 0f; | 1029 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
907 | } | 1030 | pos.Y = crossedBorder.BorderLine.Z - 1; |
1031 | } | ||
908 | 1032 | ||
909 | float localAVHeight = 1.56f; | 1033 | CheckAndAdjustLandingPoint(ref pos); |
910 | if (Appearance.AvatarHeight > 0) | ||
911 | localAVHeight = Appearance.AvatarHeight; | ||
912 | 1034 | ||
913 | float posZLimit = 0; | 1035 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
1036 | { | ||
1037 | m_log.WarnFormat( | ||
1038 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | ||
1039 | pos, Name, UUID); | ||
914 | 1040 | ||
915 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 1041 | if (pos.X < 0f) pos.X = 0f; |
916 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 1042 | if (pos.Y < 0f) pos.Y = 0f; |
917 | 1043 | if (pos.Z < 0f) pos.Z = 0f; | |
918 | float newPosZ = posZLimit + localAVHeight / 2; | 1044 | } |
919 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
920 | { | ||
921 | pos.Z = newPosZ; | ||
922 | } | ||
923 | AbsolutePosition = pos; | ||
924 | 1045 | ||
925 | AddToPhysicalScene(isFlying); | 1046 | float localAVHeight = 1.56f; |
1047 | if (Appearance.AvatarHeight > 0) | ||
1048 | localAVHeight = Appearance.AvatarHeight; | ||
926 | 1049 | ||
927 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | 1050 | float posZLimit = 0; |
928 | // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it | ||
929 | // since it requires a physics actor to be present. If it is left any later, then physics appears to reset | ||
930 | // the value to a negative position which does not trigger the border cross. | ||
931 | // This may not be the best location for this. | ||
932 | CheckForBorderCrossing(); | ||
933 | 1051 | ||
934 | if (ForceFly) | 1052 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
935 | { | 1053 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
936 | Flying = true; | 1054 | |
937 | } | 1055 | float newPosZ = posZLimit + localAVHeight / 2; |
938 | else if (FlyDisabled) | 1056 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
939 | { | 1057 | { |
940 | Flying = false; | 1058 | pos.Z = newPosZ; |
941 | } | 1059 | } |
1060 | AbsolutePosition = pos; | ||
942 | 1061 | ||
1062 | if (m_teleportFlags == TeleportFlags.Default) | ||
1063 | { | ||
1064 | Vector3 vel = Velocity; | ||
1065 | AddToPhysicalScene(isFlying); | ||
1066 | if (PhysicsActor != null) | ||
1067 | PhysicsActor.SetMomentum(vel); | ||
1068 | } | ||
1069 | else | ||
1070 | AddToPhysicalScene(isFlying); | ||
1071 | |||
1072 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | ||
1073 | // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it | ||
1074 | // since it requires a physics actor to be present. If it is left any later, then physics appears to reset | ||
1075 | // the value to a negative position which does not trigger the border cross. | ||
1076 | // This may not be the best location for this. | ||
1077 | CheckForBorderCrossing(); | ||
1078 | |||
1079 | if (ForceFly) | ||
1080 | { | ||
1081 | Flying = true; | ||
1082 | } | ||
1083 | else if (FlyDisabled) | ||
1084 | { | ||
1085 | Flying = false; | ||
1086 | } | ||
1087 | } | ||
943 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1088 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
944 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 1089 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
945 | // elsewhere anyway | 1090 | // elsewhere anyway |
@@ -979,15 +1124,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
979 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | 1124 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
980 | 1125 | ||
981 | // Resume scripts | 1126 | // Resume scripts |
982 | foreach (SceneObjectGroup sog in m_attachments) | 1127 | Util.FireAndForget(delegate(object x) { |
983 | { | 1128 | foreach (SceneObjectGroup sog in m_attachments) |
984 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 1129 | { |
985 | sog.ResumeScripts(); | 1130 | sog.ScheduleGroupForFullUpdate(); |
986 | } | 1131 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
1132 | sog.ResumeScripts(); | ||
1133 | } | ||
1134 | }); | ||
987 | } | 1135 | } |
988 | } | 1136 | } |
989 | } | 1137 | } |
990 | 1138 | ||
1139 | SendAvatarDataToAllAgents(); | ||
1140 | |||
991 | // send the animations of the other presences to me | 1141 | // send the animations of the other presences to me |
992 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 1142 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
993 | { | 1143 | { |
@@ -998,9 +1148,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
998 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1148 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
999 | // stall on the border crossing since the existing child agent will still have the last movement | 1149 | // stall on the border crossing since the existing child agent will still have the last movement |
1000 | // recorded, which stops the input from being processed. | 1150 | // recorded, which stops the input from being processed. |
1151 | |||
1001 | MovementFlag = 0; | 1152 | MovementFlag = 0; |
1002 | 1153 | ||
1003 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1154 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1155 | |||
1156 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
1004 | } | 1157 | } |
1005 | 1158 | ||
1006 | public int GetStateSource() | 1159 | public int GetStateSource() |
@@ -1028,12 +1181,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1028 | /// </remarks> | 1181 | /// </remarks> |
1029 | public void MakeChildAgent() | 1182 | public void MakeChildAgent() |
1030 | { | 1183 | { |
1184 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1185 | |||
1031 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1186 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
1032 | 1187 | ||
1033 | // Reset these so that teleporting in and walking out isn't seen | 1188 | // Reset these so that teleporting in and walking out isn't seen |
1034 | // as teleporting back | 1189 | // as teleporting back |
1035 | TeleportFlags = TeleportFlags.Default; | 1190 | TeleportFlags = TeleportFlags.Default; |
1036 | 1191 | ||
1192 | MovementFlag = 0; | ||
1193 | |||
1037 | // It looks like Animator is set to null somewhere, and MakeChild | 1194 | // It looks like Animator is set to null somewhere, and MakeChild |
1038 | // is called after that. Probably in aborted teleports. | 1195 | // is called after that. Probably in aborted teleports. |
1039 | if (Animator == null) | 1196 | if (Animator == null) |
@@ -1041,6 +1198,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1041 | else | 1198 | else |
1042 | Animator.ResetAnimations(); | 1199 | Animator.ResetAnimations(); |
1043 | 1200 | ||
1201 | |||
1044 | // m_log.DebugFormat( | 1202 | // m_log.DebugFormat( |
1045 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1203 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
1046 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1204 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -1052,6 +1210,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1052 | IsChildAgent = true; | 1210 | IsChildAgent = true; |
1053 | m_scene.SwapRootAgentCount(true); | 1211 | m_scene.SwapRootAgentCount(true); |
1054 | RemoveFromPhysicalScene(); | 1212 | RemoveFromPhysicalScene(); |
1213 | ParentID = 0; // Child agents can't be sitting | ||
1055 | 1214 | ||
1056 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1215 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
1057 | 1216 | ||
@@ -1067,9 +1226,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1067 | { | 1226 | { |
1068 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1227 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
1069 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1228 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
1070 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1071 | PhysicsActor.UnSubscribeEvents(); | ||
1072 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1229 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1230 | PhysicsActor.UnSubscribeEvents(); | ||
1231 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1073 | PhysicsActor = null; | 1232 | PhysicsActor = null; |
1074 | } | 1233 | } |
1075 | // else | 1234 | // else |
@@ -1086,7 +1245,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1086 | /// <param name="pos"></param> | 1245 | /// <param name="pos"></param> |
1087 | public void Teleport(Vector3 pos) | 1246 | public void Teleport(Vector3 pos) |
1088 | { | 1247 | { |
1089 | TeleportWithMomentum(pos, null); | 1248 | TeleportWithMomentum(pos, Vector3.Zero); |
1090 | } | 1249 | } |
1091 | 1250 | ||
1092 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1251 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1110,6 +1269,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1110 | SendTerseUpdateToAllClients(); | 1269 | SendTerseUpdateToAllClients(); |
1111 | } | 1270 | } |
1112 | 1271 | ||
1272 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1273 | { | ||
1274 | CheckLandingPoint(ref newpos); | ||
1275 | AbsolutePosition = newpos; | ||
1276 | |||
1277 | if (newvel.HasValue) | ||
1278 | { | ||
1279 | if ((Vector3)newvel == Vector3.Zero) | ||
1280 | { | ||
1281 | if (PhysicsActor != null) | ||
1282 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1283 | m_velocity = Vector3.Zero; | ||
1284 | } | ||
1285 | else | ||
1286 | { | ||
1287 | if (PhysicsActor != null) | ||
1288 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1289 | m_velocity = (Vector3)newvel; | ||
1290 | |||
1291 | if (rotateToVelXY) | ||
1292 | { | ||
1293 | Vector3 lookAt = (Vector3)newvel; | ||
1294 | lookAt.Z = 0; | ||
1295 | lookAt.Normalize(); | ||
1296 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1297 | return; | ||
1298 | } | ||
1299 | } | ||
1300 | } | ||
1301 | |||
1302 | SendTerseUpdateToAllClients(); | ||
1303 | } | ||
1304 | |||
1305 | |||
1306 | |||
1113 | public void StopFlying() | 1307 | public void StopFlying() |
1114 | { | 1308 | { |
1115 | ControllingClient.StopFlying(this); | 1309 | ControllingClient.StopFlying(this); |
@@ -1279,6 +1473,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1279 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); | 1473 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); |
1280 | } | 1474 | } |
1281 | 1475 | ||
1476 | public void SetSize(Vector3 size, float feetoffset) | ||
1477 | { | ||
1478 | if (PhysicsActor != null && !IsChildAgent) | ||
1479 | PhysicsActor.setAvatarSize(size, feetoffset); | ||
1480 | |||
1481 | } | ||
1482 | |||
1282 | /// <summary> | 1483 | /// <summary> |
1283 | /// Complete Avatar's movement into the region. | 1484 | /// Complete Avatar's movement into the region. |
1284 | /// </summary> | 1485 | /// </summary> |
@@ -1298,7 +1499,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1298 | 1499 | ||
1299 | Vector3 look = Velocity; | 1500 | Vector3 look = Velocity; |
1300 | 1501 | ||
1301 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1502 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1503 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1302 | { | 1504 | { |
1303 | look = new Vector3(0.99f, 0.042f, 0); | 1505 | look = new Vector3(0.99f, 0.042f, 0); |
1304 | } | 1506 | } |
@@ -1353,11 +1555,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1353 | 1555 | ||
1354 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1556 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1355 | if (m_agentTransfer != null) | 1557 | if (m_agentTransfer != null) |
1356 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1558 | m_agentTransfer.EnableChildAgents(this); |
1357 | 1559 | ||
1358 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1560 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1359 | if (friendsModule != null) | 1561 | if (friendsModule != null) |
1360 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1562 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1563 | |||
1361 | } | 1564 | } |
1362 | 1565 | ||
1363 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region | 1566 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region |
@@ -1382,36 +1585,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1382 | /// <param name="collisionPoint"></param> | 1585 | /// <param name="collisionPoint"></param> |
1383 | /// <param name="localid"></param> | 1586 | /// <param name="localid"></param> |
1384 | /// <param name="distance"></param> | 1587 | /// <param name="distance"></param> |
1588 | /// | ||
1589 | |||
1590 | private void UpdateCameraCollisionPlane(Vector4 plane) | ||
1591 | { | ||
1592 | if (m_lastCameraCollisionPlane != plane) | ||
1593 | { | ||
1594 | m_lastCameraCollisionPlane = plane; | ||
1595 | ControllingClient.SendCameraConstraint(plane); | ||
1596 | } | ||
1597 | } | ||
1598 | |||
1385 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) | 1599 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) |
1386 | { | 1600 | { |
1387 | const float POSITION_TOLERANCE = 0.02f; | 1601 | const float POSITION_TOLERANCE = 0.02f; |
1388 | const float VELOCITY_TOLERANCE = 0.02f; | ||
1389 | const float ROTATION_TOLERANCE = 0.02f; | 1602 | const float ROTATION_TOLERANCE = 0.02f; |
1390 | 1603 | ||
1391 | if (m_followCamAuto) | 1604 | m_doingCamRayCast = false; |
1605 | if (hitYN && localid != LocalId) | ||
1392 | { | 1606 | { |
1393 | if (hitYN) | 1607 | SceneObjectGroup group = m_scene.GetGroupByPrim(localid); |
1608 | bool IsPrim = group != null; | ||
1609 | if (IsPrim) | ||
1394 | { | 1610 | { |
1395 | CameraConstraintActive = true; | 1611 | SceneObjectPart part = group.GetPart(localid); |
1396 | //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); | 1612 | if (part != null && !part.VolumeDetectActive) |
1397 | 1613 | { | |
1398 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1614 | CameraConstraintActive = true; |
1399 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1615 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1616 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); | ||
1617 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); | ||
1618 | pNormal.Normalize(); | ||
1619 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); | ||
1620 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); | ||
1621 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); | ||
1622 | |||
1623 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, | ||
1624 | Vector3.Dot(collisionPoint, pNormal)); | ||
1625 | UpdateCameraCollisionPlane(plane); | ||
1626 | } | ||
1400 | } | 1627 | } |
1401 | else | 1628 | else |
1402 | { | 1629 | { |
1403 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 1630 | CameraConstraintActive = true; |
1404 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 1631 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1405 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | 1632 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); |
1406 | { | 1633 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); |
1407 | if (CameraConstraintActive) | 1634 | pNormal.Normalize(); |
1408 | { | 1635 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); |
1409 | ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); | 1636 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); |
1410 | CameraConstraintActive = false; | 1637 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); |
1411 | } | 1638 | |
1412 | } | 1639 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, |
1640 | Vector3.Dot(collisionPoint, pNormal)); | ||
1641 | UpdateCameraCollisionPlane(plane); | ||
1413 | } | 1642 | } |
1414 | } | 1643 | } |
1644 | else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | ||
1645 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | ||
1646 | { | ||
1647 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... | ||
1648 | UpdateCameraCollisionPlane(plane); | ||
1649 | CameraConstraintActive = false; | ||
1650 | } | ||
1415 | } | 1651 | } |
1416 | 1652 | ||
1417 | /// <summary> | 1653 | /// <summary> |
@@ -1485,12 +1721,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1485 | // DrawDistance = agentData.Far; | 1721 | // DrawDistance = agentData.Far; |
1486 | DrawDistance = Scene.DefaultDrawDistance; | 1722 | DrawDistance = Scene.DefaultDrawDistance; |
1487 | 1723 | ||
1488 | // Check if Client has camera in 'follow cam' or 'build' mode. | ||
1489 | Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); | ||
1490 | |||
1491 | m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) | ||
1492 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | ||
1493 | |||
1494 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | 1724 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; |
1495 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | 1725 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; |
1496 | 1726 | ||
@@ -1510,14 +1740,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
1510 | StandUp(); | 1740 | StandUp(); |
1511 | } | 1741 | } |
1512 | 1742 | ||
1513 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | ||
1514 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 1743 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
1515 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 1744 | // this exclude checks may not be complete |
1745 | |||
1746 | if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) | ||
1516 | { | 1747 | { |
1517 | if (m_followCamAuto) | 1748 | if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) |
1749 | { | ||
1750 | Vector3 posAdjusted = AbsolutePosition; | ||
1751 | // posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; | ||
1752 | posAdjusted.Z += 1.0f; // viewer current camera focus point | ||
1753 | Vector3 tocam = CameraPosition - posAdjusted; | ||
1754 | tocam.X = (float)Math.Round(tocam.X, 1); | ||
1755 | tocam.Y = (float)Math.Round(tocam.Y, 1); | ||
1756 | tocam.Z = (float)Math.Round(tocam.Z, 1); | ||
1757 | |||
1758 | float distTocamlen = tocam.Length(); | ||
1759 | if (distTocamlen > 0.3f) | ||
1760 | { | ||
1761 | tocam *= (1.0f / distTocamlen); | ||
1762 | posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); | ||
1763 | posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); | ||
1764 | posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); | ||
1765 | |||
1766 | m_doingCamRayCast = true; | ||
1767 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); | ||
1768 | } | ||
1769 | } | ||
1770 | else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) | ||
1518 | { | 1771 | { |
1519 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1772 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... |
1520 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1773 | UpdateCameraCollisionPlane(plane); |
1774 | CameraConstraintActive = false; | ||
1521 | } | 1775 | } |
1522 | } | 1776 | } |
1523 | 1777 | ||
@@ -1982,7 +2236,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1982 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); | 2236 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); |
1983 | 2237 | ||
1984 | MovingToTarget = false; | 2238 | MovingToTarget = false; |
1985 | MoveToPositionTarget = Vector3.Zero; | 2239 | // MoveToPositionTarget = Vector3.Zero; |
2240 | m_forceToApply = null; // cancel possible last action | ||
1986 | 2241 | ||
1987 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct | 2242 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct |
1988 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. | 2243 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. |
@@ -2000,12 +2255,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2000 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 2255 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
2001 | 2256 | ||
2002 | SitGround = false; | 2257 | SitGround = false; |
2258 | |||
2259 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
2003 | if (PhysicsActor == null) | 2260 | if (PhysicsActor == null) |
2004 | AddToPhysicalScene(false); | 2261 | AddToPhysicalScene(false); |
2262 | */ | ||
2005 | 2263 | ||
2006 | if (ParentID != 0) | 2264 | if (ParentID != 0) |
2007 | { | 2265 | { |
2008 | SceneObjectPart part = ParentPart; | 2266 | SceneObjectPart part = ParentPart; |
2267 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
2268 | |||
2009 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 2269 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
2010 | if (taskIDict != null) | 2270 | if (taskIDict != null) |
2011 | { | 2271 | { |
@@ -2021,14 +2281,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2021 | } | 2281 | } |
2022 | } | 2282 | } |
2023 | 2283 | ||
2024 | ParentPosition = part.GetWorldPosition(); | 2284 | part.ParentGroup.DeleteAvatar(UUID); |
2285 | // ParentPosition = part.GetWorldPosition(); | ||
2025 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 2286 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
2026 | 2287 | ||
2027 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 2288 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
2028 | ParentPosition = Vector3.Zero; | 2289 | // ParentPosition = Vector3.Zero; |
2290 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
2291 | if (part.SitTargetAvatar == UUID) | ||
2292 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
2029 | 2293 | ||
2030 | ParentID = 0; | 2294 | ParentID = 0; |
2031 | ParentPart = null; | 2295 | ParentPart = null; |
2296 | |||
2297 | if (PhysicsActor == null) | ||
2298 | AddToPhysicalScene(false); | ||
2299 | |||
2032 | SendAvatarDataToAllAgents(); | 2300 | SendAvatarDataToAllAgents(); |
2033 | m_requestedSitTargetID = 0; | 2301 | m_requestedSitTargetID = 0; |
2034 | 2302 | ||
@@ -2038,6 +2306,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2038 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2306 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2039 | } | 2307 | } |
2040 | 2308 | ||
2309 | else if (PhysicsActor == null) | ||
2310 | AddToPhysicalScene(false); | ||
2311 | |||
2041 | Animator.TrySetMovementAnimation("STAND"); | 2312 | Animator.TrySetMovementAnimation("STAND"); |
2042 | TriggerScenePresenceUpdated(); | 2313 | TriggerScenePresenceUpdated(); |
2043 | } | 2314 | } |
@@ -2086,11 +2357,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2086 | if (part == null) | 2357 | if (part == null) |
2087 | return; | 2358 | return; |
2088 | 2359 | ||
2089 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
2090 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
2091 | |||
2092 | if (PhysicsActor != null) | 2360 | if (PhysicsActor != null) |
2093 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2361 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2094 | 2362 | ||
2095 | bool canSit = false; | 2363 | bool canSit = false; |
2096 | Vector3 pos = part.AbsolutePosition + offset; | 2364 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -2107,31 +2375,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
2107 | } | 2375 | } |
2108 | else | 2376 | else |
2109 | { | 2377 | { |
2378 | if (PhysicsSit(part,offset)) // physics engine | ||
2379 | return; | ||
2380 | |||
2110 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2381 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2111 | { | 2382 | { |
2112 | // m_log.DebugFormat( | ||
2113 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | ||
2114 | // Name, part.Name, part.LocalId); | ||
2115 | 2383 | ||
2116 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2384 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2117 | canSit = true; | 2385 | canSit = true; |
2118 | } | 2386 | } |
2119 | // else | ||
2120 | // { | ||
2121 | // m_log.DebugFormat( | ||
2122 | // "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", | ||
2123 | // Name, part.Name, part.LocalId); | ||
2124 | // } | ||
2125 | } | 2387 | } |
2126 | 2388 | ||
2127 | if (canSit) | 2389 | if (canSit) |
2128 | { | 2390 | { |
2391 | |||
2129 | if (PhysicsActor != null) | 2392 | if (PhysicsActor != null) |
2130 | { | 2393 | { |
2131 | // We can remove the physicsActor until they stand up. | 2394 | // We can remove the physicsActor until they stand up. |
2132 | RemoveFromPhysicalScene(); | 2395 | RemoveFromPhysicalScene(); |
2133 | } | 2396 | } |
2134 | 2397 | ||
2398 | if (MovingToTarget) | ||
2399 | ResetMoveToTarget(); | ||
2400 | |||
2401 | Velocity = Vector3.Zero; | ||
2402 | |||
2135 | part.AddSittingAvatar(UUID); | 2403 | part.AddSittingAvatar(UUID); |
2136 | 2404 | ||
2137 | cameraAtOffset = part.GetCameraAtOffset(); | 2405 | cameraAtOffset = part.GetCameraAtOffset(); |
@@ -2153,6 +2421,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2153 | 2421 | ||
2154 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2422 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
2155 | { | 2423 | { |
2424 | if (IsChildAgent) | ||
2425 | return; | ||
2426 | |||
2156 | if (ParentID != 0) | 2427 | if (ParentID != 0) |
2157 | { | 2428 | { |
2158 | if (ParentPart.UUID == targetID) | 2429 | if (ParentPart.UUID == targetID) |
@@ -2168,14 +2439,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2168 | m_requestedSitTargetID = part.LocalId; | 2439 | m_requestedSitTargetID = part.LocalId; |
2169 | m_requestedSitTargetUUID = part.UUID; | 2440 | m_requestedSitTargetUUID = part.UUID; |
2170 | 2441 | ||
2171 | // m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | ||
2172 | |||
2173 | if (m_scene.PhysicsScene.SupportsRayCast()) | ||
2174 | { | ||
2175 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); | ||
2176 | //SitRayCastAvatarPosition(part); | ||
2177 | //return; | ||
2178 | } | ||
2179 | } | 2442 | } |
2180 | else | 2443 | else |
2181 | { | 2444 | { |
@@ -2185,197 +2448,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2185 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2448 | SendSitResponse(targetID, offset, Quaternion.Identity); |
2186 | } | 2449 | } |
2187 | 2450 | ||
2188 | /* | 2451 | // returns false if does not suport so older sit can be tried |
2189 | public void SitRayCastAvatarPosition(SceneObjectPart part) | 2452 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2190 | { | 2453 | { |
2191 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2454 | if (part == null || part.ParentGroup.IsAttachment) |
2192 | Vector3 StartRayCastPosition = AbsolutePosition; | ||
2193 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2194 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2195 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | ||
2196 | } | ||
2197 | |||
2198 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | ||
2199 | { | ||
2200 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2201 | if (part != null) | ||
2202 | { | ||
2203 | if (hitYN) | ||
2204 | { | ||
2205 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2206 | { | ||
2207 | SitRaycastFindEdge(collisionPoint, normal); | ||
2208 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2209 | } | ||
2210 | else | ||
2211 | { | ||
2212 | SitRayCastAvatarPositionCameraZ(part); | ||
2213 | } | ||
2214 | } | ||
2215 | else | ||
2216 | { | ||
2217 | SitRayCastAvatarPositionCameraZ(part); | ||
2218 | } | ||
2219 | } | ||
2220 | else | ||
2221 | { | 2455 | { |
2222 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2456 | return true; |
2223 | m_requestedSitTargetUUID = UUID.Zero; | ||
2224 | m_requestedSitTargetID = 0; | ||
2225 | m_requestedSitOffset = Vector3.Zero; | ||
2226 | } | 2457 | } |
2227 | 2458 | ||
2228 | } | 2459 | if ( m_scene.PhysicsScene == null) |
2229 | 2460 | return false; | |
2230 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | ||
2231 | { | ||
2232 | // Next, try to raycast from the camera Z position | ||
2233 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2234 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | ||
2235 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2236 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2237 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | ||
2238 | } | ||
2239 | 2461 | ||
2240 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2462 | if (part.PhysActor == null) |
2241 | { | ||
2242 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2243 | if (part != null) | ||
2244 | { | 2463 | { |
2245 | if (hitYN) | 2464 | // none physcis shape |
2246 | { | 2465 | if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) |
2247 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2466 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2248 | { | ||
2249 | SitRaycastFindEdge(collisionPoint, normal); | ||
2250 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2251 | } | ||
2252 | else | ||
2253 | { | ||
2254 | SitRayCastCameraPosition(part); | ||
2255 | } | ||
2256 | } | ||
2257 | else | 2467 | else |
2258 | { | 2468 | { // non physical phantom TODO |
2259 | SitRayCastCameraPosition(part); | 2469 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2470 | return false; | ||
2260 | } | 2471 | } |
2261 | } | 2472 | return true; |
2262 | else | ||
2263 | { | ||
2264 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2265 | m_requestedSitTargetUUID = UUID.Zero; | ||
2266 | m_requestedSitTargetID = 0; | ||
2267 | m_requestedSitOffset = Vector3.Zero; | ||
2268 | } | 2473 | } |
2269 | 2474 | ||
2270 | } | ||
2271 | 2475 | ||
2272 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2476 | // not doing autopilot |
2273 | { | 2477 | m_requestedSitTargetID = 0; |
2274 | // Next, try to raycast from the camera position | ||
2275 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2276 | Vector3 StartRayCastPosition = CameraPosition; | ||
2277 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2278 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2279 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | ||
2280 | } | ||
2281 | 2478 | ||
2282 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2479 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) |
2283 | { | 2480 | return true; |
2284 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2285 | if (part != null) | ||
2286 | { | ||
2287 | if (hitYN) | ||
2288 | { | ||
2289 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2290 | { | ||
2291 | SitRaycastFindEdge(collisionPoint, normal); | ||
2292 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2293 | } | ||
2294 | else | ||
2295 | { | ||
2296 | SitRayHorizontal(part); | ||
2297 | } | ||
2298 | } | ||
2299 | else | ||
2300 | { | ||
2301 | SitRayHorizontal(part); | ||
2302 | } | ||
2303 | } | ||
2304 | else | ||
2305 | { | ||
2306 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2307 | m_requestedSitTargetUUID = UUID.Zero; | ||
2308 | m_requestedSitTargetID = 0; | ||
2309 | m_requestedSitOffset = Vector3.Zero; | ||
2310 | } | ||
2311 | 2481 | ||
2482 | return false; | ||
2312 | } | 2483 | } |
2313 | 2484 | ||
2314 | public void SitRayHorizontal(SceneObjectPart part) | 2485 | |
2486 | private bool CanEnterLandPosition(Vector3 testPos) | ||
2315 | { | 2487 | { |
2316 | // Next, try to raycast from the avatar position to fwd | 2488 | ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); |
2317 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2489 | |
2318 | Vector3 StartRayCastPosition = CameraPosition; | 2490 | if (land == null || land.LandData.Name == "NO_LAND") |
2319 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2491 | return true; |
2320 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2492 | |
2321 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | 2493 | return land.CanBeOnThisLand(UUID,testPos.Z); |
2322 | } | 2494 | } |
2323 | 2495 | ||
2324 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2496 | // status |
2497 | // < 0 ignore | ||
2498 | // 0 bad sit spot | ||
2499 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) | ||
2325 | { | 2500 | { |
2326 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2501 | if (status < 0) |
2327 | if (part != null) | 2502 | return; |
2503 | |||
2504 | if (status == 0) | ||
2328 | { | 2505 | { |
2329 | if (hitYN) | 2506 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2330 | { | 2507 | return; |
2331 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2332 | { | ||
2333 | SitRaycastFindEdge(collisionPoint, normal); | ||
2334 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2335 | // Next, try to raycast from the camera position | ||
2336 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2337 | Vector3 StartRayCastPosition = CameraPosition; | ||
2338 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2339 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2340 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | ||
2341 | } | ||
2342 | else | ||
2343 | { | ||
2344 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2345 | m_requestedSitTargetUUID = UUID.Zero; | ||
2346 | m_requestedSitTargetID = 0; | ||
2347 | m_requestedSitOffset = Vector3.Zero; | ||
2348 | } | ||
2349 | } | ||
2350 | else | ||
2351 | { | ||
2352 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2353 | m_requestedSitTargetUUID = UUID.Zero; | ||
2354 | m_requestedSitTargetID = 0; | ||
2355 | m_requestedSitOffset = Vector3.Zero; | ||
2356 | } | ||
2357 | } | 2508 | } |
2358 | else | 2509 | |
2510 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); | ||
2511 | if (part == null) | ||
2512 | return; | ||
2513 | |||
2514 | Vector3 targetPos = part.GetWorldPosition() + offset * part.GetWorldRotation(); | ||
2515 | if(!CanEnterLandPosition(targetPos)) | ||
2359 | { | 2516 | { |
2360 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2517 | ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); |
2361 | m_requestedSitTargetUUID = UUID.Zero; | 2518 | return; |
2362 | m_requestedSitTargetID = 0; | ||
2363 | m_requestedSitOffset = Vector3.Zero; | ||
2364 | } | 2519 | } |
2365 | 2520 | ||
2366 | } | 2521 | RemoveFromPhysicalScene(); |
2367 | 2522 | ||
2368 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2523 | if (MovingToTarget) |
2369 | { | 2524 | ResetMoveToTarget(); |
2370 | int i = 0; | 2525 | |
2371 | //throw new NotImplementedException(); | 2526 | Velocity = Vector3.Zero; |
2372 | //m_requestedSitTargetUUID = UUID.Zero; | 2527 | |
2373 | //m_requestedSitTargetID = 0; | 2528 | part.AddSittingAvatar(UUID); |
2374 | //m_requestedSitOffset = Vector3.Zero; | ||
2375 | 2529 | ||
2376 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2530 | Vector3 cameraAtOffset = part.GetCameraAtOffset(); |
2531 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2532 | bool forceMouselook = part.GetForceMouselook(); | ||
2533 | |||
2534 | ControllingClient.SendSitResponse( | ||
2535 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2536 | |||
2537 | // not using autopilot | ||
2538 | |||
2539 | Rotation = Orientation; | ||
2540 | m_pos = offset; | ||
2541 | |||
2542 | m_requestedSitTargetID = 0; | ||
2543 | part.ParentGroup.AddAvatar(UUID); | ||
2544 | |||
2545 | ParentPart = part; | ||
2546 | ParentID = part.LocalId; | ||
2547 | if(status == 3) | ||
2548 | Animator.TrySetMovementAnimation("SIT_GROUND"); | ||
2549 | else | ||
2550 | Animator.TrySetMovementAnimation("SIT"); | ||
2551 | SendAvatarDataToAllAgents(); | ||
2552 | |||
2553 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
2377 | } | 2554 | } |
2378 | */ | 2555 | |
2379 | 2556 | ||
2380 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2557 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2381 | { | 2558 | { |
@@ -2392,6 +2569,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2392 | return; | 2569 | return; |
2393 | } | 2570 | } |
2394 | 2571 | ||
2572 | |||
2395 | if (part.SitTargetAvatar == UUID) | 2573 | if (part.SitTargetAvatar == UUID) |
2396 | { | 2574 | { |
2397 | Vector3 sitTargetPos = part.SitTargetPosition; | 2575 | Vector3 sitTargetPos = part.SitTargetPosition; |
@@ -2406,14 +2584,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2406 | 2584 | ||
2407 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2585 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2408 | 2586 | ||
2409 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2587 | double x, y, z, m; |
2588 | |||
2589 | Quaternion r = sitTargetOrient; | ||
2590 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2591 | |||
2592 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2593 | { | ||
2594 | m = 1.0 / Math.Sqrt(m); | ||
2595 | r.X *= (float)m; | ||
2596 | r.Y *= (float)m; | ||
2597 | r.Z *= (float)m; | ||
2598 | r.W *= (float)m; | ||
2599 | } | ||
2600 | |||
2601 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2602 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2603 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2604 | |||
2605 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2606 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2607 | |||
2608 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2609 | |||
2610 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2410 | Rotation = sitTargetOrient; | 2611 | Rotation = sitTargetOrient; |
2411 | ParentPosition = part.AbsolutePosition; | 2612 | // ParentPosition = part.AbsolutePosition; |
2613 | part.ParentGroup.AddAvatar(UUID); | ||
2412 | } | 2614 | } |
2413 | else | 2615 | else |
2414 | { | 2616 | { |
2415 | m_pos -= part.AbsolutePosition; | 2617 | m_pos -= part.AbsolutePosition; |
2416 | ParentPosition = part.AbsolutePosition; | 2618 | // ParentPosition = part.AbsolutePosition; |
2619 | part.ParentGroup.AddAvatar(UUID); | ||
2417 | 2620 | ||
2418 | // m_log.DebugFormat( | 2621 | // m_log.DebugFormat( |
2419 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2622 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2468,6 +2671,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2468 | TriggerScenePresenceUpdated(); | 2671 | TriggerScenePresenceUpdated(); |
2469 | } | 2672 | } |
2470 | 2673 | ||
2674 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2675 | { | ||
2676 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2677 | } | ||
2678 | |||
2679 | |||
2680 | |||
2471 | /// <summary> | 2681 | /// <summary> |
2472 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2682 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2473 | /// </summary> | 2683 | /// </summary> |
@@ -2524,8 +2734,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2524 | direc.Z *= 2.6f; | 2734 | direc.Z *= 2.6f; |
2525 | 2735 | ||
2526 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2736 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2527 | Animator.TrySetMovementAnimation("PREJUMP"); | 2737 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2528 | Animator.TrySetMovementAnimation("JUMP"); | 2738 | // Animator.TrySetMovementAnimation("JUMP"); |
2529 | } | 2739 | } |
2530 | } | 2740 | } |
2531 | } | 2741 | } |
@@ -2534,6 +2744,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2534 | 2744 | ||
2535 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2745 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2536 | m_forceToApply = direc; | 2746 | m_forceToApply = direc; |
2747 | Animator.UpdateMovementAnimations(); | ||
2537 | } | 2748 | } |
2538 | 2749 | ||
2539 | #endregion | 2750 | #endregion |
@@ -2551,16 +2762,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2551 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 2762 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2552 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 2763 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2553 | // storing a requested force instead of an actual traveling velocity | 2764 | // storing a requested force instead of an actual traveling velocity |
2765 | if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) | ||
2766 | SendAvatarDataToAllAgents(); | ||
2554 | 2767 | ||
2555 | // Throw away duplicate or insignificant updates | 2768 | if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2556 | if ( | 2769 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2557 | // If the velocity has become zero, send it no matter what. | 2770 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2558 | (Velocity != m_lastVelocity && Velocity == Vector3.Zero) | ||
2559 | // otherwise, if things have changed reasonably, send the update | ||
2560 | || (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) | ||
2561 | || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) | ||
2562 | || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))) | ||
2563 | |||
2564 | { | 2771 | { |
2565 | SendTerseUpdateToAllClients(); | 2772 | SendTerseUpdateToAllClients(); |
2566 | 2773 | ||
@@ -2718,9 +2925,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2718 | // again here... this comes after the cached appearance check because the avatars | 2925 | // again here... this comes after the cached appearance check because the avatars |
2719 | // appearance goes into the avatar update packet | 2926 | // appearance goes into the avatar update packet |
2720 | SendAvatarDataToAllAgents(); | 2927 | SendAvatarDataToAllAgents(); |
2721 | 2928 | SendAppearanceToAgent(this); | |
2722 | // This invocation always shows up in the viewer logs as an error. | ||
2723 | // SendAppearanceToAgent(this); | ||
2724 | 2929 | ||
2725 | // If we are using the the cached appearance then send it out to everyone | 2930 | // If we are using the the cached appearance then send it out to everyone |
2726 | if (cachedappearance) | 2931 | if (cachedappearance) |
@@ -2751,6 +2956,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2751 | return; | 2956 | return; |
2752 | } | 2957 | } |
2753 | 2958 | ||
2959 | m_lastSize = Appearance.AvatarSize; | ||
2960 | |||
2754 | int count = 0; | 2961 | int count = 0; |
2755 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 2962 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
2756 | { | 2963 | { |
@@ -2858,6 +3065,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2858 | 3065 | ||
2859 | avatar.ControllingClient.SendAppearance( | 3066 | avatar.ControllingClient.SendAppearance( |
2860 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); | 3067 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
3068 | |||
3069 | |||
2861 | } | 3070 | } |
2862 | 3071 | ||
2863 | #endregion | 3072 | #endregion |
@@ -2932,8 +3141,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2932 | 3141 | ||
2933 | // If we don't have a PhysActor, we can't cross anyway | 3142 | // If we don't have a PhysActor, we can't cross anyway |
2934 | // Also don't do this while sat, sitting avatars cross with the | 3143 | // Also don't do this while sat, sitting avatars cross with the |
2935 | // object they sit on. | 3144 | // object they sit on. ParentUUID denoted a pending sit, don't |
2936 | if (ParentID != 0 || PhysicsActor == null) | 3145 | // interfere with it. |
3146 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2937 | return; | 3147 | return; |
2938 | 3148 | ||
2939 | if (!IsInTransit) | 3149 | if (!IsInTransit) |
@@ -3196,6 +3406,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3196 | } | 3406 | } |
3197 | 3407 | ||
3198 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3408 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3409 | private void RaiseUpdateThrottles() | ||
3410 | { | ||
3411 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3412 | } | ||
3199 | /// <summary> | 3413 | /// <summary> |
3200 | /// This updates important decision making data about a child agent | 3414 | /// This updates important decision making data about a child agent |
3201 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3415 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3276,6 +3490,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3276 | cAgent.AlwaysRun = SetAlwaysRun; | 3490 | cAgent.AlwaysRun = SetAlwaysRun; |
3277 | 3491 | ||
3278 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3492 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3493 | |||
3494 | cAgent.ParentPart = ParentUUID; | ||
3495 | cAgent.SitOffset = m_pos; | ||
3279 | 3496 | ||
3280 | lock (scriptedcontrols) | 3497 | lock (scriptedcontrols) |
3281 | { | 3498 | { |
@@ -3284,7 +3501,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3284 | 3501 | ||
3285 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3502 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3286 | { | 3503 | { |
3287 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3504 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3288 | } | 3505 | } |
3289 | cAgent.Controllers = controls; | 3506 | cAgent.Controllers = controls; |
3290 | } | 3507 | } |
@@ -3317,6 +3534,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3317 | CameraAtAxis = cAgent.AtAxis; | 3534 | CameraAtAxis = cAgent.AtAxis; |
3318 | CameraLeftAxis = cAgent.LeftAxis; | 3535 | CameraLeftAxis = cAgent.LeftAxis; |
3319 | CameraUpAxis = cAgent.UpAxis; | 3536 | CameraUpAxis = cAgent.UpAxis; |
3537 | ParentUUID = cAgent.ParentPart; | ||
3538 | m_prevSitOffset = cAgent.SitOffset; | ||
3320 | 3539 | ||
3321 | // When we get to the point of re-computing neighbors everytime this | 3540 | // When we get to the point of re-computing neighbors everytime this |
3322 | // changes, then start using the agent's drawdistance rather than the | 3541 | // changes, then start using the agent's drawdistance rather than the |
@@ -3354,6 +3573,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3354 | foreach (ControllerData c in cAgent.Controllers) | 3573 | foreach (ControllerData c in cAgent.Controllers) |
3355 | { | 3574 | { |
3356 | ScriptControllers sc = new ScriptControllers(); | 3575 | ScriptControllers sc = new ScriptControllers(); |
3576 | sc.objectID = c.ObjectID; | ||
3357 | sc.itemID = c.ItemID; | 3577 | sc.itemID = c.ItemID; |
3358 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3578 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3359 | sc.eventControls = (ScriptControlled)c.EventControls; | 3579 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3421,20 +3641,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3421 | } | 3641 | } |
3422 | 3642 | ||
3423 | if (Appearance.AvatarHeight == 0) | 3643 | if (Appearance.AvatarHeight == 0) |
3424 | Appearance.SetHeight(); | 3644 | // Appearance.SetHeight(); |
3645 | Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
3425 | 3646 | ||
3426 | PhysicsScene scene = m_scene.PhysicsScene; | 3647 | PhysicsScene scene = m_scene.PhysicsScene; |
3427 | 3648 | ||
3428 | Vector3 pVec = AbsolutePosition; | 3649 | Vector3 pVec = AbsolutePosition; |
3429 | 3650 | ||
3651 | /* | ||
3430 | PhysicsActor = scene.AddAvatar( | 3652 | PhysicsActor = scene.AddAvatar( |
3431 | LocalId, Firstname + "." + Lastname, pVec, | 3653 | LocalId, Firstname + "." + Lastname, pVec, |
3432 | new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); | 3654 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); |
3655 | */ | ||
3656 | |||
3657 | PhysicsActor = scene.AddAvatar( | ||
3658 | LocalId, Firstname + "." + Lastname, pVec, | ||
3659 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); | ||
3433 | 3660 | ||
3434 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3661 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3435 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3662 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3436 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3663 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3437 | PhysicsActor.SubscribeEvents(500); | 3664 | PhysicsActor.SubscribeEvents(100); |
3438 | PhysicsActor.LocalID = LocalId; | 3665 | PhysicsActor.LocalID = LocalId; |
3439 | } | 3666 | } |
3440 | 3667 | ||
@@ -3448,6 +3675,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3448 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); | 3675 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); |
3449 | } | 3676 | } |
3450 | 3677 | ||
3678 | |||
3451 | /// <summary> | 3679 | /// <summary> |
3452 | /// Event called by the physics plugin to tell the avatar about a collision. | 3680 | /// Event called by the physics plugin to tell the avatar about a collision. |
3453 | /// </summary> | 3681 | /// </summary> |
@@ -3461,7 +3689,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3461 | /// <param name="e"></param> | 3689 | /// <param name="e"></param> |
3462 | public void PhysicsCollisionUpdate(EventArgs e) | 3690 | public void PhysicsCollisionUpdate(EventArgs e) |
3463 | { | 3691 | { |
3464 | if (IsChildAgent) | 3692 | if (IsChildAgent || Animator == null) |
3465 | return; | 3693 | return; |
3466 | 3694 | ||
3467 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3695 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3478,7 +3706,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3478 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3706 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3479 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3707 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3480 | 3708 | ||
3481 | CollisionPlane = Vector4.UnitW; | ||
3482 | 3709 | ||
3483 | // // No collisions at all means we may be flying. Update always | 3710 | // // No collisions at all means we may be flying. Update always |
3484 | // // to make falling work | 3711 | // // to make falling work |
@@ -3490,6 +3717,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3490 | 3717 | ||
3491 | if (coldata.Count != 0) | 3718 | if (coldata.Count != 0) |
3492 | { | 3719 | { |
3720 | /* | ||
3493 | switch (Animator.CurrentMovementAnimation) | 3721 | switch (Animator.CurrentMovementAnimation) |
3494 | { | 3722 | { |
3495 | case "STAND": | 3723 | case "STAND": |
@@ -3498,24 +3726,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
3498 | case "CROUCH": | 3726 | case "CROUCH": |
3499 | case "CROUCHWALK": | 3727 | case "CROUCHWALK": |
3500 | { | 3728 | { |
3729 | */ | ||
3501 | ContactPoint lowest; | 3730 | ContactPoint lowest; |
3502 | lowest.SurfaceNormal = Vector3.Zero; | 3731 | lowest.SurfaceNormal = Vector3.Zero; |
3503 | lowest.Position = Vector3.Zero; | 3732 | lowest.Position = Vector3.Zero; |
3504 | lowest.Position.Z = Single.NaN; | 3733 | lowest.Position.Z = float.MaxValue; |
3505 | 3734 | ||
3506 | foreach (ContactPoint contact in coldata.Values) | 3735 | foreach (ContactPoint contact in coldata.Values) |
3507 | { | 3736 | { |
3508 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | 3737 | |
3738 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
3509 | { | 3739 | { |
3510 | lowest = contact; | 3740 | lowest = contact; |
3511 | } | 3741 | } |
3512 | } | 3742 | } |
3513 | 3743 | ||
3514 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | 3744 | if (lowest.Position.Z != float.MaxValue) |
3745 | { | ||
3746 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
3747 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3748 | } | ||
3749 | else | ||
3750 | CollisionPlane = Vector4.UnitW; | ||
3751 | /* | ||
3515 | } | 3752 | } |
3516 | break; | 3753 | break; |
3517 | } | 3754 | } |
3755 | */ | ||
3518 | } | 3756 | } |
3757 | else | ||
3758 | CollisionPlane = Vector4.UnitW; | ||
3759 | |||
3760 | RaiseCollisionScriptEvents(coldata); | ||
3519 | 3761 | ||
3520 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3762 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3521 | if (Invulnerable || GodLevel > 0) | 3763 | if (Invulnerable || GodLevel > 0) |
@@ -3614,6 +3856,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3614 | // m_reprioritizationTimer.Dispose(); | 3856 | // m_reprioritizationTimer.Dispose(); |
3615 | 3857 | ||
3616 | RemoveFromPhysicalScene(); | 3858 | RemoveFromPhysicalScene(); |
3859 | |||
3860 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3861 | |||
3862 | // if (Animator != null) | ||
3863 | // Animator.Close(); | ||
3864 | Animator = null; | ||
3865 | |||
3617 | } | 3866 | } |
3618 | 3867 | ||
3619 | public void AddAttachment(SceneObjectGroup gobj) | 3868 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3847,10 +4096,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3847 | 4096 | ||
3848 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 4097 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3849 | { | 4098 | { |
4099 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
4100 | if (p == null) | ||
4101 | return; | ||
4102 | |||
4103 | ControllingClient.SendTakeControls(controls, false, false); | ||
4104 | ControllingClient.SendTakeControls(controls, true, false); | ||
4105 | |||
3850 | ScriptControllers obj = new ScriptControllers(); | 4106 | ScriptControllers obj = new ScriptControllers(); |
3851 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 4107 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3852 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 4108 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3853 | 4109 | ||
4110 | obj.objectID = p.ParentGroup.UUID; | ||
3854 | obj.itemID = Script_item_UUID; | 4111 | obj.itemID = Script_item_UUID; |
3855 | if (pass_on == 0 && accept == 0) | 4112 | if (pass_on == 0 && accept == 0) |
3856 | { | 4113 | { |
@@ -3899,6 +4156,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3899 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 4156 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3900 | } | 4157 | } |
3901 | 4158 | ||
4159 | private void UnRegisterSeatControls(UUID obj) | ||
4160 | { | ||
4161 | List<UUID> takers = new List<UUID>(); | ||
4162 | |||
4163 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
4164 | { | ||
4165 | if (c.objectID == obj) | ||
4166 | takers.Add(c.itemID); | ||
4167 | } | ||
4168 | foreach (UUID t in takers) | ||
4169 | { | ||
4170 | UnRegisterControlEventsToScript(0, t); | ||
4171 | } | ||
4172 | } | ||
4173 | |||
3902 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 4174 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3903 | { | 4175 | { |
3904 | ScriptControllers takecontrols; | 4176 | ScriptControllers takecontrols; |
@@ -4228,6 +4500,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4228 | 4500 | ||
4229 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4501 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4230 | { | 4502 | { |
4503 | string reason; | ||
4504 | |||
4505 | // Honor bans | ||
4506 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4507 | return; | ||
4508 | |||
4231 | SceneObjectGroup telehub = null; | 4509 | SceneObjectGroup telehub = null; |
4232 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4510 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4233 | { | 4511 | { |
@@ -4267,11 +4545,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4267 | pos = land.LandData.UserLocation; | 4545 | pos = land.LandData.UserLocation; |
4268 | } | 4546 | } |
4269 | } | 4547 | } |
4270 | 4548 | ||
4271 | land.SendLandUpdateToClient(ControllingClient); | 4549 | land.SendLandUpdateToClient(ControllingClient); |
4272 | } | 4550 | } |
4273 | } | 4551 | } |
4274 | 4552 | ||
4553 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4554 | { | ||
4555 | DetectedObject detobj = new DetectedObject(); | ||
4556 | detobj.keyUUID = obj.UUID; | ||
4557 | detobj.nameStr = obj.Name; | ||
4558 | detobj.ownerUUID = obj.OwnerID; | ||
4559 | detobj.posVector = obj.AbsolutePosition; | ||
4560 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4561 | detobj.velVector = obj.Velocity; | ||
4562 | detobj.colliderType = 0; | ||
4563 | detobj.groupUUID = obj.GroupID; | ||
4564 | |||
4565 | return detobj; | ||
4566 | } | ||
4567 | |||
4568 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4569 | { | ||
4570 | DetectedObject detobj = new DetectedObject(); | ||
4571 | detobj.keyUUID = av.UUID; | ||
4572 | detobj.nameStr = av.ControllingClient.Name; | ||
4573 | detobj.ownerUUID = av.UUID; | ||
4574 | detobj.posVector = av.AbsolutePosition; | ||
4575 | detobj.rotQuat = av.Rotation; | ||
4576 | detobj.velVector = av.Velocity; | ||
4577 | detobj.colliderType = 0; | ||
4578 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4579 | |||
4580 | return detobj; | ||
4581 | } | ||
4582 | |||
4583 | private DetectedObject CreateDetObjectForGround() | ||
4584 | { | ||
4585 | DetectedObject detobj = new DetectedObject(); | ||
4586 | detobj.keyUUID = UUID.Zero; | ||
4587 | detobj.nameStr = ""; | ||
4588 | detobj.ownerUUID = UUID.Zero; | ||
4589 | detobj.posVector = AbsolutePosition; | ||
4590 | detobj.rotQuat = Quaternion.Identity; | ||
4591 | detobj.velVector = Vector3.Zero; | ||
4592 | detobj.colliderType = 0; | ||
4593 | detobj.groupUUID = UUID.Zero; | ||
4594 | |||
4595 | return detobj; | ||
4596 | } | ||
4597 | |||
4598 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4599 | { | ||
4600 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4601 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4602 | foreach (uint localId in colliders) | ||
4603 | { | ||
4604 | if (localId == 0) | ||
4605 | continue; | ||
4606 | |||
4607 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4608 | if (obj != null) | ||
4609 | { | ||
4610 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4611 | colliding.Add(CreateDetObject(obj)); | ||
4612 | } | ||
4613 | else | ||
4614 | { | ||
4615 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4616 | if (av != null && (!av.IsChildAgent)) | ||
4617 | { | ||
4618 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4619 | colliding.Add(CreateDetObject(av)); | ||
4620 | } | ||
4621 | } | ||
4622 | } | ||
4623 | |||
4624 | colliderArgs.Colliders = colliding; | ||
4625 | |||
4626 | return colliderArgs; | ||
4627 | } | ||
4628 | |||
4629 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4630 | |||
4631 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4632 | { | ||
4633 | ColliderArgs CollidingMessage; | ||
4634 | |||
4635 | if (colliders.Count > 0) | ||
4636 | { | ||
4637 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4638 | { | ||
4639 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4640 | |||
4641 | if (CollidingMessage.Colliders.Count > 0) | ||
4642 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4643 | } | ||
4644 | } | ||
4645 | } | ||
4646 | |||
4647 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4648 | { | ||
4649 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4650 | { | ||
4651 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4652 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4653 | |||
4654 | colliding.Add(CreateDetObjectForGround()); | ||
4655 | LandCollidingMessage.Colliders = colliding; | ||
4656 | |||
4657 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4658 | } | ||
4659 | } | ||
4660 | |||
4661 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4662 | { | ||
4663 | try | ||
4664 | { | ||
4665 | List<uint> thisHitColliders = new List<uint>(); | ||
4666 | List<uint> endedColliders = new List<uint>(); | ||
4667 | List<uint> startedColliders = new List<uint>(); | ||
4668 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4669 | CollisionForSoundInfo soundinfo; | ||
4670 | ContactPoint curcontact; | ||
4671 | |||
4672 | if (coldata.Count == 0) | ||
4673 | { | ||
4674 | if (m_lastColliders.Count == 0) | ||
4675 | return; // nothing to do | ||
4676 | |||
4677 | foreach (uint localID in m_lastColliders) | ||
4678 | { | ||
4679 | endedColliders.Add(localID); | ||
4680 | } | ||
4681 | m_lastColliders.Clear(); | ||
4682 | } | ||
4683 | |||
4684 | else | ||
4685 | { | ||
4686 | foreach (uint id in coldata.Keys) | ||
4687 | { | ||
4688 | thisHitColliders.Add(id); | ||
4689 | if (!m_lastColliders.Contains(id)) | ||
4690 | { | ||
4691 | startedColliders.Add(id); | ||
4692 | curcontact = coldata[id]; | ||
4693 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4694 | { | ||
4695 | soundinfo = new CollisionForSoundInfo(); | ||
4696 | soundinfo.colliderID = id; | ||
4697 | soundinfo.position = curcontact.Position; | ||
4698 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4699 | soundinfolist.Add(soundinfo); | ||
4700 | } | ||
4701 | } | ||
4702 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4703 | } | ||
4704 | |||
4705 | // calculate things that ended colliding | ||
4706 | foreach (uint localID in m_lastColliders) | ||
4707 | { | ||
4708 | if (!thisHitColliders.Contains(localID)) | ||
4709 | { | ||
4710 | endedColliders.Add(localID); | ||
4711 | } | ||
4712 | } | ||
4713 | //add the items that started colliding this time to the last colliders list. | ||
4714 | foreach (uint localID in startedColliders) | ||
4715 | { | ||
4716 | m_lastColliders.Add(localID); | ||
4717 | } | ||
4718 | // remove things that ended colliding from the last colliders list | ||
4719 | foreach (uint localID in endedColliders) | ||
4720 | { | ||
4721 | m_lastColliders.Remove(localID); | ||
4722 | } | ||
4723 | |||
4724 | if (soundinfolist.Count > 0) | ||
4725 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4726 | } | ||
4727 | |||
4728 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4729 | { | ||
4730 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4731 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4732 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4733 | |||
4734 | if (startedColliders.Contains(0)) | ||
4735 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4736 | if (m_lastColliders.Contains(0)) | ||
4737 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4738 | if (endedColliders.Contains(0)) | ||
4739 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4740 | } | ||
4741 | } | ||
4742 | finally | ||
4743 | { | ||
4744 | m_collisionEventFlag = false; | ||
4745 | } | ||
4746 | } | ||
4747 | |||
4275 | private void TeleportFlagsDebug() { | 4748 | private void TeleportFlagsDebug() { |
4276 | 4749 | ||
4277 | // Some temporary debugging help to show all the TeleportFlags we have... | 4750 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4296,6 +4769,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4296 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4769 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4297 | 4770 | ||
4298 | } | 4771 | } |
4299 | |||
4300 | } | 4772 | } |
4301 | } | 4773 | } |