diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 376 |
1 files changed, 315 insertions, 61 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ec6bb89..2efb0d2 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,11 @@ 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 Vector3 m_prevSitOffset; | ||
237 | |||
232 | protected AvatarAppearance m_appearance; | 238 | protected AvatarAppearance m_appearance; |
233 | 239 | ||
234 | public AvatarAppearance Appearance | 240 | public AvatarAppearance Appearance |
@@ -576,6 +582,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
576 | } | 582 | } |
577 | private uint m_parentID; | 583 | private uint m_parentID; |
578 | 584 | ||
585 | public UUID ParentUUID | ||
586 | { | ||
587 | get { return m_parentUUID; } | ||
588 | set { m_parentUUID = value; } | ||
589 | } | ||
590 | private UUID m_parentUUID = UUID.Zero; | ||
591 | |||
579 | public float Health | 592 | public float Health |
580 | { | 593 | { |
581 | get { return m_health; } | 594 | get { return m_health; } |
@@ -797,10 +810,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
797 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 810 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
798 | Name, m_scene.RegionInfo.RegionName); | 811 | Name, m_scene.RegionInfo.RegionName); |
799 | 812 | ||
800 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
801 | |||
802 | bool wasChild = IsChildAgent; | 813 | bool wasChild = IsChildAgent; |
803 | IsChildAgent = false; | 814 | |
815 | if (ParentUUID != UUID.Zero) | ||
816 | { | ||
817 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
818 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
819 | if (part == null) | ||
820 | { | ||
821 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
822 | } | ||
823 | else | ||
824 | { | ||
825 | part.ParentGroup.AddAvatar(UUID); | ||
826 | if (part.SitTargetPosition != Vector3.Zero) | ||
827 | part.SitTargetAvatar = UUID; | ||
828 | ParentPosition = part.GetWorldPosition(); | ||
829 | ParentID = part.LocalId; | ||
830 | m_pos = m_prevSitOffset; | ||
831 | pos = ParentPosition; | ||
832 | } | ||
833 | ParentUUID = UUID.Zero; | ||
834 | |||
835 | IsChildAgent = false; | ||
836 | |||
837 | Animator.TrySetMovementAnimation("SIT"); | ||
838 | } | ||
839 | else | ||
840 | { | ||
841 | IsChildAgent = false; | ||
842 | } | ||
843 | |||
804 | 844 | ||
805 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 845 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
806 | if (gm != null) | 846 | if (gm != null) |
@@ -810,62 +850,64 @@ namespace OpenSim.Region.Framework.Scenes | |||
810 | 850 | ||
811 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 851 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
812 | 852 | ||
813 | // Moved this from SendInitialData to ensure that Appearance is initialized | 853 | 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 | { | 854 | { |
819 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 855 | // Moved this from SendInitialData to ensure that Appearance is initialized |
820 | pos.X = crossedBorder.BorderLine.Z - 1; | 856 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
821 | } | 857 | // related to the handling of attachments |
858 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
859 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
860 | { | ||
861 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
862 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
863 | } | ||
822 | 864 | ||
823 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 865 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
824 | { | 866 | { |
825 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 867 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
826 | pos.Y = crossedBorder.BorderLine.Z - 1; | 868 | pos.Y = crossedBorder.BorderLine.Z - 1; |
827 | } | 869 | } |
828 | 870 | ||
829 | CheckAndAdjustLandingPoint(ref pos); | 871 | CheckAndAdjustLandingPoint(ref pos); |
830 | 872 | ||
831 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 873 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
832 | { | 874 | { |
833 | m_log.WarnFormat( | 875 | m_log.WarnFormat( |
834 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 876 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
835 | pos, Name, UUID); | 877 | pos, Name, UUID); |
836 | 878 | ||
837 | if (pos.X < 0f) pos.X = 0f; | 879 | if (pos.X < 0f) pos.X = 0f; |
838 | if (pos.Y < 0f) pos.Y = 0f; | 880 | if (pos.Y < 0f) pos.Y = 0f; |
839 | if (pos.Z < 0f) pos.Z = 0f; | 881 | if (pos.Z < 0f) pos.Z = 0f; |
840 | } | 882 | } |
841 | 883 | ||
842 | float localAVHeight = 1.56f; | 884 | float localAVHeight = 1.56f; |
843 | if (Appearance.AvatarHeight > 0) | 885 | if (Appearance.AvatarHeight > 0) |
844 | localAVHeight = Appearance.AvatarHeight; | 886 | localAVHeight = Appearance.AvatarHeight; |
845 | 887 | ||
846 | float posZLimit = 0; | 888 | float posZLimit = 0; |
847 | 889 | ||
848 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 890 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
849 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 891 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
850 | 892 | ||
851 | float newPosZ = posZLimit + localAVHeight / 2; | 893 | float newPosZ = posZLimit + localAVHeight / 2; |
852 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 894 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
853 | { | 895 | { |
854 | pos.Z = newPosZ; | 896 | pos.Z = newPosZ; |
855 | } | 897 | } |
856 | AbsolutePosition = pos; | 898 | AbsolutePosition = pos; |
857 | 899 | ||
858 | AddToPhysicalScene(isFlying); | 900 | AddToPhysicalScene(isFlying); |
859 | 901 | ||
860 | if (ForceFly) | 902 | if (ForceFly) |
861 | { | 903 | { |
862 | Flying = true; | 904 | Flying = true; |
863 | } | 905 | } |
864 | else if (FlyDisabled) | 906 | else if (FlyDisabled) |
865 | { | 907 | { |
866 | Flying = false; | 908 | Flying = false; |
909 | } | ||
867 | } | 910 | } |
868 | |||
869 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 911 | // 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 | 912 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
871 | // elsewhere anyway | 913 | // elsewhere anyway |
@@ -883,14 +925,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
883 | { | 925 | { |
884 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); | 926 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); |
885 | // Resume scripts | 927 | // Resume scripts |
886 | foreach (SceneObjectGroup sog in m_attachments) | 928 | Util.FireAndForget(delegate(object x) { |
887 | { | 929 | foreach (SceneObjectGroup sog in m_attachments) |
888 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 930 | { |
889 | sog.ResumeScripts(); | 931 | sog.ScheduleGroupForFullUpdate(); |
890 | } | 932 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
933 | sog.ResumeScripts(); | ||
934 | } | ||
935 | }); | ||
891 | } | 936 | } |
892 | } | 937 | } |
893 | 938 | ||
939 | SendAvatarDataToAllAgents(); | ||
940 | |||
894 | // send the animations of the other presences to me | 941 | // send the animations of the other presences to me |
895 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 942 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
896 | { | 943 | { |
@@ -1687,9 +1734,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1687 | if (pos.Z - terrainHeight < 0.2) | 1734 | if (pos.Z - terrainHeight < 0.2) |
1688 | pos.Z = terrainHeight; | 1735 | pos.Z = terrainHeight; |
1689 | 1736 | ||
1690 | m_log.DebugFormat( | 1737 | // m_log.DebugFormat( |
1691 | "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", | 1738 | // "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", |
1692 | Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); | 1739 | // Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); |
1693 | 1740 | ||
1694 | if (noFly) | 1741 | if (noFly) |
1695 | Flying = false; | 1742 | Flying = false; |
@@ -1746,8 +1793,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1746 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1793 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1747 | 1794 | ||
1748 | SitGround = false; | 1795 | SitGround = false; |
1796 | |||
1797 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1749 | if (PhysicsActor == null) | 1798 | if (PhysicsActor == null) |
1750 | AddToPhysicalScene(false); | 1799 | AddToPhysicalScene(false); |
1800 | */ | ||
1751 | 1801 | ||
1752 | if (ParentID != 0) | 1802 | if (ParentID != 0) |
1753 | { | 1803 | { |
@@ -1773,6 +1823,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1773 | if (part.SitTargetAvatar == UUID) | 1823 | if (part.SitTargetAvatar == UUID) |
1774 | part.SitTargetAvatar = UUID.Zero; | 1824 | part.SitTargetAvatar = UUID.Zero; |
1775 | 1825 | ||
1826 | part.ParentGroup.DeleteAvatar(UUID); | ||
1776 | ParentPosition = part.GetWorldPosition(); | 1827 | ParentPosition = part.GetWorldPosition(); |
1777 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1828 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1778 | } | 1829 | } |
@@ -1781,6 +1832,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1781 | ParentPosition = Vector3.Zero; | 1832 | ParentPosition = Vector3.Zero; |
1782 | 1833 | ||
1783 | ParentID = 0; | 1834 | ParentID = 0; |
1835 | |||
1836 | if (PhysicsActor == null) | ||
1837 | AddToPhysicalScene(false); | ||
1838 | |||
1784 | SendAvatarDataToAllAgents(); | 1839 | SendAvatarDataToAllAgents(); |
1785 | m_requestedSitTargetID = 0; | 1840 | m_requestedSitTargetID = 0; |
1786 | 1841 | ||
@@ -1788,6 +1843,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1788 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1843 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1789 | } | 1844 | } |
1790 | 1845 | ||
1846 | else if (PhysicsActor == null) | ||
1847 | AddToPhysicalScene(false); | ||
1848 | |||
1791 | Animator.TrySetMovementAnimation("STAND"); | 1849 | Animator.TrySetMovementAnimation("STAND"); |
1792 | } | 1850 | } |
1793 | 1851 | ||
@@ -1911,7 +1969,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1911 | forceMouselook = part.GetForceMouselook(); | 1969 | forceMouselook = part.GetForceMouselook(); |
1912 | 1970 | ||
1913 | ControllingClient.SendSitResponse( | 1971 | ControllingClient.SendSitResponse( |
1914 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 1972 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1915 | 1973 | ||
1916 | m_requestedSitTargetUUID = targetID; | 1974 | m_requestedSitTargetUUID = targetID; |
1917 | 1975 | ||
@@ -2193,14 +2251,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
2193 | 2251 | ||
2194 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2252 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2195 | 2253 | ||
2196 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2254 | double x, y, z, m; |
2255 | |||
2256 | Quaternion r = sitTargetOrient; | ||
2257 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2258 | |||
2259 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2260 | { | ||
2261 | m = 1.0 / Math.Sqrt(m); | ||
2262 | r.X *= (float)m; | ||
2263 | r.Y *= (float)m; | ||
2264 | r.Z *= (float)m; | ||
2265 | r.W *= (float)m; | ||
2266 | } | ||
2267 | |||
2268 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2269 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2270 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2271 | |||
2272 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2273 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2274 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2197 | Rotation = sitTargetOrient; | 2275 | Rotation = sitTargetOrient; |
2198 | ParentPosition = part.AbsolutePosition; | 2276 | ParentPosition = part.AbsolutePosition; |
2277 | part.ParentGroup.AddAvatar(UUID); | ||
2199 | } | 2278 | } |
2200 | else | 2279 | else |
2201 | { | 2280 | { |
2202 | m_pos -= part.AbsolutePosition; | 2281 | m_pos -= part.AbsolutePosition; |
2203 | ParentPosition = part.AbsolutePosition; | 2282 | ParentPosition = part.AbsolutePosition; |
2283 | part.ParentGroup.AddAvatar(UUID); | ||
2204 | 2284 | ||
2205 | // m_log.DebugFormat( | 2285 | // m_log.DebugFormat( |
2206 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2286 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -3042,6 +3122,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3042 | cAgent.AlwaysRun = SetAlwaysRun; | 3122 | cAgent.AlwaysRun = SetAlwaysRun; |
3043 | 3123 | ||
3044 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3124 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3125 | |||
3126 | cAgent.ParentPart = ParentUUID; | ||
3127 | cAgent.SitOffset = m_pos; | ||
3045 | 3128 | ||
3046 | lock (scriptedcontrols) | 3129 | lock (scriptedcontrols) |
3047 | { | 3130 | { |
@@ -3101,6 +3184,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3101 | CameraAtAxis = cAgent.AtAxis; | 3184 | CameraAtAxis = cAgent.AtAxis; |
3102 | CameraLeftAxis = cAgent.LeftAxis; | 3185 | CameraLeftAxis = cAgent.LeftAxis; |
3103 | CameraUpAxis = cAgent.UpAxis; | 3186 | CameraUpAxis = cAgent.UpAxis; |
3187 | ParentUUID = cAgent.ParentPart; | ||
3188 | m_prevSitOffset = cAgent.SitOffset; | ||
3104 | 3189 | ||
3105 | // When we get to the point of re-computing neighbors everytime this | 3190 | // When we get to the point of re-computing neighbors everytime this |
3106 | // changes, then start using the agent's drawdistance rather than the | 3191 | // changes, then start using the agent's drawdistance rather than the |
@@ -3307,6 +3392,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3307 | } | 3392 | } |
3308 | } | 3393 | } |
3309 | 3394 | ||
3395 | RaiseCollisionScriptEvents(coldata); | ||
3396 | |||
3310 | if (Invulnerable) | 3397 | if (Invulnerable) |
3311 | return; | 3398 | return; |
3312 | 3399 | ||
@@ -3818,6 +3905,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3818 | 3905 | ||
3819 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 3906 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3820 | { | 3907 | { |
3908 | string reason; | ||
3909 | |||
3910 | // Honor bans | ||
3911 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
3912 | return; | ||
3913 | |||
3821 | SceneObjectGroup telehub = null; | 3914 | SceneObjectGroup telehub = null; |
3822 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 3915 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
3823 | { | 3916 | { |
@@ -3857,11 +3950,173 @@ namespace OpenSim.Region.Framework.Scenes | |||
3857 | pos = land.LandData.UserLocation; | 3950 | pos = land.LandData.UserLocation; |
3858 | } | 3951 | } |
3859 | } | 3952 | } |
3860 | 3953 | ||
3861 | land.SendLandUpdateToClient(ControllingClient); | 3954 | land.SendLandUpdateToClient(ControllingClient); |
3862 | } | 3955 | } |
3863 | } | 3956 | } |
3864 | 3957 | ||
3958 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
3959 | { | ||
3960 | lock(m_collisionEventLock) | ||
3961 | { | ||
3962 | if (m_collisionEventFlag) | ||
3963 | return; | ||
3964 | m_collisionEventFlag = true; | ||
3965 | } | ||
3966 | |||
3967 | Util.FireAndForget(delegate(object x) | ||
3968 | { | ||
3969 | try | ||
3970 | { | ||
3971 | List<uint> thisHitColliders = new List<uint>(); | ||
3972 | List<uint> endedColliders = new List<uint>(); | ||
3973 | List<uint> startedColliders = new List<uint>(); | ||
3974 | |||
3975 | foreach (uint localid in coldata.Keys) | ||
3976 | { | ||
3977 | thisHitColliders.Add(localid); | ||
3978 | if (!m_lastColliders.Contains(localid)) | ||
3979 | { | ||
3980 | startedColliders.Add(localid); | ||
3981 | } | ||
3982 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3983 | } | ||
3984 | |||
3985 | // calculate things that ended colliding | ||
3986 | foreach (uint localID in m_lastColliders) | ||
3987 | { | ||
3988 | if (!thisHitColliders.Contains(localID)) | ||
3989 | { | ||
3990 | endedColliders.Add(localID); | ||
3991 | } | ||
3992 | } | ||
3993 | //add the items that started colliding this time to the last colliders list. | ||
3994 | foreach (uint localID in startedColliders) | ||
3995 | { | ||
3996 | m_lastColliders.Add(localID); | ||
3997 | } | ||
3998 | // remove things that ended colliding from the last colliders list | ||
3999 | foreach (uint localID in endedColliders) | ||
4000 | { | ||
4001 | m_lastColliders.Remove(localID); | ||
4002 | } | ||
4003 | |||
4004 | // do event notification | ||
4005 | if (startedColliders.Count > 0) | ||
4006 | { | ||
4007 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
4008 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4009 | foreach (uint localId in startedColliders) | ||
4010 | { | ||
4011 | if (localId == 0) | ||
4012 | continue; | ||
4013 | |||
4014 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4015 | string data = ""; | ||
4016 | if (obj != null) | ||
4017 | { | ||
4018 | DetectedObject detobj = new DetectedObject(); | ||
4019 | detobj.keyUUID = obj.UUID; | ||
4020 | detobj.nameStr = obj.Name; | ||
4021 | detobj.ownerUUID = obj.OwnerID; | ||
4022 | detobj.posVector = obj.AbsolutePosition; | ||
4023 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4024 | detobj.velVector = obj.Velocity; | ||
4025 | detobj.colliderType = 0; | ||
4026 | detobj.groupUUID = obj.GroupID; | ||
4027 | colliding.Add(detobj); | ||
4028 | } | ||
4029 | } | ||
4030 | |||
4031 | if (colliding.Count > 0) | ||
4032 | { | ||
4033 | StartCollidingMessage.Colliders = colliding; | ||
4034 | |||
4035 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4036 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
4037 | } | ||
4038 | } | ||
4039 | |||
4040 | if (endedColliders.Count > 0) | ||
4041 | { | ||
4042 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
4043 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4044 | foreach (uint localId in endedColliders) | ||
4045 | { | ||
4046 | if (localId == 0) | ||
4047 | continue; | ||
4048 | |||
4049 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4050 | string data = ""; | ||
4051 | if (obj != null) | ||
4052 | { | ||
4053 | DetectedObject detobj = new DetectedObject(); | ||
4054 | detobj.keyUUID = obj.UUID; | ||
4055 | detobj.nameStr = obj.Name; | ||
4056 | detobj.ownerUUID = obj.OwnerID; | ||
4057 | detobj.posVector = obj.AbsolutePosition; | ||
4058 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4059 | detobj.velVector = obj.Velocity; | ||
4060 | detobj.colliderType = 0; | ||
4061 | detobj.groupUUID = obj.GroupID; | ||
4062 | colliding.Add(detobj); | ||
4063 | } | ||
4064 | } | ||
4065 | |||
4066 | if (colliding.Count > 0) | ||
4067 | { | ||
4068 | EndCollidingMessage.Colliders = colliding; | ||
4069 | |||
4070 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4071 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
4072 | } | ||
4073 | } | ||
4074 | |||
4075 | if (thisHitColliders.Count > 0) | ||
4076 | { | ||
4077 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
4078 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4079 | foreach (uint localId in thisHitColliders) | ||
4080 | { | ||
4081 | if (localId == 0) | ||
4082 | continue; | ||
4083 | |||
4084 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4085 | string data = ""; | ||
4086 | if (obj != null) | ||
4087 | { | ||
4088 | DetectedObject detobj = new DetectedObject(); | ||
4089 | detobj.keyUUID = obj.UUID; | ||
4090 | detobj.nameStr = obj.Name; | ||
4091 | detobj.ownerUUID = obj.OwnerID; | ||
4092 | detobj.posVector = obj.AbsolutePosition; | ||
4093 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4094 | detobj.velVector = obj.Velocity; | ||
4095 | detobj.colliderType = 0; | ||
4096 | detobj.groupUUID = obj.GroupID; | ||
4097 | colliding.Add(detobj); | ||
4098 | } | ||
4099 | } | ||
4100 | |||
4101 | if (colliding.Count > 0) | ||
4102 | { | ||
4103 | CollidingMessage.Colliders = colliding; | ||
4104 | |||
4105 | lock (m_attachments) | ||
4106 | { | ||
4107 | foreach (SceneObjectGroup att in m_attachments) | ||
4108 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4109 | } | ||
4110 | } | ||
4111 | } | ||
4112 | } | ||
4113 | finally | ||
4114 | { | ||
4115 | m_collisionEventFlag = false; | ||
4116 | } | ||
4117 | }); | ||
4118 | } | ||
4119 | |||
3865 | private void TeleportFlagsDebug() { | 4120 | private void TeleportFlagsDebug() { |
3866 | 4121 | ||
3867 | // Some temporary debugging help to show all the TeleportFlags we have... | 4122 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -3886,6 +4141,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
3886 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4141 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
3887 | 4142 | ||
3888 | } | 4143 | } |
3889 | |||
3890 | } | 4144 | } |
3891 | } | 4145 | } |