diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1072 |
1 files changed, 759 insertions, 313 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a90872e..f024f52 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 |
@@ -221,8 +225,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
221 | /// </summary> | 225 | /// </summary> |
222 | public bool LandAtTarget { get; private set; } | 226 | public bool LandAtTarget { get; private set; } |
223 | 227 | ||
224 | private bool m_followCamAuto; | ||
225 | |||
226 | private int m_movementUpdateCount; | 228 | private int m_movementUpdateCount; |
227 | private const int NumMovementsBetweenRayCast = 5; | 229 | private const int NumMovementsBetweenRayCast = 5; |
228 | 230 | ||
@@ -230,6 +232,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
230 | //private int m_moveToPositionStateStatus; | 232 | //private int m_moveToPositionStateStatus; |
231 | //***************************************************** | 233 | //***************************************************** |
232 | 234 | ||
235 | private bool m_collisionEventFlag = false; | ||
236 | private object m_collisionEventLock = new Object(); | ||
237 | |||
238 | private int m_movementAnimationUpdateCounter = 0; | ||
239 | |||
240 | private Vector3 m_prevSitOffset; | ||
241 | |||
233 | protected AvatarAppearance m_appearance; | 242 | protected AvatarAppearance m_appearance; |
234 | 243 | ||
235 | public AvatarAppearance Appearance | 244 | public AvatarAppearance Appearance |
@@ -344,6 +353,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
344 | /// </summary> | 353 | /// </summary> |
345 | protected Vector3 m_lastCameraPosition; | 354 | protected Vector3 m_lastCameraPosition; |
346 | 355 | ||
356 | private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1); | ||
357 | private bool m_doingCamRayCast = false; | ||
358 | |||
347 | public Vector3 CameraPosition { get; set; } | 359 | public Vector3 CameraPosition { get; set; } |
348 | 360 | ||
349 | public Quaternion CameraRotation | 361 | public Quaternion CameraRotation |
@@ -424,7 +436,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
424 | get { return (IClientCore)ControllingClient; } | 436 | get { return (IClientCore)ControllingClient; } |
425 | } | 437 | } |
426 | 438 | ||
427 | public Vector3 ParentPosition { get; set; } | 439 | // public Vector3 ParentPosition { get; set; } |
428 | 440 | ||
429 | /// <summary> | 441 | /// <summary> |
430 | /// Position of this avatar relative to the region the avatar is in | 442 | /// Position of this avatar relative to the region the avatar is in |
@@ -482,7 +494,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
482 | if (ParentID == 0) | 494 | if (ParentID == 0) |
483 | { | 495 | { |
484 | m_pos = value; | 496 | m_pos = value; |
485 | ParentPosition = Vector3.Zero; | 497 | // ParentPosition = Vector3.Zero; |
486 | } | 498 | } |
487 | 499 | ||
488 | //m_log.DebugFormat( | 500 | //m_log.DebugFormat( |
@@ -551,7 +563,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
551 | // Scene.RegionInfo.RegionName, Name, m_velocity); | 563 | // Scene.RegionInfo.RegionName, Name, m_velocity); |
552 | } | 564 | } |
553 | } | 565 | } |
566 | /* | ||
567 | public override Vector3 AngularVelocity | ||
568 | { | ||
569 | get | ||
570 | { | ||
571 | if (PhysicsActor != null) | ||
572 | { | ||
573 | m_rotationalvelocity = PhysicsActor.RotationalVelocity; | ||
574 | |||
575 | // m_log.DebugFormat( | ||
576 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
577 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
578 | } | ||
554 | 579 | ||
580 | return m_rotationalvelocity; | ||
581 | } | ||
582 | } | ||
583 | */ | ||
555 | private Quaternion m_bodyRot = Quaternion.Identity; | 584 | private Quaternion m_bodyRot = Quaternion.Identity; |
556 | 585 | ||
557 | public Quaternion Rotation | 586 | public Quaternion Rotation |
@@ -562,19 +591,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
562 | m_bodyRot = value; | 591 | m_bodyRot = value; |
563 | if (PhysicsActor != null) | 592 | if (PhysicsActor != null) |
564 | { | 593 | { |
565 | PhysicsActor.Orientation = m_bodyRot; | 594 | try |
595 | { | ||
596 | PhysicsActor.Orientation = m_bodyRot; | ||
597 | } | ||
598 | catch (Exception e) | ||
599 | { | ||
600 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); | ||
601 | } | ||
566 | } | 602 | } |
567 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 603 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
568 | } | 604 | } |
569 | } | 605 | } |
570 | 606 | ||
571 | public bool IsChildAgent { get; set; } | 607 | public bool IsChildAgent { get; set; } |
608 | public bool IsLoggingIn { get; set; } | ||
572 | 609 | ||
573 | /// <summary> | 610 | /// <summary> |
574 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. | 611 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. |
575 | /// </summary> | 612 | /// </summary> |
576 | public uint ParentID { get; set; } | 613 | public uint ParentID { get; set; } |
577 | 614 | ||
615 | public UUID ParentUUID | ||
616 | { | ||
617 | get { return m_parentUUID; } | ||
618 | set { m_parentUUID = value; } | ||
619 | } | ||
620 | private UUID m_parentUUID = UUID.Zero; | ||
621 | |||
578 | /// <summary> | 622 | /// <summary> |
579 | /// Are we sitting on an object? | 623 | /// Are we sitting on an object? |
580 | /// </summary> | 624 | /// </summary> |
@@ -698,6 +742,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
698 | AttachmentsSyncLock = new Object(); | 742 | AttachmentsSyncLock = new Object(); |
699 | AllowMovement = true; | 743 | AllowMovement = true; |
700 | IsChildAgent = true; | 744 | IsChildAgent = true; |
745 | IsLoggingIn = false; | ||
701 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; | 746 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; |
702 | Animator = new ScenePresenceAnimator(this); | 747 | Animator = new ScenePresenceAnimator(this); |
703 | PresenceType = type; | 748 | PresenceType = type; |
@@ -741,6 +786,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
741 | Appearance = appearance; | 786 | Appearance = appearance; |
742 | } | 787 | } |
743 | 788 | ||
789 | private void RegionHeartbeatEnd(Scene scene) | ||
790 | { | ||
791 | if (IsChildAgent) | ||
792 | return; | ||
793 | |||
794 | m_movementAnimationUpdateCounter ++; | ||
795 | if (m_movementAnimationUpdateCounter >= 2) | ||
796 | { | ||
797 | m_movementAnimationUpdateCounter = 0; | ||
798 | if (Animator != null) | ||
799 | { | ||
800 | // If the parentID == 0 we are not sitting | ||
801 | // if !SitGournd then we are not sitting on the ground | ||
802 | // Fairly straightforward, now here comes the twist | ||
803 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
804 | // be sat on an object that isn't there yet. Should | ||
805 | // be treated as if sat. | ||
806 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
807 | Animator.UpdateMovementAnimations(); | ||
808 | } | ||
809 | else | ||
810 | { | ||
811 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
812 | } | ||
813 | } | ||
814 | } | ||
815 | |||
744 | public void RegisterToEvents() | 816 | public void RegisterToEvents() |
745 | { | 817 | { |
746 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 818 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -750,8 +822,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
750 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 822 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
751 | ControllingClient.OnStartAnim += HandleStartAnim; | 823 | ControllingClient.OnStartAnim += HandleStartAnim; |
752 | ControllingClient.OnStopAnim += HandleStopAnim; | 824 | ControllingClient.OnStopAnim += HandleStopAnim; |
825 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
753 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 826 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
754 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 827 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
828 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
755 | 829 | ||
756 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 830 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
757 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 831 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -810,10 +884,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
810 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 884 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
811 | Name, m_scene.RegionInfo.RegionName); | 885 | Name, m_scene.RegionInfo.RegionName); |
812 | 886 | ||
813 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
814 | |||
815 | bool wasChild = IsChildAgent; | 887 | bool wasChild = IsChildAgent; |
816 | IsChildAgent = false; | 888 | |
889 | if (ParentUUID != UUID.Zero) | ||
890 | { | ||
891 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
892 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
893 | if (part == null) | ||
894 | { | ||
895 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
896 | } | ||
897 | else | ||
898 | { | ||
899 | part.ParentGroup.AddAvatar(UUID); | ||
900 | if (part.SitTargetPosition != Vector3.Zero) | ||
901 | part.SitTargetAvatar = UUID; | ||
902 | // ParentPosition = part.GetWorldPosition(); | ||
903 | ParentID = part.LocalId; | ||
904 | ParentPart = part; | ||
905 | m_pos = m_prevSitOffset; | ||
906 | // pos = ParentPosition; | ||
907 | pos = part.GetWorldPosition(); | ||
908 | } | ||
909 | ParentUUID = UUID.Zero; | ||
910 | |||
911 | IsChildAgent = false; | ||
912 | |||
913 | // Animator.TrySetMovementAnimation("SIT"); | ||
914 | } | ||
915 | else | ||
916 | { | ||
917 | IsChildAgent = false; | ||
918 | IsLoggingIn = false; | ||
919 | } | ||
920 | |||
817 | 921 | ||
818 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 922 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
819 | if (gm != null) | 923 | if (gm != null) |
@@ -823,62 +927,99 @@ namespace OpenSim.Region.Framework.Scenes | |||
823 | 927 | ||
824 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 928 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
825 | 929 | ||
826 | // Moved this from SendInitialData to ensure that Appearance is initialized | 930 | UUID groupUUID = UUID.Zero; |
827 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 931 | string GroupName = string.Empty; |
828 | // related to the handling of attachments | 932 | ulong groupPowers = 0; |
829 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | 933 | |
830 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 934 | // ---------------------------------- |
935 | // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status | ||
936 | try | ||
831 | { | 937 | { |
832 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 938 | if (gm != null) |
833 | pos.X = crossedBorder.BorderLine.Z - 1; | 939 | { |
940 | groupUUID = ControllingClient.ActiveGroupId; | ||
941 | GroupRecord record = gm.GetGroupRecord(groupUUID); | ||
942 | if (record != null) | ||
943 | GroupName = record.GroupName; | ||
944 | GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); | ||
945 | if (groupMembershipData != null) | ||
946 | groupPowers = groupMembershipData.GroupPowers; | ||
947 | } | ||
948 | ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, | ||
949 | Grouptitle); | ||
834 | } | 950 | } |
835 | 951 | catch (Exception e) | |
836 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | ||
837 | { | 952 | { |
838 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 953 | m_log.Debug("[AGENTUPDATE]: " + e.ToString()); |
839 | pos.Y = crossedBorder.BorderLine.Z - 1; | ||
840 | } | 954 | } |
955 | // ------------------------------------ | ||
841 | 956 | ||
842 | CheckAndAdjustLandingPoint(ref pos); | 957 | if (ParentID == 0) |
843 | |||
844 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | ||
845 | { | 958 | { |
846 | m_log.WarnFormat( | 959 | // Moved this from SendInitialData to ensure that Appearance is initialized |
847 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 960 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
848 | pos, Name, UUID); | 961 | // related to the handling of attachments |
962 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
963 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
964 | { | ||
965 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
966 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
967 | } | ||
849 | 968 | ||
850 | if (pos.X < 0f) pos.X = 0f; | 969 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
851 | if (pos.Y < 0f) pos.Y = 0f; | 970 | { |
852 | if (pos.Z < 0f) pos.Z = 0f; | 971 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
853 | } | 972 | pos.Y = crossedBorder.BorderLine.Z - 1; |
973 | } | ||
854 | 974 | ||
855 | float localAVHeight = 1.56f; | 975 | CheckAndAdjustLandingPoint(ref pos); |
856 | if (Appearance.AvatarHeight > 0) | ||
857 | localAVHeight = Appearance.AvatarHeight; | ||
858 | 976 | ||
859 | float posZLimit = 0; | 977 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
978 | { | ||
979 | m_log.WarnFormat( | ||
980 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | ||
981 | pos, Name, UUID); | ||
860 | 982 | ||
861 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 983 | if (pos.X < 0f) pos.X = 0f; |
862 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 984 | if (pos.Y < 0f) pos.Y = 0f; |
863 | 985 | if (pos.Z < 0f) pos.Z = 0f; | |
864 | float newPosZ = posZLimit + localAVHeight / 2; | 986 | } |
865 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
866 | { | ||
867 | pos.Z = newPosZ; | ||
868 | } | ||
869 | AbsolutePosition = pos; | ||
870 | 987 | ||
871 | AddToPhysicalScene(isFlying); | 988 | float localAVHeight = 1.56f; |
989 | if (Appearance.AvatarHeight > 0) | ||
990 | localAVHeight = Appearance.AvatarHeight; | ||
872 | 991 | ||
873 | if (ForceFly) | 992 | float posZLimit = 0; |
874 | { | ||
875 | Flying = true; | ||
876 | } | ||
877 | else if (FlyDisabled) | ||
878 | { | ||
879 | Flying = false; | ||
880 | } | ||
881 | 993 | ||
994 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | ||
995 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | ||
996 | |||
997 | float newPosZ = posZLimit + localAVHeight / 2; | ||
998 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
999 | { | ||
1000 | pos.Z = newPosZ; | ||
1001 | } | ||
1002 | AbsolutePosition = pos; | ||
1003 | |||
1004 | if (m_teleportFlags == TeleportFlags.Default) | ||
1005 | { | ||
1006 | Vector3 vel = Velocity; | ||
1007 | AddToPhysicalScene(isFlying); | ||
1008 | if (PhysicsActor != null) | ||
1009 | PhysicsActor.SetMomentum(vel); | ||
1010 | } | ||
1011 | else | ||
1012 | AddToPhysicalScene(isFlying); | ||
1013 | |||
1014 | if (ForceFly) | ||
1015 | { | ||
1016 | Flying = true; | ||
1017 | } | ||
1018 | else if (FlyDisabled) | ||
1019 | { | ||
1020 | Flying = false; | ||
1021 | } | ||
1022 | } | ||
882 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1023 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
883 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 1024 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
884 | // elsewhere anyway | 1025 | // elsewhere anyway |
@@ -898,14 +1039,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
898 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | 1039 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
899 | 1040 | ||
900 | // Resume scripts | 1041 | // Resume scripts |
901 | foreach (SceneObjectGroup sog in m_attachments) | 1042 | Util.FireAndForget(delegate(object x) { |
902 | { | 1043 | foreach (SceneObjectGroup sog in m_attachments) |
903 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 1044 | { |
904 | sog.ResumeScripts(); | 1045 | sog.ScheduleGroupForFullUpdate(); |
905 | } | 1046 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
1047 | sog.ResumeScripts(); | ||
1048 | } | ||
1049 | }); | ||
906 | } | 1050 | } |
907 | } | 1051 | } |
908 | 1052 | ||
1053 | SendAvatarDataToAllAgents(); | ||
1054 | |||
909 | // send the animations of the other presences to me | 1055 | // send the animations of the other presences to me |
910 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 1056 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
911 | { | 1057 | { |
@@ -916,9 +1062,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
916 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1062 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
917 | // stall on the border crossing since the existing child agent will still have the last movement | 1063 | // stall on the border crossing since the existing child agent will still have the last movement |
918 | // recorded, which stops the input from being processed. | 1064 | // recorded, which stops the input from being processed. |
1065 | |||
919 | MovementFlag = 0; | 1066 | MovementFlag = 0; |
920 | 1067 | ||
921 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1068 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1069 | |||
1070 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
922 | } | 1071 | } |
923 | 1072 | ||
924 | public int GetStateSource() | 1073 | public int GetStateSource() |
@@ -946,12 +1095,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
946 | /// </remarks> | 1095 | /// </remarks> |
947 | public void MakeChildAgent() | 1096 | public void MakeChildAgent() |
948 | { | 1097 | { |
1098 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1099 | |||
949 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1100 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
950 | 1101 | ||
951 | // Reset these so that teleporting in and walking out isn't seen | 1102 | // Reset these so that teleporting in and walking out isn't seen |
952 | // as teleporting back | 1103 | // as teleporting back |
953 | TeleportFlags = TeleportFlags.Default; | 1104 | TeleportFlags = TeleportFlags.Default; |
954 | 1105 | ||
1106 | MovementFlag = 0; | ||
1107 | |||
955 | // It looks like Animator is set to null somewhere, and MakeChild | 1108 | // It looks like Animator is set to null somewhere, and MakeChild |
956 | // is called after that. Probably in aborted teleports. | 1109 | // is called after that. Probably in aborted teleports. |
957 | if (Animator == null) | 1110 | if (Animator == null) |
@@ -959,6 +1112,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
959 | else | 1112 | else |
960 | Animator.ResetAnimations(); | 1113 | Animator.ResetAnimations(); |
961 | 1114 | ||
1115 | |||
962 | // m_log.DebugFormat( | 1116 | // m_log.DebugFormat( |
963 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1117 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
964 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1118 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -970,6 +1124,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
970 | IsChildAgent = true; | 1124 | IsChildAgent = true; |
971 | m_scene.SwapRootAgentCount(true); | 1125 | m_scene.SwapRootAgentCount(true); |
972 | RemoveFromPhysicalScene(); | 1126 | RemoveFromPhysicalScene(); |
1127 | ParentID = 0; // Child agents can't be sitting | ||
973 | 1128 | ||
974 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1129 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
975 | 1130 | ||
@@ -985,9 +1140,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
985 | { | 1140 | { |
986 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1141 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
987 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1142 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
988 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
989 | PhysicsActor.UnSubscribeEvents(); | ||
990 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1143 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1144 | PhysicsActor.UnSubscribeEvents(); | ||
1145 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
991 | PhysicsActor = null; | 1146 | PhysicsActor = null; |
992 | } | 1147 | } |
993 | // else | 1148 | // else |
@@ -1004,7 +1159,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1004 | /// <param name="pos"></param> | 1159 | /// <param name="pos"></param> |
1005 | public void Teleport(Vector3 pos) | 1160 | public void Teleport(Vector3 pos) |
1006 | { | 1161 | { |
1007 | TeleportWithMomentum(pos, null); | 1162 | TeleportWithMomentum(pos, Vector3.Zero); |
1008 | } | 1163 | } |
1009 | 1164 | ||
1010 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1165 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1028,6 +1183,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1028 | SendTerseUpdateToAllClients(); | 1183 | SendTerseUpdateToAllClients(); |
1029 | } | 1184 | } |
1030 | 1185 | ||
1186 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1187 | { | ||
1188 | CheckLandingPoint(ref newpos); | ||
1189 | AbsolutePosition = newpos; | ||
1190 | |||
1191 | if (newvel.HasValue) | ||
1192 | { | ||
1193 | if ((Vector3)newvel == Vector3.Zero) | ||
1194 | { | ||
1195 | if (PhysicsActor != null) | ||
1196 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1197 | m_velocity = Vector3.Zero; | ||
1198 | } | ||
1199 | else | ||
1200 | { | ||
1201 | if (PhysicsActor != null) | ||
1202 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1203 | m_velocity = (Vector3)newvel; | ||
1204 | |||
1205 | if (rotateToVelXY) | ||
1206 | { | ||
1207 | Vector3 lookAt = (Vector3)newvel; | ||
1208 | lookAt.Z = 0; | ||
1209 | lookAt.Normalize(); | ||
1210 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1211 | return; | ||
1212 | } | ||
1213 | } | ||
1214 | } | ||
1215 | |||
1216 | SendTerseUpdateToAllClients(); | ||
1217 | } | ||
1218 | |||
1219 | |||
1220 | |||
1031 | public void StopFlying() | 1221 | public void StopFlying() |
1032 | { | 1222 | { |
1033 | ControllingClient.StopFlying(this); | 1223 | ControllingClient.StopFlying(this); |
@@ -1118,6 +1308,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1118 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); | 1308 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); |
1119 | } | 1309 | } |
1120 | 1310 | ||
1311 | public void SetSize(Vector3 size, float feetoffset) | ||
1312 | { | ||
1313 | if (PhysicsActor != null && !IsChildAgent) | ||
1314 | PhysicsActor.setAvatarSize(size, feetoffset); | ||
1315 | |||
1316 | } | ||
1317 | |||
1121 | /// <summary> | 1318 | /// <summary> |
1122 | /// Complete Avatar's movement into the region. | 1319 | /// Complete Avatar's movement into the region. |
1123 | /// </summary> | 1320 | /// </summary> |
@@ -1137,7 +1334,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1137 | 1334 | ||
1138 | Vector3 look = Velocity; | 1335 | Vector3 look = Velocity; |
1139 | 1336 | ||
1140 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1337 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1338 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1141 | { | 1339 | { |
1142 | look = new Vector3(0.99f, 0.042f, 0); | 1340 | look = new Vector3(0.99f, 0.042f, 0); |
1143 | } | 1341 | } |
@@ -1187,13 +1385,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1187 | // Create child agents in neighbouring regions | 1385 | // Create child agents in neighbouring regions |
1188 | if (openChildAgents && !IsChildAgent) | 1386 | if (openChildAgents && !IsChildAgent) |
1189 | { | 1387 | { |
1388 | |||
1190 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1389 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1191 | if (m_agentTransfer != null) | 1390 | if (m_agentTransfer != null) |
1192 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1391 | m_agentTransfer.EnableChildAgents(this); |
1193 | 1392 | ||
1194 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1393 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1195 | if (friendsModule != null) | 1394 | if (friendsModule != null) |
1196 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1395 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1396 | |||
1197 | } | 1397 | } |
1198 | 1398 | ||
1199 | // m_log.DebugFormat( | 1399 | // m_log.DebugFormat( |
@@ -1209,35 +1409,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1209 | /// <param name="collisionPoint"></param> | 1409 | /// <param name="collisionPoint"></param> |
1210 | /// <param name="localid"></param> | 1410 | /// <param name="localid"></param> |
1211 | /// <param name="distance"></param> | 1411 | /// <param name="distance"></param> |
1412 | /// | ||
1413 | |||
1414 | private void UpdateCameraCollisionPlane(Vector4 plane) | ||
1415 | { | ||
1416 | if (m_lastCameraCollisionPlane != plane) | ||
1417 | { | ||
1418 | m_lastCameraCollisionPlane = plane; | ||
1419 | ControllingClient.SendCameraConstraint(plane); | ||
1420 | } | ||
1421 | } | ||
1422 | |||
1212 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) | 1423 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) |
1213 | { | 1424 | { |
1214 | const float POSITION_TOLERANCE = 0.02f; | 1425 | const float POSITION_TOLERANCE = 0.02f; |
1215 | const float VELOCITY_TOLERANCE = 0.02f; | ||
1216 | const float ROTATION_TOLERANCE = 0.02f; | 1426 | const float ROTATION_TOLERANCE = 0.02f; |
1217 | 1427 | ||
1218 | if (m_followCamAuto) | 1428 | m_doingCamRayCast = false; |
1429 | if (hitYN && localid != LocalId) | ||
1219 | { | 1430 | { |
1220 | if (hitYN) | 1431 | CameraConstraintActive = true; |
1221 | { | 1432 | pNormal.X = (float)Math.Round(pNormal.X, 2); |
1222 | CameraConstraintActive = true; | 1433 | pNormal.Y = (float)Math.Round(pNormal.Y, 2); |
1223 | //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); | 1434 | pNormal.Z = (float)Math.Round(pNormal.Z, 2); |
1224 | 1435 | pNormal.Normalize(); | |
1225 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1436 | collisionPoint.X = (float)Math.Round(collisionPoint.X, 1); |
1226 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1437 | collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1); |
1227 | } | 1438 | collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1); |
1228 | else | 1439 | |
1229 | { | 1440 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal)); |
1230 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 1441 | UpdateCameraCollisionPlane(plane); |
1231 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 1442 | } |
1232 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | 1443 | else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
1233 | { | 1444 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) |
1234 | if (CameraConstraintActive) | 1445 | { |
1235 | { | 1446 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... |
1236 | ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); | 1447 | UpdateCameraCollisionPlane(plane); |
1237 | CameraConstraintActive = false; | 1448 | CameraConstraintActive = false; |
1238 | } | ||
1239 | } | ||
1240 | } | ||
1241 | } | 1449 | } |
1242 | } | 1450 | } |
1243 | 1451 | ||
@@ -1312,12 +1520,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1312 | // DrawDistance = agentData.Far; | 1520 | // DrawDistance = agentData.Far; |
1313 | DrawDistance = Scene.DefaultDrawDistance; | 1521 | DrawDistance = Scene.DefaultDrawDistance; |
1314 | 1522 | ||
1315 | // Check if Client has camera in 'follow cam' or 'build' mode. | ||
1316 | Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); | ||
1317 | |||
1318 | m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) | ||
1319 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | ||
1320 | |||
1321 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | 1523 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; |
1322 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | 1524 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; |
1323 | 1525 | ||
@@ -1337,14 +1539,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
1337 | StandUp(); | 1539 | StandUp(); |
1338 | } | 1540 | } |
1339 | 1541 | ||
1340 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | ||
1341 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 1542 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
1342 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 1543 | // this exclude checks may not be complete |
1544 | |||
1545 | if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) | ||
1343 | { | 1546 | { |
1344 | if (m_followCamAuto) | 1547 | if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) |
1548 | { | ||
1549 | Vector3 posAdjusted = AbsolutePosition; | ||
1550 | // posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; | ||
1551 | posAdjusted.Z += 1.0f; // viewer current camera focus point | ||
1552 | Vector3 tocam = CameraPosition - posAdjusted; | ||
1553 | tocam.X = (float)Math.Round(tocam.X, 1); | ||
1554 | tocam.Y = (float)Math.Round(tocam.Y, 1); | ||
1555 | tocam.Z = (float)Math.Round(tocam.Z, 1); | ||
1556 | |||
1557 | float distTocamlen = tocam.Length(); | ||
1558 | if (distTocamlen > 0.3f) | ||
1559 | { | ||
1560 | tocam *= (1.0f / distTocamlen); | ||
1561 | posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); | ||
1562 | posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); | ||
1563 | posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); | ||
1564 | |||
1565 | m_doingCamRayCast = true; | ||
1566 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); | ||
1567 | } | ||
1568 | } | ||
1569 | else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) | ||
1345 | { | 1570 | { |
1346 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1571 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... |
1347 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1572 | UpdateCameraCollisionPlane(plane); |
1573 | CameraConstraintActive = false; | ||
1348 | } | 1574 | } |
1349 | } | 1575 | } |
1350 | 1576 | ||
@@ -1782,7 +2008,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1782 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); | 2008 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); |
1783 | 2009 | ||
1784 | MovingToTarget = false; | 2010 | MovingToTarget = false; |
1785 | MoveToPositionTarget = Vector3.Zero; | 2011 | // MoveToPositionTarget = Vector3.Zero; |
2012 | m_forceToApply = null; // cancel possible last action | ||
1786 | 2013 | ||
1787 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct | 2014 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct |
1788 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. | 2015 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. |
@@ -1800,12 +2027,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1800 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 2027 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1801 | 2028 | ||
1802 | SitGround = false; | 2029 | SitGround = false; |
2030 | |||
2031 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1803 | if (PhysicsActor == null) | 2032 | if (PhysicsActor == null) |
1804 | AddToPhysicalScene(false); | 2033 | AddToPhysicalScene(false); |
2034 | */ | ||
1805 | 2035 | ||
1806 | if (ParentID != 0) | 2036 | if (ParentID != 0) |
1807 | { | 2037 | { |
1808 | SceneObjectPart part = ParentPart; | 2038 | SceneObjectPart part = ParentPart; |
2039 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
2040 | |||
1809 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 2041 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1810 | if (taskIDict != null) | 2042 | if (taskIDict != null) |
1811 | { | 2043 | { |
@@ -1821,14 +2053,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1821 | } | 2053 | } |
1822 | } | 2054 | } |
1823 | 2055 | ||
1824 | ParentPosition = part.GetWorldPosition(); | 2056 | part.ParentGroup.DeleteAvatar(UUID); |
2057 | // ParentPosition = part.GetWorldPosition(); | ||
1825 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 2058 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1826 | 2059 | ||
1827 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 2060 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
1828 | ParentPosition = Vector3.Zero; | 2061 | // ParentPosition = Vector3.Zero; |
2062 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
2063 | if (part.SitTargetAvatar == UUID) | ||
2064 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
1829 | 2065 | ||
1830 | ParentID = 0; | 2066 | ParentID = 0; |
1831 | ParentPart = null; | 2067 | ParentPart = null; |
2068 | |||
2069 | if (PhysicsActor == null) | ||
2070 | AddToPhysicalScene(false); | ||
2071 | |||
1832 | SendAvatarDataToAllAgents(); | 2072 | SendAvatarDataToAllAgents(); |
1833 | m_requestedSitTargetID = 0; | 2073 | m_requestedSitTargetID = 0; |
1834 | 2074 | ||
@@ -1838,6 +2078,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1838 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2078 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1839 | } | 2079 | } |
1840 | 2080 | ||
2081 | else if (PhysicsActor == null) | ||
2082 | AddToPhysicalScene(false); | ||
2083 | |||
1841 | Animator.TrySetMovementAnimation("STAND"); | 2084 | Animator.TrySetMovementAnimation("STAND"); |
1842 | } | 2085 | } |
1843 | 2086 | ||
@@ -1885,11 +2128,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1885 | if (part == null) | 2128 | if (part == null) |
1886 | return; | 2129 | return; |
1887 | 2130 | ||
1888 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
1889 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
1890 | |||
1891 | if (PhysicsActor != null) | 2131 | if (PhysicsActor != null) |
1892 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2132 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
1893 | 2133 | ||
1894 | bool canSit = false; | 2134 | bool canSit = false; |
1895 | Vector3 pos = part.AbsolutePosition + offset; | 2135 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -1906,31 +2146,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
1906 | } | 2146 | } |
1907 | else | 2147 | else |
1908 | { | 2148 | { |
2149 | if (PhysicsSit(part,offset)) // physics engine | ||
2150 | return; | ||
2151 | |||
1909 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2152 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
1910 | { | 2153 | { |
1911 | // m_log.DebugFormat( | ||
1912 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | ||
1913 | // Name, part.Name, part.LocalId); | ||
1914 | 2154 | ||
1915 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2155 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
1916 | canSit = true; | 2156 | canSit = true; |
1917 | } | 2157 | } |
1918 | // else | ||
1919 | // { | ||
1920 | // m_log.DebugFormat( | ||
1921 | // "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", | ||
1922 | // Name, part.Name, part.LocalId); | ||
1923 | // } | ||
1924 | } | 2158 | } |
1925 | 2159 | ||
1926 | if (canSit) | 2160 | if (canSit) |
1927 | { | 2161 | { |
2162 | |||
1928 | if (PhysicsActor != null) | 2163 | if (PhysicsActor != null) |
1929 | { | 2164 | { |
1930 | // We can remove the physicsActor until they stand up. | 2165 | // We can remove the physicsActor until they stand up. |
1931 | RemoveFromPhysicalScene(); | 2166 | RemoveFromPhysicalScene(); |
1932 | } | 2167 | } |
1933 | 2168 | ||
2169 | if (MovingToTarget) | ||
2170 | ResetMoveToTarget(); | ||
2171 | |||
2172 | Velocity = Vector3.Zero; | ||
2173 | |||
1934 | part.AddSittingAvatar(UUID); | 2174 | part.AddSittingAvatar(UUID); |
1935 | 2175 | ||
1936 | cameraAtOffset = part.GetCameraAtOffset(); | 2176 | cameraAtOffset = part.GetCameraAtOffset(); |
@@ -1938,7 +2178,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1938 | forceMouselook = part.GetForceMouselook(); | 2178 | forceMouselook = part.GetForceMouselook(); |
1939 | 2179 | ||
1940 | ControllingClient.SendSitResponse( | 2180 | ControllingClient.SendSitResponse( |
1941 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2181 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1942 | 2182 | ||
1943 | m_requestedSitTargetUUID = targetID; | 2183 | m_requestedSitTargetUUID = targetID; |
1944 | 2184 | ||
@@ -1952,6 +2192,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1952 | 2192 | ||
1953 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2193 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
1954 | { | 2194 | { |
2195 | if (IsChildAgent) | ||
2196 | return; | ||
2197 | |||
1955 | if (ParentID != 0) | 2198 | if (ParentID != 0) |
1956 | { | 2199 | { |
1957 | if (ParentPart.UUID == targetID) | 2200 | if (ParentPart.UUID == targetID) |
@@ -1967,14 +2210,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1967 | m_requestedSitTargetID = part.LocalId; | 2210 | m_requestedSitTargetID = part.LocalId; |
1968 | m_requestedSitTargetUUID = targetID; | 2211 | m_requestedSitTargetUUID = targetID; |
1969 | 2212 | ||
1970 | // m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | ||
1971 | |||
1972 | if (m_scene.PhysicsScene.SupportsRayCast()) | ||
1973 | { | ||
1974 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); | ||
1975 | //SitRayCastAvatarPosition(part); | ||
1976 | //return; | ||
1977 | } | ||
1978 | } | 2213 | } |
1979 | else | 2214 | else |
1980 | { | 2215 | { |
@@ -1984,197 +2219,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
1984 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2219 | SendSitResponse(targetID, offset, Quaternion.Identity); |
1985 | } | 2220 | } |
1986 | 2221 | ||
1987 | /* | 2222 | // returns false if does not suport so older sit can be tried |
1988 | public void SitRayCastAvatarPosition(SceneObjectPart part) | 2223 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
1989 | { | 2224 | { |
1990 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2225 | if (part == null || part.ParentGroup.IsAttachment) |
1991 | Vector3 StartRayCastPosition = AbsolutePosition; | ||
1992 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
1993 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
1994 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | ||
1995 | } | ||
1996 | |||
1997 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | ||
1998 | { | ||
1999 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2000 | if (part != null) | ||
2001 | { | ||
2002 | if (hitYN) | ||
2003 | { | ||
2004 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2005 | { | ||
2006 | SitRaycastFindEdge(collisionPoint, normal); | ||
2007 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2008 | } | ||
2009 | else | ||
2010 | { | ||
2011 | SitRayCastAvatarPositionCameraZ(part); | ||
2012 | } | ||
2013 | } | ||
2014 | else | ||
2015 | { | ||
2016 | SitRayCastAvatarPositionCameraZ(part); | ||
2017 | } | ||
2018 | } | ||
2019 | else | ||
2020 | { | 2226 | { |
2021 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2227 | return true; |
2022 | m_requestedSitTargetUUID = UUID.Zero; | ||
2023 | m_requestedSitTargetID = 0; | ||
2024 | m_requestedSitOffset = Vector3.Zero; | ||
2025 | } | 2228 | } |
2026 | 2229 | ||
2027 | } | 2230 | if ( m_scene.PhysicsScene == null) |
2028 | 2231 | return false; | |
2029 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | ||
2030 | { | ||
2031 | // Next, try to raycast from the camera Z position | ||
2032 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2033 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | ||
2034 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2035 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2036 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | ||
2037 | } | ||
2038 | 2232 | ||
2039 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2233 | if (part.PhysActor == null) |
2040 | { | ||
2041 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2042 | if (part != null) | ||
2043 | { | 2234 | { |
2044 | if (hitYN) | 2235 | // none physcis shape |
2045 | { | 2236 | if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) |
2046 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2237 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2047 | { | ||
2048 | SitRaycastFindEdge(collisionPoint, normal); | ||
2049 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2050 | } | ||
2051 | else | ||
2052 | { | ||
2053 | SitRayCastCameraPosition(part); | ||
2054 | } | ||
2055 | } | ||
2056 | else | 2238 | else |
2057 | { | 2239 | { // non physical phantom TODO |
2058 | SitRayCastCameraPosition(part); | 2240 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2241 | return false; | ||
2059 | } | 2242 | } |
2060 | } | 2243 | return true; |
2061 | else | ||
2062 | { | ||
2063 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2064 | m_requestedSitTargetUUID = UUID.Zero; | ||
2065 | m_requestedSitTargetID = 0; | ||
2066 | m_requestedSitOffset = Vector3.Zero; | ||
2067 | } | 2244 | } |
2068 | 2245 | ||
2069 | } | ||
2070 | 2246 | ||
2071 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2247 | // not doing autopilot |
2072 | { | 2248 | m_requestedSitTargetID = 0; |
2073 | // Next, try to raycast from the camera position | ||
2074 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2075 | Vector3 StartRayCastPosition = CameraPosition; | ||
2076 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2077 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2078 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | ||
2079 | } | ||
2080 | 2249 | ||
2081 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2250 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) |
2082 | { | 2251 | return true; |
2083 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2084 | if (part != null) | ||
2085 | { | ||
2086 | if (hitYN) | ||
2087 | { | ||
2088 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2089 | { | ||
2090 | SitRaycastFindEdge(collisionPoint, normal); | ||
2091 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2092 | } | ||
2093 | else | ||
2094 | { | ||
2095 | SitRayHorizontal(part); | ||
2096 | } | ||
2097 | } | ||
2098 | else | ||
2099 | { | ||
2100 | SitRayHorizontal(part); | ||
2101 | } | ||
2102 | } | ||
2103 | else | ||
2104 | { | ||
2105 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2106 | m_requestedSitTargetUUID = UUID.Zero; | ||
2107 | m_requestedSitTargetID = 0; | ||
2108 | m_requestedSitOffset = Vector3.Zero; | ||
2109 | } | ||
2110 | 2252 | ||
2253 | return false; | ||
2111 | } | 2254 | } |
2112 | 2255 | ||
2113 | public void SitRayHorizontal(SceneObjectPart part) | 2256 | |
2257 | private bool CanEnterLandPosition(Vector3 testPos) | ||
2114 | { | 2258 | { |
2115 | // Next, try to raycast from the avatar position to fwd | 2259 | ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); |
2116 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2260 | |
2117 | Vector3 StartRayCastPosition = CameraPosition; | 2261 | if (land == null || land.LandData.Name == "NO_LAND") |
2118 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2262 | return true; |
2119 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2263 | |
2120 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | 2264 | return land.CanBeOnThisLand(UUID,testPos.Z); |
2121 | } | 2265 | } |
2122 | 2266 | ||
2123 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2267 | // status |
2268 | // < 0 ignore | ||
2269 | // 0 bad sit spot | ||
2270 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) | ||
2124 | { | 2271 | { |
2125 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2272 | if (status < 0) |
2126 | if (part != null) | 2273 | return; |
2274 | |||
2275 | if (status == 0) | ||
2127 | { | 2276 | { |
2128 | if (hitYN) | 2277 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2129 | { | 2278 | return; |
2130 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2131 | { | ||
2132 | SitRaycastFindEdge(collisionPoint, normal); | ||
2133 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2134 | // Next, try to raycast from the camera position | ||
2135 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2136 | Vector3 StartRayCastPosition = CameraPosition; | ||
2137 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2138 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2139 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | ||
2140 | } | ||
2141 | else | ||
2142 | { | ||
2143 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2144 | m_requestedSitTargetUUID = UUID.Zero; | ||
2145 | m_requestedSitTargetID = 0; | ||
2146 | m_requestedSitOffset = Vector3.Zero; | ||
2147 | } | ||
2148 | } | ||
2149 | else | ||
2150 | { | ||
2151 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2152 | m_requestedSitTargetUUID = UUID.Zero; | ||
2153 | m_requestedSitTargetID = 0; | ||
2154 | m_requestedSitOffset = Vector3.Zero; | ||
2155 | } | ||
2156 | } | 2279 | } |
2157 | else | 2280 | |
2281 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); | ||
2282 | if (part == null) | ||
2283 | return; | ||
2284 | |||
2285 | Vector3 targetPos = part.GetWorldPosition() + offset * part.GetWorldRotation(); | ||
2286 | if(!CanEnterLandPosition(targetPos)) | ||
2158 | { | 2287 | { |
2159 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2288 | ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); |
2160 | m_requestedSitTargetUUID = UUID.Zero; | 2289 | return; |
2161 | m_requestedSitTargetID = 0; | ||
2162 | m_requestedSitOffset = Vector3.Zero; | ||
2163 | } | 2290 | } |
2164 | 2291 | ||
2165 | } | 2292 | RemoveFromPhysicalScene(); |
2166 | 2293 | ||
2167 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2294 | if (MovingToTarget) |
2168 | { | 2295 | ResetMoveToTarget(); |
2169 | int i = 0; | 2296 | |
2170 | //throw new NotImplementedException(); | 2297 | Velocity = Vector3.Zero; |
2171 | //m_requestedSitTargetUUID = UUID.Zero; | 2298 | |
2172 | //m_requestedSitTargetID = 0; | 2299 | part.AddSittingAvatar(UUID); |
2173 | //m_requestedSitOffset = Vector3.Zero; | ||
2174 | 2300 | ||
2175 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2301 | Vector3 cameraAtOffset = part.GetCameraAtOffset(); |
2302 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2303 | bool forceMouselook = part.GetForceMouselook(); | ||
2304 | |||
2305 | ControllingClient.SendSitResponse( | ||
2306 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2307 | |||
2308 | // not using autopilot | ||
2309 | |||
2310 | Rotation = Orientation; | ||
2311 | m_pos = offset; | ||
2312 | |||
2313 | m_requestedSitTargetID = 0; | ||
2314 | part.ParentGroup.AddAvatar(UUID); | ||
2315 | |||
2316 | ParentPart = part; | ||
2317 | ParentID = part.LocalId; | ||
2318 | if(status == 3) | ||
2319 | Animator.TrySetMovementAnimation("SIT_GROUND"); | ||
2320 | else | ||
2321 | Animator.TrySetMovementAnimation("SIT"); | ||
2322 | SendAvatarDataToAllAgents(); | ||
2323 | |||
2324 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
2176 | } | 2325 | } |
2177 | */ | 2326 | |
2178 | 2327 | ||
2179 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2328 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2180 | { | 2329 | { |
@@ -2191,6 +2340,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2191 | return; | 2340 | return; |
2192 | } | 2341 | } |
2193 | 2342 | ||
2343 | |||
2194 | if (part.SitTargetAvatar == UUID) | 2344 | if (part.SitTargetAvatar == UUID) |
2195 | { | 2345 | { |
2196 | Vector3 sitTargetPos = part.SitTargetPosition; | 2346 | Vector3 sitTargetPos = part.SitTargetPosition; |
@@ -2205,14 +2355,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2205 | 2355 | ||
2206 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2356 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2207 | 2357 | ||
2208 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2358 | double x, y, z, m; |
2359 | |||
2360 | Quaternion r = sitTargetOrient; | ||
2361 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2362 | |||
2363 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2364 | { | ||
2365 | m = 1.0 / Math.Sqrt(m); | ||
2366 | r.X *= (float)m; | ||
2367 | r.Y *= (float)m; | ||
2368 | r.Z *= (float)m; | ||
2369 | r.W *= (float)m; | ||
2370 | } | ||
2371 | |||
2372 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2373 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2374 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2375 | |||
2376 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2377 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2378 | |||
2379 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2380 | |||
2381 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2209 | Rotation = sitTargetOrient; | 2382 | Rotation = sitTargetOrient; |
2210 | ParentPosition = part.AbsolutePosition; | 2383 | // ParentPosition = part.AbsolutePosition; |
2384 | part.ParentGroup.AddAvatar(UUID); | ||
2211 | } | 2385 | } |
2212 | else | 2386 | else |
2213 | { | 2387 | { |
2214 | m_pos -= part.AbsolutePosition; | 2388 | m_pos -= part.AbsolutePosition; |
2215 | ParentPosition = part.AbsolutePosition; | 2389 | // ParentPosition = part.AbsolutePosition; |
2390 | part.ParentGroup.AddAvatar(UUID); | ||
2216 | 2391 | ||
2217 | // m_log.DebugFormat( | 2392 | // m_log.DebugFormat( |
2218 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2393 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2262,6 +2437,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2262 | Animator.RemoveAnimation(animID, false); | 2437 | Animator.RemoveAnimation(animID, false); |
2263 | } | 2438 | } |
2264 | 2439 | ||
2440 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2441 | { | ||
2442 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2443 | } | ||
2444 | |||
2445 | |||
2446 | |||
2265 | /// <summary> | 2447 | /// <summary> |
2266 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2448 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2267 | /// </summary> | 2449 | /// </summary> |
@@ -2315,14 +2497,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2315 | direc.Z *= 2.6f; | 2497 | direc.Z *= 2.6f; |
2316 | 2498 | ||
2317 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2499 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2318 | Animator.TrySetMovementAnimation("PREJUMP"); | 2500 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2319 | Animator.TrySetMovementAnimation("JUMP"); | 2501 | // Animator.TrySetMovementAnimation("JUMP"); |
2320 | } | 2502 | } |
2321 | } | 2503 | } |
2322 | } | 2504 | } |
2323 | 2505 | ||
2324 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2506 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2325 | m_forceToApply = direc; | 2507 | m_forceToApply = direc; |
2508 | Animator.UpdateMovementAnimations(); | ||
2326 | } | 2509 | } |
2327 | 2510 | ||
2328 | #endregion | 2511 | #endregion |
@@ -2340,16 +2523,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2340 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 2523 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2341 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 2524 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2342 | // storing a requested force instead of an actual traveling velocity | 2525 | // storing a requested force instead of an actual traveling velocity |
2526 | if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) | ||
2527 | SendAvatarDataToAllAgents(); | ||
2343 | 2528 | ||
2344 | // Throw away duplicate or insignificant updates | 2529 | if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2345 | if ( | 2530 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2346 | // If the velocity has become zero, send it no matter what. | 2531 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2347 | (Velocity != m_lastVelocity && Velocity == Vector3.Zero) | ||
2348 | // otherwise, if things have changed reasonably, send the update | ||
2349 | || (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) | ||
2350 | || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) | ||
2351 | || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))) | ||
2352 | |||
2353 | { | 2532 | { |
2354 | SendTerseUpdateToAllClients(); | 2533 | SendTerseUpdateToAllClients(); |
2355 | 2534 | ||
@@ -2538,6 +2717,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2538 | return; | 2717 | return; |
2539 | } | 2718 | } |
2540 | 2719 | ||
2720 | m_lastSize = Appearance.AvatarSize; | ||
2721 | |||
2541 | int count = 0; | 2722 | int count = 0; |
2542 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 2723 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
2543 | { | 2724 | { |
@@ -2645,6 +2826,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2645 | 2826 | ||
2646 | avatar.ControllingClient.SendAppearance( | 2827 | avatar.ControllingClient.SendAppearance( |
2647 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); | 2828 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
2829 | |||
2830 | |||
2648 | } | 2831 | } |
2649 | 2832 | ||
2650 | #endregion | 2833 | #endregion |
@@ -2719,8 +2902,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2719 | 2902 | ||
2720 | // If we don't have a PhysActor, we can't cross anyway | 2903 | // If we don't have a PhysActor, we can't cross anyway |
2721 | // Also don't do this while sat, sitting avatars cross with the | 2904 | // Also don't do this while sat, sitting avatars cross with the |
2722 | // object they sit on. | 2905 | // object they sit on. ParentUUID denoted a pending sit, don't |
2723 | if (ParentID != 0 || PhysicsActor == null) | 2906 | // interfere with it. |
2907 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2724 | return; | 2908 | return; |
2725 | 2909 | ||
2726 | if (!IsInTransit) | 2910 | if (!IsInTransit) |
@@ -2981,6 +3165,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2981 | } | 3165 | } |
2982 | 3166 | ||
2983 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3167 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3168 | private void RaiseUpdateThrottles() | ||
3169 | { | ||
3170 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3171 | } | ||
2984 | /// <summary> | 3172 | /// <summary> |
2985 | /// This updates important decision making data about a child agent | 3173 | /// This updates important decision making data about a child agent |
2986 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3174 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3061,6 +3249,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3061 | cAgent.AlwaysRun = SetAlwaysRun; | 3249 | cAgent.AlwaysRun = SetAlwaysRun; |
3062 | 3250 | ||
3063 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3251 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3252 | |||
3253 | cAgent.ParentPart = ParentUUID; | ||
3254 | cAgent.SitOffset = m_pos; | ||
3064 | 3255 | ||
3065 | lock (scriptedcontrols) | 3256 | lock (scriptedcontrols) |
3066 | { | 3257 | { |
@@ -3069,7 +3260,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3069 | 3260 | ||
3070 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3261 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3071 | { | 3262 | { |
3072 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3263 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3073 | } | 3264 | } |
3074 | cAgent.Controllers = controls; | 3265 | cAgent.Controllers = controls; |
3075 | } | 3266 | } |
@@ -3102,6 +3293,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3102 | CameraAtAxis = cAgent.AtAxis; | 3293 | CameraAtAxis = cAgent.AtAxis; |
3103 | CameraLeftAxis = cAgent.LeftAxis; | 3294 | CameraLeftAxis = cAgent.LeftAxis; |
3104 | CameraUpAxis = cAgent.UpAxis; | 3295 | CameraUpAxis = cAgent.UpAxis; |
3296 | ParentUUID = cAgent.ParentPart; | ||
3297 | m_prevSitOffset = cAgent.SitOffset; | ||
3105 | 3298 | ||
3106 | // When we get to the point of re-computing neighbors everytime this | 3299 | // When we get to the point of re-computing neighbors everytime this |
3107 | // changes, then start using the agent's drawdistance rather than the | 3300 | // changes, then start using the agent's drawdistance rather than the |
@@ -3139,6 +3332,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3139 | foreach (ControllerData c in cAgent.Controllers) | 3332 | foreach (ControllerData c in cAgent.Controllers) |
3140 | { | 3333 | { |
3141 | ScriptControllers sc = new ScriptControllers(); | 3334 | ScriptControllers sc = new ScriptControllers(); |
3335 | sc.objectID = c.ObjectID; | ||
3142 | sc.itemID = c.ItemID; | 3336 | sc.itemID = c.ItemID; |
3143 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3337 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3144 | sc.eventControls = (ScriptControlled)c.EventControls; | 3338 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3206,20 +3400,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3206 | } | 3400 | } |
3207 | 3401 | ||
3208 | if (Appearance.AvatarHeight == 0) | 3402 | if (Appearance.AvatarHeight == 0) |
3209 | Appearance.SetHeight(); | 3403 | // Appearance.SetHeight(); |
3404 | Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
3210 | 3405 | ||
3211 | PhysicsScene scene = m_scene.PhysicsScene; | 3406 | PhysicsScene scene = m_scene.PhysicsScene; |
3212 | 3407 | ||
3213 | Vector3 pVec = AbsolutePosition; | 3408 | Vector3 pVec = AbsolutePosition; |
3214 | 3409 | ||
3410 | /* | ||
3215 | PhysicsActor = scene.AddAvatar( | 3411 | PhysicsActor = scene.AddAvatar( |
3216 | LocalId, Firstname + "." + Lastname, pVec, | 3412 | LocalId, Firstname + "." + Lastname, pVec, |
3217 | new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); | 3413 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); |
3414 | */ | ||
3415 | |||
3416 | PhysicsActor = scene.AddAvatar( | ||
3417 | LocalId, Firstname + "." + Lastname, pVec, | ||
3418 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); | ||
3218 | 3419 | ||
3219 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3420 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3220 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3421 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3221 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3422 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3222 | PhysicsActor.SubscribeEvents(500); | 3423 | PhysicsActor.SubscribeEvents(100); |
3223 | PhysicsActor.LocalID = LocalId; | 3424 | PhysicsActor.LocalID = LocalId; |
3224 | } | 3425 | } |
3225 | 3426 | ||
@@ -3233,6 +3434,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3233 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); | 3434 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); |
3234 | } | 3435 | } |
3235 | 3436 | ||
3437 | |||
3236 | /// <summary> | 3438 | /// <summary> |
3237 | /// Event called by the physics plugin to tell the avatar about a collision. | 3439 | /// Event called by the physics plugin to tell the avatar about a collision. |
3238 | /// </summary> | 3440 | /// </summary> |
@@ -3246,7 +3448,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3246 | /// <param name="e"></param> | 3448 | /// <param name="e"></param> |
3247 | public void PhysicsCollisionUpdate(EventArgs e) | 3449 | public void PhysicsCollisionUpdate(EventArgs e) |
3248 | { | 3450 | { |
3249 | if (IsChildAgent) | 3451 | if (IsChildAgent || Animator == null) |
3250 | return; | 3452 | return; |
3251 | 3453 | ||
3252 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3454 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3262,7 +3464,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3262 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3464 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3263 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3465 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3264 | 3466 | ||
3265 | CollisionPlane = Vector4.UnitW; | ||
3266 | 3467 | ||
3267 | // // No collisions at all means we may be flying. Update always | 3468 | // // No collisions at all means we may be flying. Update always |
3268 | // // to make falling work | 3469 | // // to make falling work |
@@ -3274,6 +3475,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3274 | 3475 | ||
3275 | if (coldata.Count != 0) | 3476 | if (coldata.Count != 0) |
3276 | { | 3477 | { |
3478 | /* | ||
3277 | switch (Animator.CurrentMovementAnimation) | 3479 | switch (Animator.CurrentMovementAnimation) |
3278 | { | 3480 | { |
3279 | case "STAND": | 3481 | case "STAND": |
@@ -3282,24 +3484,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
3282 | case "CROUCH": | 3484 | case "CROUCH": |
3283 | case "CROUCHWALK": | 3485 | case "CROUCHWALK": |
3284 | { | 3486 | { |
3487 | */ | ||
3285 | ContactPoint lowest; | 3488 | ContactPoint lowest; |
3286 | lowest.SurfaceNormal = Vector3.Zero; | 3489 | lowest.SurfaceNormal = Vector3.Zero; |
3287 | lowest.Position = Vector3.Zero; | 3490 | lowest.Position = Vector3.Zero; |
3288 | lowest.Position.Z = Single.NaN; | 3491 | lowest.Position.Z = float.MaxValue; |
3289 | 3492 | ||
3290 | foreach (ContactPoint contact in coldata.Values) | 3493 | foreach (ContactPoint contact in coldata.Values) |
3291 | { | 3494 | { |
3292 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | 3495 | |
3496 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
3293 | { | 3497 | { |
3294 | lowest = contact; | 3498 | lowest = contact; |
3295 | } | 3499 | } |
3296 | } | 3500 | } |
3297 | 3501 | ||
3298 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | 3502 | if (lowest.Position.Z != float.MaxValue) |
3503 | { | ||
3504 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
3505 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3506 | } | ||
3507 | else | ||
3508 | CollisionPlane = Vector4.UnitW; | ||
3509 | /* | ||
3299 | } | 3510 | } |
3300 | break; | 3511 | break; |
3301 | } | 3512 | } |
3513 | */ | ||
3302 | } | 3514 | } |
3515 | else | ||
3516 | CollisionPlane = Vector4.UnitW; | ||
3517 | |||
3518 | RaiseCollisionScriptEvents(coldata); | ||
3303 | 3519 | ||
3304 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3520 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3305 | if (Invulnerable || GodLevel > 0) | 3521 | if (Invulnerable || GodLevel > 0) |
@@ -3398,6 +3614,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3398 | // m_reprioritizationTimer.Dispose(); | 3614 | // m_reprioritizationTimer.Dispose(); |
3399 | 3615 | ||
3400 | RemoveFromPhysicalScene(); | 3616 | RemoveFromPhysicalScene(); |
3617 | |||
3618 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3619 | |||
3620 | // if (Animator != null) | ||
3621 | // Animator.Close(); | ||
3622 | Animator = null; | ||
3623 | |||
3401 | } | 3624 | } |
3402 | 3625 | ||
3403 | public void AddAttachment(SceneObjectGroup gobj) | 3626 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3631,10 +3854,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3631 | 3854 | ||
3632 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 3855 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3633 | { | 3856 | { |
3857 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
3858 | if (p == null) | ||
3859 | return; | ||
3860 | |||
3861 | ControllingClient.SendTakeControls(controls, false, false); | ||
3862 | ControllingClient.SendTakeControls(controls, true, false); | ||
3863 | |||
3634 | ScriptControllers obj = new ScriptControllers(); | 3864 | ScriptControllers obj = new ScriptControllers(); |
3635 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 3865 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3636 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 3866 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3637 | 3867 | ||
3868 | obj.objectID = p.ParentGroup.UUID; | ||
3638 | obj.itemID = Script_item_UUID; | 3869 | obj.itemID = Script_item_UUID; |
3639 | if (pass_on == 0 && accept == 0) | 3870 | if (pass_on == 0 && accept == 0) |
3640 | { | 3871 | { |
@@ -3683,6 +3914,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3683 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 3914 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3684 | } | 3915 | } |
3685 | 3916 | ||
3917 | private void UnRegisterSeatControls(UUID obj) | ||
3918 | { | ||
3919 | List<UUID> takers = new List<UUID>(); | ||
3920 | |||
3921 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
3922 | { | ||
3923 | if (c.objectID == obj) | ||
3924 | takers.Add(c.itemID); | ||
3925 | } | ||
3926 | foreach (UUID t in takers) | ||
3927 | { | ||
3928 | UnRegisterControlEventsToScript(0, t); | ||
3929 | } | ||
3930 | } | ||
3931 | |||
3686 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3932 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3687 | { | 3933 | { |
3688 | ScriptControllers takecontrols; | 3934 | ScriptControllers takecontrols; |
@@ -4001,6 +4247,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4001 | 4247 | ||
4002 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4248 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4003 | { | 4249 | { |
4250 | string reason; | ||
4251 | |||
4252 | // Honor bans | ||
4253 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4254 | return; | ||
4255 | |||
4004 | SceneObjectGroup telehub = null; | 4256 | SceneObjectGroup telehub = null; |
4005 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4257 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4006 | { | 4258 | { |
@@ -4040,11 +4292,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4040 | pos = land.LandData.UserLocation; | 4292 | pos = land.LandData.UserLocation; |
4041 | } | 4293 | } |
4042 | } | 4294 | } |
4043 | 4295 | ||
4044 | land.SendLandUpdateToClient(ControllingClient); | 4296 | land.SendLandUpdateToClient(ControllingClient); |
4045 | } | 4297 | } |
4046 | } | 4298 | } |
4047 | 4299 | ||
4300 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4301 | { | ||
4302 | DetectedObject detobj = new DetectedObject(); | ||
4303 | detobj.keyUUID = obj.UUID; | ||
4304 | detobj.nameStr = obj.Name; | ||
4305 | detobj.ownerUUID = obj.OwnerID; | ||
4306 | detobj.posVector = obj.AbsolutePosition; | ||
4307 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4308 | detobj.velVector = obj.Velocity; | ||
4309 | detobj.colliderType = 0; | ||
4310 | detobj.groupUUID = obj.GroupID; | ||
4311 | |||
4312 | return detobj; | ||
4313 | } | ||
4314 | |||
4315 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4316 | { | ||
4317 | DetectedObject detobj = new DetectedObject(); | ||
4318 | detobj.keyUUID = av.UUID; | ||
4319 | detobj.nameStr = av.ControllingClient.Name; | ||
4320 | detobj.ownerUUID = av.UUID; | ||
4321 | detobj.posVector = av.AbsolutePosition; | ||
4322 | detobj.rotQuat = av.Rotation; | ||
4323 | detobj.velVector = av.Velocity; | ||
4324 | detobj.colliderType = 0; | ||
4325 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4326 | |||
4327 | return detobj; | ||
4328 | } | ||
4329 | |||
4330 | private DetectedObject CreateDetObjectForGround() | ||
4331 | { | ||
4332 | DetectedObject detobj = new DetectedObject(); | ||
4333 | detobj.keyUUID = UUID.Zero; | ||
4334 | detobj.nameStr = ""; | ||
4335 | detobj.ownerUUID = UUID.Zero; | ||
4336 | detobj.posVector = AbsolutePosition; | ||
4337 | detobj.rotQuat = Quaternion.Identity; | ||
4338 | detobj.velVector = Vector3.Zero; | ||
4339 | detobj.colliderType = 0; | ||
4340 | detobj.groupUUID = UUID.Zero; | ||
4341 | |||
4342 | return detobj; | ||
4343 | } | ||
4344 | |||
4345 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4346 | { | ||
4347 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4348 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4349 | foreach (uint localId in colliders) | ||
4350 | { | ||
4351 | if (localId == 0) | ||
4352 | continue; | ||
4353 | |||
4354 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4355 | if (obj != null) | ||
4356 | { | ||
4357 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4358 | colliding.Add(CreateDetObject(obj)); | ||
4359 | } | ||
4360 | else | ||
4361 | { | ||
4362 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4363 | if (av != null && (!av.IsChildAgent)) | ||
4364 | { | ||
4365 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4366 | colliding.Add(CreateDetObject(av)); | ||
4367 | } | ||
4368 | } | ||
4369 | } | ||
4370 | |||
4371 | colliderArgs.Colliders = colliding; | ||
4372 | |||
4373 | return colliderArgs; | ||
4374 | } | ||
4375 | |||
4376 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4377 | |||
4378 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4379 | { | ||
4380 | ColliderArgs CollidingMessage; | ||
4381 | |||
4382 | if (colliders.Count > 0) | ||
4383 | { | ||
4384 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4385 | { | ||
4386 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4387 | |||
4388 | if (CollidingMessage.Colliders.Count > 0) | ||
4389 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4390 | } | ||
4391 | } | ||
4392 | } | ||
4393 | |||
4394 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4395 | { | ||
4396 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4397 | { | ||
4398 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4399 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4400 | |||
4401 | colliding.Add(CreateDetObjectForGround()); | ||
4402 | LandCollidingMessage.Colliders = colliding; | ||
4403 | |||
4404 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4405 | } | ||
4406 | } | ||
4407 | |||
4408 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4409 | { | ||
4410 | try | ||
4411 | { | ||
4412 | List<uint> thisHitColliders = new List<uint>(); | ||
4413 | List<uint> endedColliders = new List<uint>(); | ||
4414 | List<uint> startedColliders = new List<uint>(); | ||
4415 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4416 | CollisionForSoundInfo soundinfo; | ||
4417 | ContactPoint curcontact; | ||
4418 | |||
4419 | if (coldata.Count == 0) | ||
4420 | { | ||
4421 | if (m_lastColliders.Count == 0) | ||
4422 | return; // nothing to do | ||
4423 | |||
4424 | foreach (uint localID in m_lastColliders) | ||
4425 | { | ||
4426 | endedColliders.Add(localID); | ||
4427 | } | ||
4428 | m_lastColliders.Clear(); | ||
4429 | } | ||
4430 | |||
4431 | else | ||
4432 | { | ||
4433 | foreach (uint id in coldata.Keys) | ||
4434 | { | ||
4435 | thisHitColliders.Add(id); | ||
4436 | if (!m_lastColliders.Contains(id)) | ||
4437 | { | ||
4438 | startedColliders.Add(id); | ||
4439 | curcontact = coldata[id]; | ||
4440 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4441 | { | ||
4442 | soundinfo = new CollisionForSoundInfo(); | ||
4443 | soundinfo.colliderID = id; | ||
4444 | soundinfo.position = curcontact.Position; | ||
4445 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4446 | soundinfolist.Add(soundinfo); | ||
4447 | } | ||
4448 | } | ||
4449 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4450 | } | ||
4451 | |||
4452 | // calculate things that ended colliding | ||
4453 | foreach (uint localID in m_lastColliders) | ||
4454 | { | ||
4455 | if (!thisHitColliders.Contains(localID)) | ||
4456 | { | ||
4457 | endedColliders.Add(localID); | ||
4458 | } | ||
4459 | } | ||
4460 | //add the items that started colliding this time to the last colliders list. | ||
4461 | foreach (uint localID in startedColliders) | ||
4462 | { | ||
4463 | m_lastColliders.Add(localID); | ||
4464 | } | ||
4465 | // remove things that ended colliding from the last colliders list | ||
4466 | foreach (uint localID in endedColliders) | ||
4467 | { | ||
4468 | m_lastColliders.Remove(localID); | ||
4469 | } | ||
4470 | |||
4471 | if (soundinfolist.Count > 0) | ||
4472 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4473 | } | ||
4474 | |||
4475 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4476 | { | ||
4477 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4478 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4479 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4480 | |||
4481 | if (startedColliders.Contains(0)) | ||
4482 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4483 | if (m_lastColliders.Contains(0)) | ||
4484 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4485 | if (endedColliders.Contains(0)) | ||
4486 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4487 | } | ||
4488 | } | ||
4489 | finally | ||
4490 | { | ||
4491 | m_collisionEventFlag = false; | ||
4492 | } | ||
4493 | } | ||
4494 | |||
4048 | private void TeleportFlagsDebug() { | 4495 | private void TeleportFlagsDebug() { |
4049 | 4496 | ||
4050 | // Some temporary debugging help to show all the TeleportFlags we have... | 4497 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4069,6 +4516,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4069 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4516 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4070 | 4517 | ||
4071 | } | 4518 | } |
4072 | |||
4073 | } | 4519 | } |
4074 | } | 4520 | } |