diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 420 |
1 files changed, 345 insertions, 75 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cf60c69..a23dc31 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -91,7 +91,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
91 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 91 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
92 | /// issue #1716 | 92 | /// issue #1716 |
93 | /// </summary> | 93 | /// </summary> |
94 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 94 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
95 | 95 | ||
96 | /// <summary> | 96 | /// <summary> |
97 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 97 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -168,6 +168,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 168 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
169 | // private int m_updateCount = 0; //KF: Update Anims for a while | 169 | // private int m_updateCount = 0; //KF: Update Anims for a while |
170 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 170 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
171 | private List<uint> m_lastColliders = new List<uint>(); | ||
171 | 172 | ||
172 | private TeleportFlags m_teleportFlags; | 173 | private TeleportFlags m_teleportFlags; |
173 | public TeleportFlags TeleportFlags | 174 | public TeleportFlags TeleportFlags |
@@ -229,6 +230,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
229 | //private int m_moveToPositionStateStatus; | 230 | //private int m_moveToPositionStateStatus; |
230 | //***************************************************** | 231 | //***************************************************** |
231 | 232 | ||
233 | private bool m_collisionEventFlag = false; | ||
234 | private object m_collisionEventLock = new Object(); | ||
235 | |||
236 | private int m_movementAnimationUpdateCounter = 0; | ||
237 | |||
238 | private Vector3 m_prevSitOffset; | ||
239 | |||
232 | protected AvatarAppearance m_appearance; | 240 | protected AvatarAppearance m_appearance; |
233 | 241 | ||
234 | public AvatarAppearance Appearance | 242 | public AvatarAppearance Appearance |
@@ -568,6 +576,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
568 | /// </summary> | 576 | /// </summary> |
569 | public uint ParentID { get; set; } | 577 | public uint ParentID { get; set; } |
570 | 578 | ||
579 | public UUID ParentUUID | ||
580 | { | ||
581 | get { return m_parentUUID; } | ||
582 | set { m_parentUUID = value; } | ||
583 | } | ||
584 | private UUID m_parentUUID = UUID.Zero; | ||
585 | |||
571 | /// <summary> | 586 | /// <summary> |
572 | /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. | 587 | /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. |
573 | /// </summary> | 588 | /// </summary> |
@@ -728,6 +743,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
728 | Appearance = appearance; | 743 | Appearance = appearance; |
729 | } | 744 | } |
730 | 745 | ||
746 | private void RegionHeartbeatEnd(Scene scene) | ||
747 | { | ||
748 | if (IsChildAgent) | ||
749 | return; | ||
750 | |||
751 | m_movementAnimationUpdateCounter ++; | ||
752 | if (m_movementAnimationUpdateCounter >= 2) | ||
753 | { | ||
754 | m_movementAnimationUpdateCounter = 0; | ||
755 | if (Animator != null) | ||
756 | { | ||
757 | Animator.UpdateMovementAnimations(); | ||
758 | } | ||
759 | else | ||
760 | { | ||
761 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
762 | } | ||
763 | } | ||
764 | } | ||
765 | |||
731 | public void RegisterToEvents() | 766 | public void RegisterToEvents() |
732 | { | 767 | { |
733 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 768 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -797,10 +832,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
797 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 832 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
798 | Name, m_scene.RegionInfo.RegionName); | 833 | Name, m_scene.RegionInfo.RegionName); |
799 | 834 | ||
800 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
801 | |||
802 | bool wasChild = IsChildAgent; | 835 | bool wasChild = IsChildAgent; |
803 | IsChildAgent = false; | 836 | |
837 | if (ParentUUID != UUID.Zero) | ||
838 | { | ||
839 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
840 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
841 | if (part == null) | ||
842 | { | ||
843 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
844 | } | ||
845 | else | ||
846 | { | ||
847 | part.ParentGroup.AddAvatar(UUID); | ||
848 | if (part.SitTargetPosition != Vector3.Zero) | ||
849 | part.SitTargetAvatar = UUID; | ||
850 | ParentPosition = part.GetWorldPosition(); | ||
851 | ParentID = part.LocalId; | ||
852 | ParentPart = part; | ||
853 | m_pos = m_prevSitOffset; | ||
854 | pos = ParentPosition; | ||
855 | } | ||
856 | ParentUUID = UUID.Zero; | ||
857 | |||
858 | IsChildAgent = false; | ||
859 | |||
860 | Animator.TrySetMovementAnimation("SIT"); | ||
861 | } | ||
862 | else | ||
863 | { | ||
864 | IsChildAgent = false; | ||
865 | } | ||
866 | |||
804 | 867 | ||
805 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 868 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
806 | if (gm != null) | 869 | if (gm != null) |
@@ -810,62 +873,64 @@ namespace OpenSim.Region.Framework.Scenes | |||
810 | 873 | ||
811 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 874 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
812 | 875 | ||
813 | // Moved this from SendInitialData to ensure that Appearance is initialized | 876 | if (ParentID == 0) |
814 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | ||
815 | // related to the handling of attachments | ||
816 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
817 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
818 | { | 877 | { |
819 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 878 | // Moved this from SendInitialData to ensure that Appearance is initialized |
820 | pos.X = crossedBorder.BorderLine.Z - 1; | 879 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
821 | } | 880 | // related to the handling of attachments |
881 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
882 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
883 | { | ||
884 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
885 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
886 | } | ||
822 | 887 | ||
823 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 888 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
824 | { | 889 | { |
825 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 890 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
826 | pos.Y = crossedBorder.BorderLine.Z - 1; | 891 | pos.Y = crossedBorder.BorderLine.Z - 1; |
827 | } | 892 | } |
828 | 893 | ||
829 | CheckAndAdjustLandingPoint(ref pos); | 894 | CheckAndAdjustLandingPoint(ref pos); |
830 | 895 | ||
831 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 896 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
832 | { | 897 | { |
833 | m_log.WarnFormat( | 898 | m_log.WarnFormat( |
834 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 899 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
835 | pos, Name, UUID); | 900 | pos, Name, UUID); |
836 | 901 | ||
837 | if (pos.X < 0f) pos.X = 0f; | 902 | if (pos.X < 0f) pos.X = 0f; |
838 | if (pos.Y < 0f) pos.Y = 0f; | 903 | if (pos.Y < 0f) pos.Y = 0f; |
839 | if (pos.Z < 0f) pos.Z = 0f; | 904 | if (pos.Z < 0f) pos.Z = 0f; |
840 | } | 905 | } |
841 | 906 | ||
842 | float localAVHeight = 1.56f; | 907 | float localAVHeight = 1.56f; |
843 | if (Appearance.AvatarHeight > 0) | 908 | if (Appearance.AvatarHeight > 0) |
844 | localAVHeight = Appearance.AvatarHeight; | 909 | localAVHeight = Appearance.AvatarHeight; |
845 | 910 | ||
846 | float posZLimit = 0; | 911 | float posZLimit = 0; |
847 | 912 | ||
848 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 913 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
849 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 914 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
850 | 915 | ||
851 | float newPosZ = posZLimit + localAVHeight / 2; | 916 | float newPosZ = posZLimit + localAVHeight / 2; |
852 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 917 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
853 | { | 918 | { |
854 | pos.Z = newPosZ; | 919 | pos.Z = newPosZ; |
855 | } | 920 | } |
856 | AbsolutePosition = pos; | 921 | AbsolutePosition = pos; |
857 | 922 | ||
858 | AddToPhysicalScene(isFlying); | 923 | AddToPhysicalScene(isFlying); |
859 | 924 | ||
860 | if (ForceFly) | 925 | if (ForceFly) |
861 | { | 926 | { |
862 | Flying = true; | 927 | Flying = true; |
863 | } | 928 | } |
864 | else if (FlyDisabled) | 929 | else if (FlyDisabled) |
865 | { | 930 | { |
866 | Flying = false; | 931 | Flying = false; |
932 | } | ||
867 | } | 933 | } |
868 | |||
869 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 934 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
870 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 935 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
871 | // elsewhere anyway | 936 | // elsewhere anyway |
@@ -883,14 +948,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
883 | { | 948 | { |
884 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); | 949 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); |
885 | // Resume scripts | 950 | // Resume scripts |
886 | foreach (SceneObjectGroup sog in m_attachments) | 951 | Util.FireAndForget(delegate(object x) { |
887 | { | 952 | foreach (SceneObjectGroup sog in m_attachments) |
888 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 953 | { |
889 | sog.ResumeScripts(); | 954 | sog.ScheduleGroupForFullUpdate(); |
890 | } | 955 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
956 | sog.ResumeScripts(); | ||
957 | } | ||
958 | }); | ||
891 | } | 959 | } |
892 | } | 960 | } |
893 | 961 | ||
962 | SendAvatarDataToAllAgents(); | ||
963 | |||
894 | // send the animations of the other presences to me | 964 | // send the animations of the other presences to me |
895 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 965 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
896 | { | 966 | { |
@@ -904,6 +974,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
904 | MovementFlag = 0; | 974 | MovementFlag = 0; |
905 | 975 | ||
906 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 976 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
977 | |||
978 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
907 | } | 979 | } |
908 | 980 | ||
909 | public int GetStateSource() | 981 | public int GetStateSource() |
@@ -931,6 +1003,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
931 | /// </remarks> | 1003 | /// </remarks> |
932 | public void MakeChildAgent() | 1004 | public void MakeChildAgent() |
933 | { | 1005 | { |
1006 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1007 | |||
934 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1008 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
935 | 1009 | ||
936 | // Reset these so that teleporting in and walking out isn't seen | 1010 | // Reset these so that teleporting in and walking out isn't seen |
@@ -1687,9 +1761,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1687 | if (pos.Z - terrainHeight < 0.2) | 1761 | if (pos.Z - terrainHeight < 0.2) |
1688 | pos.Z = terrainHeight; | 1762 | pos.Z = terrainHeight; |
1689 | 1763 | ||
1690 | m_log.DebugFormat( | 1764 | // m_log.DebugFormat( |
1691 | "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", | 1765 | // "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", |
1692 | Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); | 1766 | // Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); |
1693 | 1767 | ||
1694 | if (noFly) | 1768 | if (noFly) |
1695 | Flying = false; | 1769 | Flying = false; |
@@ -1746,8 +1820,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1746 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1820 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1747 | 1821 | ||
1748 | SitGround = false; | 1822 | SitGround = false; |
1823 | |||
1824 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1749 | if (PhysicsActor == null) | 1825 | if (PhysicsActor == null) |
1750 | AddToPhysicalScene(false); | 1826 | AddToPhysicalScene(false); |
1827 | */ | ||
1751 | 1828 | ||
1752 | if (ParentID != 0) | 1829 | if (ParentID != 0) |
1753 | { | 1830 | { |
@@ -1771,6 +1848,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1771 | if (part.SitTargetAvatar == UUID) | 1848 | if (part.SitTargetAvatar == UUID) |
1772 | part.SitTargetAvatar = UUID.Zero; | 1849 | part.SitTargetAvatar = UUID.Zero; |
1773 | 1850 | ||
1851 | part.ParentGroup.DeleteAvatar(UUID); | ||
1774 | ParentPosition = part.GetWorldPosition(); | 1852 | ParentPosition = part.GetWorldPosition(); |
1775 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1853 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1776 | 1854 | ||
@@ -1779,6 +1857,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1779 | 1857 | ||
1780 | ParentID = 0; | 1858 | ParentID = 0; |
1781 | ParentPart = null; | 1859 | ParentPart = null; |
1860 | |||
1861 | if (PhysicsActor == null) | ||
1862 | AddToPhysicalScene(false); | ||
1863 | |||
1782 | SendAvatarDataToAllAgents(); | 1864 | SendAvatarDataToAllAgents(); |
1783 | m_requestedSitTargetID = 0; | 1865 | m_requestedSitTargetID = 0; |
1784 | 1866 | ||
@@ -1786,6 +1868,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1786 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1868 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1787 | } | 1869 | } |
1788 | 1870 | ||
1871 | else if (PhysicsActor == null) | ||
1872 | AddToPhysicalScene(false); | ||
1873 | |||
1789 | Animator.TrySetMovementAnimation("STAND"); | 1874 | Animator.TrySetMovementAnimation("STAND"); |
1790 | } | 1875 | } |
1791 | 1876 | ||
@@ -1909,7 +1994,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1909 | forceMouselook = part.GetForceMouselook(); | 1994 | forceMouselook = part.GetForceMouselook(); |
1910 | 1995 | ||
1911 | ControllingClient.SendSitResponse( | 1996 | ControllingClient.SendSitResponse( |
1912 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 1997 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1913 | 1998 | ||
1914 | m_requestedSitTargetUUID = targetID; | 1999 | m_requestedSitTargetUUID = targetID; |
1915 | 2000 | ||
@@ -2191,14 +2276,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
2191 | 2276 | ||
2192 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2277 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2193 | 2278 | ||
2194 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2279 | double x, y, z, m; |
2280 | |||
2281 | Quaternion r = sitTargetOrient; | ||
2282 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2283 | |||
2284 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2285 | { | ||
2286 | m = 1.0 / Math.Sqrt(m); | ||
2287 | r.X *= (float)m; | ||
2288 | r.Y *= (float)m; | ||
2289 | r.Z *= (float)m; | ||
2290 | r.W *= (float)m; | ||
2291 | } | ||
2292 | |||
2293 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2294 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2295 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2296 | |||
2297 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2298 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2299 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2195 | Rotation = sitTargetOrient; | 2300 | Rotation = sitTargetOrient; |
2196 | ParentPosition = part.AbsolutePosition; | 2301 | ParentPosition = part.AbsolutePosition; |
2302 | part.ParentGroup.AddAvatar(UUID); | ||
2197 | } | 2303 | } |
2198 | else | 2304 | else |
2199 | { | 2305 | { |
2200 | m_pos -= part.AbsolutePosition; | 2306 | m_pos -= part.AbsolutePosition; |
2201 | ParentPosition = part.AbsolutePosition; | 2307 | ParentPosition = part.AbsolutePosition; |
2308 | part.ParentGroup.AddAvatar(UUID); | ||
2202 | 2309 | ||
2203 | // m_log.DebugFormat( | 2310 | // m_log.DebugFormat( |
2204 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2311 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2296,14 +2403,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2296 | direc.Z *= 2.6f; | 2403 | direc.Z *= 2.6f; |
2297 | 2404 | ||
2298 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2405 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2299 | Animator.TrySetMovementAnimation("PREJUMP"); | 2406 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2300 | Animator.TrySetMovementAnimation("JUMP"); | 2407 | // Animator.TrySetMovementAnimation("JUMP"); |
2301 | } | 2408 | } |
2302 | } | 2409 | } |
2303 | } | 2410 | } |
2304 | 2411 | ||
2305 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2412 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2306 | m_forceToApply = direc; | 2413 | m_forceToApply = direc; |
2414 | Animator.UpdateMovementAnimations(); | ||
2307 | } | 2415 | } |
2308 | 2416 | ||
2309 | #endregion | 2417 | #endregion |
@@ -3037,6 +3145,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3037 | cAgent.AlwaysRun = SetAlwaysRun; | 3145 | cAgent.AlwaysRun = SetAlwaysRun; |
3038 | 3146 | ||
3039 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3147 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3148 | |||
3149 | cAgent.ParentPart = ParentUUID; | ||
3150 | cAgent.SitOffset = m_pos; | ||
3040 | 3151 | ||
3041 | lock (scriptedcontrols) | 3152 | lock (scriptedcontrols) |
3042 | { | 3153 | { |
@@ -3096,6 +3207,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3096 | CameraAtAxis = cAgent.AtAxis; | 3207 | CameraAtAxis = cAgent.AtAxis; |
3097 | CameraLeftAxis = cAgent.LeftAxis; | 3208 | CameraLeftAxis = cAgent.LeftAxis; |
3098 | CameraUpAxis = cAgent.UpAxis; | 3209 | CameraUpAxis = cAgent.UpAxis; |
3210 | ParentUUID = cAgent.ParentPart; | ||
3211 | m_prevSitOffset = cAgent.SitOffset; | ||
3099 | 3212 | ||
3100 | // When we get to the point of re-computing neighbors everytime this | 3213 | // When we get to the point of re-computing neighbors everytime this |
3101 | // changes, then start using the agent's drawdistance rather than the | 3214 | // changes, then start using the agent's drawdistance rather than the |
@@ -3248,18 +3361,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3248 | if (IsChildAgent) | 3361 | if (IsChildAgent) |
3249 | return; | 3362 | return; |
3250 | 3363 | ||
3251 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | ||
3252 | // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( | ||
3253 | // as of this comment the interval is set in AddToPhysicalScene | ||
3254 | if (Animator != null) | ||
3255 | { | ||
3256 | // if (m_updateCount > 0) | ||
3257 | // { | ||
3258 | Animator.UpdateMovementAnimations(); | ||
3259 | // m_updateCount--; | ||
3260 | // } | ||
3261 | } | ||
3262 | |||
3263 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3364 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3264 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3365 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3265 | 3366 | ||
@@ -3302,6 +3403,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3302 | } | 3403 | } |
3303 | } | 3404 | } |
3304 | 3405 | ||
3406 | RaiseCollisionScriptEvents(coldata); | ||
3407 | |||
3305 | if (Invulnerable) | 3408 | if (Invulnerable) |
3306 | return; | 3409 | return; |
3307 | 3410 | ||
@@ -3813,6 +3916,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3813 | 3916 | ||
3814 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 3917 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3815 | { | 3918 | { |
3919 | string reason; | ||
3920 | |||
3921 | // Honor bans | ||
3922 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
3923 | return; | ||
3924 | |||
3816 | SceneObjectGroup telehub = null; | 3925 | SceneObjectGroup telehub = null; |
3817 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 3926 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
3818 | { | 3927 | { |
@@ -3852,11 +3961,173 @@ namespace OpenSim.Region.Framework.Scenes | |||
3852 | pos = land.LandData.UserLocation; | 3961 | pos = land.LandData.UserLocation; |
3853 | } | 3962 | } |
3854 | } | 3963 | } |
3855 | 3964 | ||
3856 | land.SendLandUpdateToClient(ControllingClient); | 3965 | land.SendLandUpdateToClient(ControllingClient); |
3857 | } | 3966 | } |
3858 | } | 3967 | } |
3859 | 3968 | ||
3969 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
3970 | { | ||
3971 | lock(m_collisionEventLock) | ||
3972 | { | ||
3973 | if (m_collisionEventFlag) | ||
3974 | return; | ||
3975 | m_collisionEventFlag = true; | ||
3976 | } | ||
3977 | |||
3978 | Util.FireAndForget(delegate(object x) | ||
3979 | { | ||
3980 | try | ||
3981 | { | ||
3982 | List<uint> thisHitColliders = new List<uint>(); | ||
3983 | List<uint> endedColliders = new List<uint>(); | ||
3984 | List<uint> startedColliders = new List<uint>(); | ||
3985 | |||
3986 | foreach (uint localid in coldata.Keys) | ||
3987 | { | ||
3988 | thisHitColliders.Add(localid); | ||
3989 | if (!m_lastColliders.Contains(localid)) | ||
3990 | { | ||
3991 | startedColliders.Add(localid); | ||
3992 | } | ||
3993 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3994 | } | ||
3995 | |||
3996 | // calculate things that ended colliding | ||
3997 | foreach (uint localID in m_lastColliders) | ||
3998 | { | ||
3999 | if (!thisHitColliders.Contains(localID)) | ||
4000 | { | ||
4001 | endedColliders.Add(localID); | ||
4002 | } | ||
4003 | } | ||
4004 | //add the items that started colliding this time to the last colliders list. | ||
4005 | foreach (uint localID in startedColliders) | ||
4006 | { | ||
4007 | m_lastColliders.Add(localID); | ||
4008 | } | ||
4009 | // remove things that ended colliding from the last colliders list | ||
4010 | foreach (uint localID in endedColliders) | ||
4011 | { | ||
4012 | m_lastColliders.Remove(localID); | ||
4013 | } | ||
4014 | |||
4015 | // do event notification | ||
4016 | if (startedColliders.Count > 0) | ||
4017 | { | ||
4018 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
4019 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4020 | foreach (uint localId in startedColliders) | ||
4021 | { | ||
4022 | if (localId == 0) | ||
4023 | continue; | ||
4024 | |||
4025 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4026 | string data = ""; | ||
4027 | if (obj != null) | ||
4028 | { | ||
4029 | DetectedObject detobj = new DetectedObject(); | ||
4030 | detobj.keyUUID = obj.UUID; | ||
4031 | detobj.nameStr = obj.Name; | ||
4032 | detobj.ownerUUID = obj.OwnerID; | ||
4033 | detobj.posVector = obj.AbsolutePosition; | ||
4034 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4035 | detobj.velVector = obj.Velocity; | ||
4036 | detobj.colliderType = 0; | ||
4037 | detobj.groupUUID = obj.GroupID; | ||
4038 | colliding.Add(detobj); | ||
4039 | } | ||
4040 | } | ||
4041 | |||
4042 | if (colliding.Count > 0) | ||
4043 | { | ||
4044 | StartCollidingMessage.Colliders = colliding; | ||
4045 | |||
4046 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4047 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
4048 | } | ||
4049 | } | ||
4050 | |||
4051 | if (endedColliders.Count > 0) | ||
4052 | { | ||
4053 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
4054 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4055 | foreach (uint localId in endedColliders) | ||
4056 | { | ||
4057 | if (localId == 0) | ||
4058 | continue; | ||
4059 | |||
4060 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4061 | string data = ""; | ||
4062 | if (obj != null) | ||
4063 | { | ||
4064 | DetectedObject detobj = new DetectedObject(); | ||
4065 | detobj.keyUUID = obj.UUID; | ||
4066 | detobj.nameStr = obj.Name; | ||
4067 | detobj.ownerUUID = obj.OwnerID; | ||
4068 | detobj.posVector = obj.AbsolutePosition; | ||
4069 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4070 | detobj.velVector = obj.Velocity; | ||
4071 | detobj.colliderType = 0; | ||
4072 | detobj.groupUUID = obj.GroupID; | ||
4073 | colliding.Add(detobj); | ||
4074 | } | ||
4075 | } | ||
4076 | |||
4077 | if (colliding.Count > 0) | ||
4078 | { | ||
4079 | EndCollidingMessage.Colliders = colliding; | ||
4080 | |||
4081 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4082 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
4083 | } | ||
4084 | } | ||
4085 | |||
4086 | if (thisHitColliders.Count > 0) | ||
4087 | { | ||
4088 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
4089 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4090 | foreach (uint localId in thisHitColliders) | ||
4091 | { | ||
4092 | if (localId == 0) | ||
4093 | continue; | ||
4094 | |||
4095 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4096 | string data = ""; | ||
4097 | if (obj != null) | ||
4098 | { | ||
4099 | DetectedObject detobj = new DetectedObject(); | ||
4100 | detobj.keyUUID = obj.UUID; | ||
4101 | detobj.nameStr = obj.Name; | ||
4102 | detobj.ownerUUID = obj.OwnerID; | ||
4103 | detobj.posVector = obj.AbsolutePosition; | ||
4104 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4105 | detobj.velVector = obj.Velocity; | ||
4106 | detobj.colliderType = 0; | ||
4107 | detobj.groupUUID = obj.GroupID; | ||
4108 | colliding.Add(detobj); | ||
4109 | } | ||
4110 | } | ||
4111 | |||
4112 | if (colliding.Count > 0) | ||
4113 | { | ||
4114 | CollidingMessage.Colliders = colliding; | ||
4115 | |||
4116 | lock (m_attachments) | ||
4117 | { | ||
4118 | foreach (SceneObjectGroup att in m_attachments) | ||
4119 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4120 | } | ||
4121 | } | ||
4122 | } | ||
4123 | } | ||
4124 | finally | ||
4125 | { | ||
4126 | m_collisionEventFlag = false; | ||
4127 | } | ||
4128 | }); | ||
4129 | } | ||
4130 | |||
3860 | private void TeleportFlagsDebug() { | 4131 | private void TeleportFlagsDebug() { |
3861 | 4132 | ||
3862 | // Some temporary debugging help to show all the TeleportFlags we have... | 4133 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -3881,6 +4152,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
3881 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4152 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
3882 | 4153 | ||
3883 | } | 4154 | } |
3884 | |||
3885 | } | 4155 | } |
3886 | } | 4156 | } |