diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 431 |
1 files changed, 356 insertions, 75 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6b38027..e0d5055 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -92,7 +92,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
92 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 92 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
93 | /// issue #1716 | 93 | /// issue #1716 |
94 | /// </summary> | 94 | /// </summary> |
95 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 95 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
96 | 96 | ||
97 | /// <summary> | 97 | /// <summary> |
98 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 98 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -169,6 +169,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
169 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 169 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
170 | // private int m_updateCount = 0; //KF: Update Anims for a while | 170 | // private int m_updateCount = 0; //KF: Update Anims for a while |
171 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 171 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
172 | private List<uint> m_lastColliders = new List<uint>(); | ||
172 | 173 | ||
173 | private TeleportFlags m_teleportFlags; | 174 | private TeleportFlags m_teleportFlags; |
174 | public TeleportFlags TeleportFlags | 175 | public TeleportFlags TeleportFlags |
@@ -230,6 +231,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
230 | //private int m_moveToPositionStateStatus; | 231 | //private int m_moveToPositionStateStatus; |
231 | //***************************************************** | 232 | //***************************************************** |
232 | 233 | ||
234 | private bool m_collisionEventFlag = false; | ||
235 | private object m_collisionEventLock = new Object(); | ||
236 | |||
237 | private int m_movementAnimationUpdateCounter = 0; | ||
238 | |||
239 | private Vector3 m_prevSitOffset; | ||
240 | |||
233 | protected AvatarAppearance m_appearance; | 241 | protected AvatarAppearance m_appearance; |
234 | 242 | ||
235 | public AvatarAppearance Appearance | 243 | public AvatarAppearance Appearance |
@@ -569,6 +577,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
569 | /// </summary> | 577 | /// </summary> |
570 | public uint ParentID { get; set; } | 578 | public uint ParentID { get; set; } |
571 | 579 | ||
580 | public UUID ParentUUID | ||
581 | { | ||
582 | get { return m_parentUUID; } | ||
583 | set { m_parentUUID = value; } | ||
584 | } | ||
585 | private UUID m_parentUUID = UUID.Zero; | ||
586 | |||
572 | /// <summary> | 587 | /// <summary> |
573 | /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. | 588 | /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. |
574 | /// </summary> | 589 | /// </summary> |
@@ -729,6 +744,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
729 | Appearance = appearance; | 744 | Appearance = appearance; |
730 | } | 745 | } |
731 | 746 | ||
747 | private void RegionHeartbeatEnd(Scene scene) | ||
748 | { | ||
749 | if (IsChildAgent) | ||
750 | return; | ||
751 | |||
752 | m_movementAnimationUpdateCounter ++; | ||
753 | if (m_movementAnimationUpdateCounter >= 2) | ||
754 | { | ||
755 | m_movementAnimationUpdateCounter = 0; | ||
756 | if (Animator != null) | ||
757 | { | ||
758 | if(ParentID == 0 && !SitGround) // skip it if sitting | ||
759 | Animator.UpdateMovementAnimations(); | ||
760 | } | ||
761 | else | ||
762 | { | ||
763 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
764 | } | ||
765 | } | ||
766 | } | ||
767 | |||
732 | public void RegisterToEvents() | 768 | public void RegisterToEvents() |
733 | { | 769 | { |
734 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 770 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -798,10 +834,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
798 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 834 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
799 | Name, m_scene.RegionInfo.RegionName); | 835 | Name, m_scene.RegionInfo.RegionName); |
800 | 836 | ||
801 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
802 | |||
803 | bool wasChild = IsChildAgent; | 837 | bool wasChild = IsChildAgent; |
804 | IsChildAgent = false; | 838 | |
839 | if (ParentUUID != UUID.Zero) | ||
840 | { | ||
841 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
842 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
843 | if (part == null) | ||
844 | { | ||
845 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
846 | } | ||
847 | else | ||
848 | { | ||
849 | part.ParentGroup.AddAvatar(UUID); | ||
850 | if (part.SitTargetPosition != Vector3.Zero) | ||
851 | part.SitTargetAvatar = UUID; | ||
852 | ParentPosition = part.GetWorldPosition(); | ||
853 | ParentID = part.LocalId; | ||
854 | ParentPart = part; | ||
855 | m_pos = m_prevSitOffset; | ||
856 | pos = ParentPosition; | ||
857 | } | ||
858 | ParentUUID = UUID.Zero; | ||
859 | |||
860 | IsChildAgent = false; | ||
861 | |||
862 | Animator.TrySetMovementAnimation("SIT"); | ||
863 | } | ||
864 | else | ||
865 | { | ||
866 | IsChildAgent = false; | ||
867 | } | ||
868 | |||
805 | 869 | ||
806 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 870 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
807 | if (gm != null) | 871 | if (gm != null) |
@@ -811,62 +875,64 @@ namespace OpenSim.Region.Framework.Scenes | |||
811 | 875 | ||
812 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 876 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
813 | 877 | ||
814 | // Moved this from SendInitialData to ensure that Appearance is initialized | 878 | if (ParentID == 0) |
815 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | ||
816 | // related to the handling of attachments | ||
817 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
818 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
819 | { | 879 | { |
820 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 880 | // Moved this from SendInitialData to ensure that Appearance is initialized |
821 | pos.X = crossedBorder.BorderLine.Z - 1; | 881 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
822 | } | 882 | // related to the handling of attachments |
883 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
884 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
885 | { | ||
886 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
887 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
888 | } | ||
823 | 889 | ||
824 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 890 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
825 | { | 891 | { |
826 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 892 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
827 | pos.Y = crossedBorder.BorderLine.Z - 1; | 893 | pos.Y = crossedBorder.BorderLine.Z - 1; |
828 | } | 894 | } |
829 | 895 | ||
830 | CheckAndAdjustLandingPoint(ref pos); | 896 | CheckAndAdjustLandingPoint(ref pos); |
831 | 897 | ||
832 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 898 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
833 | { | 899 | { |
834 | m_log.WarnFormat( | 900 | m_log.WarnFormat( |
835 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 901 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
836 | pos, Name, UUID); | 902 | pos, Name, UUID); |
837 | 903 | ||
838 | if (pos.X < 0f) pos.X = 0f; | 904 | if (pos.X < 0f) pos.X = 0f; |
839 | if (pos.Y < 0f) pos.Y = 0f; | 905 | if (pos.Y < 0f) pos.Y = 0f; |
840 | if (pos.Z < 0f) pos.Z = 0f; | 906 | if (pos.Z < 0f) pos.Z = 0f; |
841 | } | 907 | } |
842 | 908 | ||
843 | float localAVHeight = 1.56f; | 909 | float localAVHeight = 1.56f; |
844 | if (Appearance.AvatarHeight > 0) | 910 | if (Appearance.AvatarHeight > 0) |
845 | localAVHeight = Appearance.AvatarHeight; | 911 | localAVHeight = Appearance.AvatarHeight; |
846 | 912 | ||
847 | float posZLimit = 0; | 913 | float posZLimit = 0; |
848 | 914 | ||
849 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 915 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
850 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 916 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
851 | 917 | ||
852 | float newPosZ = posZLimit + localAVHeight / 2; | 918 | float newPosZ = posZLimit + localAVHeight / 2; |
853 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 919 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
854 | { | 920 | { |
855 | pos.Z = newPosZ; | 921 | pos.Z = newPosZ; |
856 | } | 922 | } |
857 | AbsolutePosition = pos; | 923 | AbsolutePosition = pos; |
858 | 924 | ||
859 | AddToPhysicalScene(isFlying); | 925 | AddToPhysicalScene(isFlying); |
860 | 926 | ||
861 | if (ForceFly) | 927 | if (ForceFly) |
862 | { | 928 | { |
863 | Flying = true; | 929 | Flying = true; |
864 | } | 930 | } |
865 | else if (FlyDisabled) | 931 | else if (FlyDisabled) |
866 | { | 932 | { |
867 | Flying = false; | 933 | Flying = false; |
934 | } | ||
868 | } | 935 | } |
869 | |||
870 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 936 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
871 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 937 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
872 | // elsewhere anyway | 938 | // elsewhere anyway |
@@ -884,14 +950,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
884 | { | 950 | { |
885 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); | 951 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); |
886 | // Resume scripts | 952 | // Resume scripts |
887 | foreach (SceneObjectGroup sog in m_attachments) | 953 | Util.FireAndForget(delegate(object x) { |
888 | { | 954 | foreach (SceneObjectGroup sog in m_attachments) |
889 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 955 | { |
890 | sog.ResumeScripts(); | 956 | sog.ScheduleGroupForFullUpdate(); |
891 | } | 957 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
958 | sog.ResumeScripts(); | ||
959 | } | ||
960 | }); | ||
892 | } | 961 | } |
893 | } | 962 | } |
894 | 963 | ||
964 | SendAvatarDataToAllAgents(); | ||
965 | |||
895 | // send the animations of the other presences to me | 966 | // send the animations of the other presences to me |
896 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 967 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
897 | { | 968 | { |
@@ -905,6 +976,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
905 | MovementFlag = 0; | 976 | MovementFlag = 0; |
906 | 977 | ||
907 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 978 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
979 | |||
980 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
908 | } | 981 | } |
909 | 982 | ||
910 | public int GetStateSource() | 983 | public int GetStateSource() |
@@ -932,6 +1005,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
932 | /// </remarks> | 1005 | /// </remarks> |
933 | public void MakeChildAgent() | 1006 | public void MakeChildAgent() |
934 | { | 1007 | { |
1008 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1009 | |||
935 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1010 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
936 | 1011 | ||
937 | // Reset these so that teleporting in and walking out isn't seen | 1012 | // Reset these so that teleporting in and walking out isn't seen |
@@ -990,7 +1065,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
990 | /// <param name="pos"></param> | 1065 | /// <param name="pos"></param> |
991 | public void Teleport(Vector3 pos) | 1066 | public void Teleport(Vector3 pos) |
992 | { | 1067 | { |
993 | TeleportWithMomentum(pos, null); | 1068 | TeleportWithMomentum(pos, Vector3.Zero); |
994 | } | 1069 | } |
995 | 1070 | ||
996 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1071 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1315,8 +1390,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1315 | { | 1390 | { |
1316 | if (m_followCamAuto) | 1391 | if (m_followCamAuto) |
1317 | { | 1392 | { |
1318 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1393 | // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1319 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1394 | // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); |
1395 | |||
1396 | Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; | ||
1397 | Vector3 distTocam = CameraPosition - posAdjusted; | ||
1398 | float distTocamlen = distTocam.Length(); | ||
1399 | if (distTocamlen > 0) | ||
1400 | { | ||
1401 | distTocam *= 1.0f / distTocamlen; | ||
1402 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); | ||
1403 | } | ||
1404 | |||
1320 | } | 1405 | } |
1321 | } | 1406 | } |
1322 | 1407 | ||
@@ -1752,8 +1837,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1752 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1837 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1753 | 1838 | ||
1754 | SitGround = false; | 1839 | SitGround = false; |
1840 | |||
1841 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1755 | if (PhysicsActor == null) | 1842 | if (PhysicsActor == null) |
1756 | AddToPhysicalScene(false); | 1843 | AddToPhysicalScene(false); |
1844 | */ | ||
1757 | 1845 | ||
1758 | if (ParentID != 0) | 1846 | if (ParentID != 0) |
1759 | { | 1847 | { |
@@ -1777,6 +1865,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1777 | if (part.SitTargetAvatar == UUID) | 1865 | if (part.SitTargetAvatar == UUID) |
1778 | part.SitTargetAvatar = UUID.Zero; | 1866 | part.SitTargetAvatar = UUID.Zero; |
1779 | 1867 | ||
1868 | part.ParentGroup.DeleteAvatar(UUID); | ||
1780 | ParentPosition = part.GetWorldPosition(); | 1869 | ParentPosition = part.GetWorldPosition(); |
1781 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1870 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1782 | 1871 | ||
@@ -1785,6 +1874,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1785 | 1874 | ||
1786 | ParentID = 0; | 1875 | ParentID = 0; |
1787 | ParentPart = null; | 1876 | ParentPart = null; |
1877 | |||
1878 | if (PhysicsActor == null) | ||
1879 | AddToPhysicalScene(false); | ||
1880 | |||
1788 | SendAvatarDataToAllAgents(); | 1881 | SendAvatarDataToAllAgents(); |
1789 | m_requestedSitTargetID = 0; | 1882 | m_requestedSitTargetID = 0; |
1790 | 1883 | ||
@@ -1792,6 +1885,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1792 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1885 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1793 | } | 1886 | } |
1794 | 1887 | ||
1888 | else if (PhysicsActor == null) | ||
1889 | AddToPhysicalScene(false); | ||
1890 | |||
1795 | Animator.TrySetMovementAnimation("STAND"); | 1891 | Animator.TrySetMovementAnimation("STAND"); |
1796 | } | 1892 | } |
1797 | 1893 | ||
@@ -1915,7 +2011,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1915 | forceMouselook = part.GetForceMouselook(); | 2011 | forceMouselook = part.GetForceMouselook(); |
1916 | 2012 | ||
1917 | ControllingClient.SendSitResponse( | 2013 | ControllingClient.SendSitResponse( |
1918 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2014 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1919 | 2015 | ||
1920 | m_requestedSitTargetUUID = targetID; | 2016 | m_requestedSitTargetUUID = targetID; |
1921 | 2017 | ||
@@ -2197,14 +2293,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
2197 | 2293 | ||
2198 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2294 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2199 | 2295 | ||
2200 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2296 | double x, y, z, m; |
2297 | |||
2298 | Quaternion r = sitTargetOrient; | ||
2299 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2300 | |||
2301 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2302 | { | ||
2303 | m = 1.0 / Math.Sqrt(m); | ||
2304 | r.X *= (float)m; | ||
2305 | r.Y *= (float)m; | ||
2306 | r.Z *= (float)m; | ||
2307 | r.W *= (float)m; | ||
2308 | } | ||
2309 | |||
2310 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2311 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2312 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2313 | |||
2314 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2315 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2316 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2201 | Rotation = sitTargetOrient; | 2317 | Rotation = sitTargetOrient; |
2202 | ParentPosition = part.AbsolutePosition; | 2318 | ParentPosition = part.AbsolutePosition; |
2319 | part.ParentGroup.AddAvatar(UUID); | ||
2203 | } | 2320 | } |
2204 | else | 2321 | else |
2205 | { | 2322 | { |
2206 | m_pos -= part.AbsolutePosition; | 2323 | m_pos -= part.AbsolutePosition; |
2207 | ParentPosition = part.AbsolutePosition; | 2324 | ParentPosition = part.AbsolutePosition; |
2325 | part.ParentGroup.AddAvatar(UUID); | ||
2208 | 2326 | ||
2209 | // m_log.DebugFormat( | 2327 | // m_log.DebugFormat( |
2210 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2328 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2302,14 +2420,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2302 | direc.Z *= 2.6f; | 2420 | direc.Z *= 2.6f; |
2303 | 2421 | ||
2304 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2422 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2305 | Animator.TrySetMovementAnimation("PREJUMP"); | 2423 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2306 | Animator.TrySetMovementAnimation("JUMP"); | 2424 | // Animator.TrySetMovementAnimation("JUMP"); |
2307 | } | 2425 | } |
2308 | } | 2426 | } |
2309 | } | 2427 | } |
2310 | 2428 | ||
2311 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2429 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2312 | m_forceToApply = direc; | 2430 | m_forceToApply = direc; |
2431 | Animator.UpdateMovementAnimations(); | ||
2313 | } | 2432 | } |
2314 | 2433 | ||
2315 | #endregion | 2434 | #endregion |
@@ -3043,6 +3162,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3043 | cAgent.AlwaysRun = SetAlwaysRun; | 3162 | cAgent.AlwaysRun = SetAlwaysRun; |
3044 | 3163 | ||
3045 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3164 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3165 | |||
3166 | cAgent.ParentPart = ParentUUID; | ||
3167 | cAgent.SitOffset = m_pos; | ||
3046 | 3168 | ||
3047 | lock (scriptedcontrols) | 3169 | lock (scriptedcontrols) |
3048 | { | 3170 | { |
@@ -3102,6 +3224,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3102 | CameraAtAxis = cAgent.AtAxis; | 3224 | CameraAtAxis = cAgent.AtAxis; |
3103 | CameraLeftAxis = cAgent.LeftAxis; | 3225 | CameraLeftAxis = cAgent.LeftAxis; |
3104 | CameraUpAxis = cAgent.UpAxis; | 3226 | CameraUpAxis = cAgent.UpAxis; |
3227 | ParentUUID = cAgent.ParentPart; | ||
3228 | m_prevSitOffset = cAgent.SitOffset; | ||
3105 | 3229 | ||
3106 | // When we get to the point of re-computing neighbors everytime this | 3230 | // When we get to the point of re-computing neighbors everytime this |
3107 | // changes, then start using the agent's drawdistance rather than the | 3231 | // changes, then start using the agent's drawdistance rather than the |
@@ -3254,18 +3378,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3254 | if (IsChildAgent) | 3378 | if (IsChildAgent) |
3255 | return; | 3379 | return; |
3256 | 3380 | ||
3257 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | ||
3258 | // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( | ||
3259 | // as of this comment the interval is set in AddToPhysicalScene | ||
3260 | if (Animator != null) | ||
3261 | { | ||
3262 | // if (m_updateCount > 0) | ||
3263 | // { | ||
3264 | Animator.UpdateMovementAnimations(); | ||
3265 | // m_updateCount--; | ||
3266 | // } | ||
3267 | } | ||
3268 | |||
3269 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3381 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3270 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3382 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3271 | 3383 | ||
@@ -3308,6 +3420,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3308 | } | 3420 | } |
3309 | } | 3421 | } |
3310 | 3422 | ||
3423 | RaiseCollisionScriptEvents(coldata); | ||
3424 | |||
3311 | if (Invulnerable) | 3425 | if (Invulnerable) |
3312 | return; | 3426 | return; |
3313 | 3427 | ||
@@ -3892,6 +4006,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3892 | 4006 | ||
3893 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4007 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3894 | { | 4008 | { |
4009 | string reason; | ||
4010 | |||
4011 | // Honor bans | ||
4012 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4013 | return; | ||
4014 | |||
3895 | SceneObjectGroup telehub = null; | 4015 | SceneObjectGroup telehub = null; |
3896 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4016 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
3897 | { | 4017 | { |
@@ -3931,11 +4051,173 @@ namespace OpenSim.Region.Framework.Scenes | |||
3931 | pos = land.LandData.UserLocation; | 4051 | pos = land.LandData.UserLocation; |
3932 | } | 4052 | } |
3933 | } | 4053 | } |
3934 | 4054 | ||
3935 | land.SendLandUpdateToClient(ControllingClient); | 4055 | land.SendLandUpdateToClient(ControllingClient); |
3936 | } | 4056 | } |
3937 | } | 4057 | } |
3938 | 4058 | ||
4059 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4060 | { | ||
4061 | lock(m_collisionEventLock) | ||
4062 | { | ||
4063 | if (m_collisionEventFlag) | ||
4064 | return; | ||
4065 | m_collisionEventFlag = true; | ||
4066 | } | ||
4067 | |||
4068 | Util.FireAndForget(delegate(object x) | ||
4069 | { | ||
4070 | try | ||
4071 | { | ||
4072 | List<uint> thisHitColliders = new List<uint>(); | ||
4073 | List<uint> endedColliders = new List<uint>(); | ||
4074 | List<uint> startedColliders = new List<uint>(); | ||
4075 | |||
4076 | foreach (uint localid in coldata.Keys) | ||
4077 | { | ||
4078 | thisHitColliders.Add(localid); | ||
4079 | if (!m_lastColliders.Contains(localid)) | ||
4080 | { | ||
4081 | startedColliders.Add(localid); | ||
4082 | } | ||
4083 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4084 | } | ||
4085 | |||
4086 | // calculate things that ended colliding | ||
4087 | foreach (uint localID in m_lastColliders) | ||
4088 | { | ||
4089 | if (!thisHitColliders.Contains(localID)) | ||
4090 | { | ||
4091 | endedColliders.Add(localID); | ||
4092 | } | ||
4093 | } | ||
4094 | //add the items that started colliding this time to the last colliders list. | ||
4095 | foreach (uint localID in startedColliders) | ||
4096 | { | ||
4097 | m_lastColliders.Add(localID); | ||
4098 | } | ||
4099 | // remove things that ended colliding from the last colliders list | ||
4100 | foreach (uint localID in endedColliders) | ||
4101 | { | ||
4102 | m_lastColliders.Remove(localID); | ||
4103 | } | ||
4104 | |||
4105 | // do event notification | ||
4106 | if (startedColliders.Count > 0) | ||
4107 | { | ||
4108 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
4109 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4110 | foreach (uint localId in startedColliders) | ||
4111 | { | ||
4112 | if (localId == 0) | ||
4113 | continue; | ||
4114 | |||
4115 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4116 | string data = ""; | ||
4117 | if (obj != null) | ||
4118 | { | ||
4119 | DetectedObject detobj = new DetectedObject(); | ||
4120 | detobj.keyUUID = obj.UUID; | ||
4121 | detobj.nameStr = obj.Name; | ||
4122 | detobj.ownerUUID = obj.OwnerID; | ||
4123 | detobj.posVector = obj.AbsolutePosition; | ||
4124 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4125 | detobj.velVector = obj.Velocity; | ||
4126 | detobj.colliderType = 0; | ||
4127 | detobj.groupUUID = obj.GroupID; | ||
4128 | colliding.Add(detobj); | ||
4129 | } | ||
4130 | } | ||
4131 | |||
4132 | if (colliding.Count > 0) | ||
4133 | { | ||
4134 | StartCollidingMessage.Colliders = colliding; | ||
4135 | |||
4136 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4137 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
4138 | } | ||
4139 | } | ||
4140 | |||
4141 | if (endedColliders.Count > 0) | ||
4142 | { | ||
4143 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
4144 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4145 | foreach (uint localId in endedColliders) | ||
4146 | { | ||
4147 | if (localId == 0) | ||
4148 | continue; | ||
4149 | |||
4150 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4151 | string data = ""; | ||
4152 | if (obj != null) | ||
4153 | { | ||
4154 | DetectedObject detobj = new DetectedObject(); | ||
4155 | detobj.keyUUID = obj.UUID; | ||
4156 | detobj.nameStr = obj.Name; | ||
4157 | detobj.ownerUUID = obj.OwnerID; | ||
4158 | detobj.posVector = obj.AbsolutePosition; | ||
4159 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4160 | detobj.velVector = obj.Velocity; | ||
4161 | detobj.colliderType = 0; | ||
4162 | detobj.groupUUID = obj.GroupID; | ||
4163 | colliding.Add(detobj); | ||
4164 | } | ||
4165 | } | ||
4166 | |||
4167 | if (colliding.Count > 0) | ||
4168 | { | ||
4169 | EndCollidingMessage.Colliders = colliding; | ||
4170 | |||
4171 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4172 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
4173 | } | ||
4174 | } | ||
4175 | |||
4176 | if (thisHitColliders.Count > 0) | ||
4177 | { | ||
4178 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
4179 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4180 | foreach (uint localId in thisHitColliders) | ||
4181 | { | ||
4182 | if (localId == 0) | ||
4183 | continue; | ||
4184 | |||
4185 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4186 | string data = ""; | ||
4187 | if (obj != null) | ||
4188 | { | ||
4189 | DetectedObject detobj = new DetectedObject(); | ||
4190 | detobj.keyUUID = obj.UUID; | ||
4191 | detobj.nameStr = obj.Name; | ||
4192 | detobj.ownerUUID = obj.OwnerID; | ||
4193 | detobj.posVector = obj.AbsolutePosition; | ||
4194 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4195 | detobj.velVector = obj.Velocity; | ||
4196 | detobj.colliderType = 0; | ||
4197 | detobj.groupUUID = obj.GroupID; | ||
4198 | colliding.Add(detobj); | ||
4199 | } | ||
4200 | } | ||
4201 | |||
4202 | if (colliding.Count > 0) | ||
4203 | { | ||
4204 | CollidingMessage.Colliders = colliding; | ||
4205 | |||
4206 | lock (m_attachments) | ||
4207 | { | ||
4208 | foreach (SceneObjectGroup att in m_attachments) | ||
4209 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4210 | } | ||
4211 | } | ||
4212 | } | ||
4213 | } | ||
4214 | finally | ||
4215 | { | ||
4216 | m_collisionEventFlag = false; | ||
4217 | } | ||
4218 | }); | ||
4219 | } | ||
4220 | |||
3939 | private void TeleportFlagsDebug() { | 4221 | private void TeleportFlagsDebug() { |
3940 | 4222 | ||
3941 | // Some temporary debugging help to show all the TeleportFlags we have... | 4223 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -3960,6 +4242,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
3960 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4242 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
3961 | 4243 | ||
3962 | } | 4244 | } |
3963 | |||
3964 | } | 4245 | } |
3965 | } | 4246 | } |