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 40c8d06..26fa6c0 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 |
@@ -640,6 +646,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
640 | } | 646 | } |
641 | private uint m_parentID; | 647 | private uint m_parentID; |
642 | 648 | ||
649 | public UUID ParentUUID | ||
650 | { | ||
651 | get { return m_parentUUID; } | ||
652 | set { m_parentUUID = value; } | ||
653 | } | ||
654 | private UUID m_parentUUID = UUID.Zero; | ||
655 | |||
643 | public float Health | 656 | public float Health |
644 | { | 657 | { |
645 | get { return m_health; } | 658 | get { return m_health; } |
@@ -861,10 +874,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
861 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 874 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
862 | Name, m_scene.RegionInfo.RegionName); | 875 | Name, m_scene.RegionInfo.RegionName); |
863 | 876 | ||
864 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
865 | |||
866 | bool wasChild = IsChildAgent; | 877 | bool wasChild = IsChildAgent; |
867 | IsChildAgent = false; | 878 | |
879 | if (ParentUUID != UUID.Zero) | ||
880 | { | ||
881 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
882 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
883 | if (part == null) | ||
884 | { | ||
885 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
886 | } | ||
887 | else | ||
888 | { | ||
889 | part.ParentGroup.AddAvatar(UUID); | ||
890 | if (part.SitTargetPosition != Vector3.Zero) | ||
891 | part.SitTargetAvatar = UUID; | ||
892 | ParentPosition = part.GetWorldPosition(); | ||
893 | ParentID = part.LocalId; | ||
894 | m_pos = m_prevSitOffset; | ||
895 | pos = ParentPosition; | ||
896 | } | ||
897 | ParentUUID = UUID.Zero; | ||
898 | |||
899 | IsChildAgent = false; | ||
900 | |||
901 | Animator.TrySetMovementAnimation("SIT"); | ||
902 | } | ||
903 | else | ||
904 | { | ||
905 | IsChildAgent = false; | ||
906 | } | ||
907 | |||
868 | 908 | ||
869 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 909 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
870 | if (gm != null) | 910 | if (gm != null) |
@@ -874,62 +914,64 @@ namespace OpenSim.Region.Framework.Scenes | |||
874 | 914 | ||
875 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 915 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
876 | 916 | ||
877 | // Moved this from SendInitialData to ensure that Appearance is initialized | 917 | if (ParentID == 0) |
878 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | ||
879 | // related to the handling of attachments | ||
880 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
881 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
882 | { | 918 | { |
883 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 919 | // Moved this from SendInitialData to ensure that Appearance is initialized |
884 | pos.X = crossedBorder.BorderLine.Z - 1; | 920 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
885 | } | 921 | // related to the handling of attachments |
922 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
923 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
924 | { | ||
925 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
926 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
927 | } | ||
886 | 928 | ||
887 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 929 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
888 | { | 930 | { |
889 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 931 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
890 | pos.Y = crossedBorder.BorderLine.Z - 1; | 932 | pos.Y = crossedBorder.BorderLine.Z - 1; |
891 | } | 933 | } |
892 | 934 | ||
893 | CheckAndAdjustLandingPoint(ref pos); | 935 | CheckAndAdjustLandingPoint(ref pos); |
894 | 936 | ||
895 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 937 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
896 | { | 938 | { |
897 | m_log.WarnFormat( | 939 | m_log.WarnFormat( |
898 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 940 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
899 | pos, Name, UUID); | 941 | pos, Name, UUID); |
900 | 942 | ||
901 | if (pos.X < 0f) pos.X = 0f; | 943 | if (pos.X < 0f) pos.X = 0f; |
902 | if (pos.Y < 0f) pos.Y = 0f; | 944 | if (pos.Y < 0f) pos.Y = 0f; |
903 | if (pos.Z < 0f) pos.Z = 0f; | 945 | if (pos.Z < 0f) pos.Z = 0f; |
904 | } | 946 | } |
905 | 947 | ||
906 | float localAVHeight = 1.56f; | 948 | float localAVHeight = 1.56f; |
907 | if (Appearance.AvatarHeight > 0) | 949 | if (Appearance.AvatarHeight > 0) |
908 | localAVHeight = Appearance.AvatarHeight; | 950 | localAVHeight = Appearance.AvatarHeight; |
909 | 951 | ||
910 | float posZLimit = 0; | 952 | float posZLimit = 0; |
911 | 953 | ||
912 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 954 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
913 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 955 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
914 | 956 | ||
915 | float newPosZ = posZLimit + localAVHeight / 2; | 957 | float newPosZ = posZLimit + localAVHeight / 2; |
916 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 958 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
917 | { | 959 | { |
918 | pos.Z = newPosZ; | 960 | pos.Z = newPosZ; |
919 | } | 961 | } |
920 | AbsolutePosition = pos; | 962 | AbsolutePosition = pos; |
921 | 963 | ||
922 | AddToPhysicalScene(isFlying); | 964 | AddToPhysicalScene(isFlying); |
923 | 965 | ||
924 | if (ForceFly) | 966 | if (ForceFly) |
925 | { | 967 | { |
926 | Flying = true; | 968 | Flying = true; |
927 | } | 969 | } |
928 | else if (FlyDisabled) | 970 | else if (FlyDisabled) |
929 | { | 971 | { |
930 | Flying = false; | 972 | Flying = false; |
973 | } | ||
931 | } | 974 | } |
932 | |||
933 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 975 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
934 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 976 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
935 | // elsewhere anyway | 977 | // elsewhere anyway |
@@ -947,14 +989,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
947 | { | 989 | { |
948 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); | 990 | m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); |
949 | // Resume scripts | 991 | // Resume scripts |
950 | foreach (SceneObjectGroup sog in m_attachments) | 992 | Util.FireAndForget(delegate(object x) { |
951 | { | 993 | foreach (SceneObjectGroup sog in m_attachments) |
952 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 994 | { |
953 | sog.ResumeScripts(); | 995 | sog.ScheduleGroupForFullUpdate(); |
954 | } | 996 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
997 | sog.ResumeScripts(); | ||
998 | } | ||
999 | }); | ||
955 | } | 1000 | } |
956 | } | 1001 | } |
957 | 1002 | ||
1003 | SendAvatarDataToAllAgents(); | ||
1004 | |||
958 | // send the animations of the other presences to me | 1005 | // send the animations of the other presences to me |
959 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 1006 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
960 | { | 1007 | { |
@@ -1751,9 +1798,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1751 | if (pos.Z - terrainHeight < 0.2) | 1798 | if (pos.Z - terrainHeight < 0.2) |
1752 | pos.Z = terrainHeight; | 1799 | pos.Z = terrainHeight; |
1753 | 1800 | ||
1754 | m_log.DebugFormat( | 1801 | // m_log.DebugFormat( |
1755 | "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", | 1802 | // "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", |
1756 | Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); | 1803 | // Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); |
1757 | 1804 | ||
1758 | if (noFly) | 1805 | if (noFly) |
1759 | Flying = false; | 1806 | Flying = false; |
@@ -1810,8 +1857,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1810 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1857 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1811 | 1858 | ||
1812 | SitGround = false; | 1859 | SitGround = false; |
1860 | |||
1861 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1813 | if (PhysicsActor == null) | 1862 | if (PhysicsActor == null) |
1814 | AddToPhysicalScene(false); | 1863 | AddToPhysicalScene(false); |
1864 | */ | ||
1815 | 1865 | ||
1816 | if (ParentID != 0) | 1866 | if (ParentID != 0) |
1817 | { | 1867 | { |
@@ -1837,6 +1887,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1837 | if (part.SitTargetAvatar == UUID) | 1887 | if (part.SitTargetAvatar == UUID) |
1838 | part.SitTargetAvatar = UUID.Zero; | 1888 | part.SitTargetAvatar = UUID.Zero; |
1839 | 1889 | ||
1890 | part.ParentGroup.DeleteAvatar(UUID); | ||
1840 | ParentPosition = part.GetWorldPosition(); | 1891 | ParentPosition = part.GetWorldPosition(); |
1841 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1892 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1842 | } | 1893 | } |
@@ -1845,6 +1896,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1845 | ParentPosition = Vector3.Zero; | 1896 | ParentPosition = Vector3.Zero; |
1846 | 1897 | ||
1847 | ParentID = 0; | 1898 | ParentID = 0; |
1899 | |||
1900 | if (PhysicsActor == null) | ||
1901 | AddToPhysicalScene(false); | ||
1902 | |||
1848 | SendAvatarDataToAllAgents(); | 1903 | SendAvatarDataToAllAgents(); |
1849 | m_requestedSitTargetID = 0; | 1904 | m_requestedSitTargetID = 0; |
1850 | 1905 | ||
@@ -1852,6 +1907,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1852 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1907 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1853 | } | 1908 | } |
1854 | 1909 | ||
1910 | else if (PhysicsActor == null) | ||
1911 | AddToPhysicalScene(false); | ||
1912 | |||
1855 | Animator.TrySetMovementAnimation("STAND"); | 1913 | Animator.TrySetMovementAnimation("STAND"); |
1856 | } | 1914 | } |
1857 | 1915 | ||
@@ -1975,7 +2033,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1975 | forceMouselook = part.GetForceMouselook(); | 2033 | forceMouselook = part.GetForceMouselook(); |
1976 | 2034 | ||
1977 | ControllingClient.SendSitResponse( | 2035 | ControllingClient.SendSitResponse( |
1978 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2036 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1979 | 2037 | ||
1980 | m_requestedSitTargetUUID = targetID; | 2038 | m_requestedSitTargetUUID = targetID; |
1981 | 2039 | ||
@@ -2257,14 +2315,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
2257 | 2315 | ||
2258 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2316 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2259 | 2317 | ||
2260 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2318 | double x, y, z, m; |
2319 | |||
2320 | Quaternion r = sitTargetOrient; | ||
2321 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2322 | |||
2323 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2324 | { | ||
2325 | m = 1.0 / Math.Sqrt(m); | ||
2326 | r.X *= (float)m; | ||
2327 | r.Y *= (float)m; | ||
2328 | r.Z *= (float)m; | ||
2329 | r.W *= (float)m; | ||
2330 | } | ||
2331 | |||
2332 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2333 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2334 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2335 | |||
2336 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2337 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2338 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2261 | Rotation = sitTargetOrient; | 2339 | Rotation = sitTargetOrient; |
2262 | ParentPosition = part.AbsolutePosition; | 2340 | ParentPosition = part.AbsolutePosition; |
2341 | part.ParentGroup.AddAvatar(UUID); | ||
2263 | } | 2342 | } |
2264 | else | 2343 | else |
2265 | { | 2344 | { |
2266 | m_pos -= part.AbsolutePosition; | 2345 | m_pos -= part.AbsolutePosition; |
2267 | ParentPosition = part.AbsolutePosition; | 2346 | ParentPosition = part.AbsolutePosition; |
2347 | part.ParentGroup.AddAvatar(UUID); | ||
2268 | 2348 | ||
2269 | // m_log.DebugFormat( | 2349 | // m_log.DebugFormat( |
2270 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2350 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -3106,6 +3186,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3106 | cAgent.AlwaysRun = SetAlwaysRun; | 3186 | cAgent.AlwaysRun = SetAlwaysRun; |
3107 | 3187 | ||
3108 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3188 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3189 | |||
3190 | cAgent.ParentPart = ParentUUID; | ||
3191 | cAgent.SitOffset = m_pos; | ||
3109 | 3192 | ||
3110 | lock (scriptedcontrols) | 3193 | lock (scriptedcontrols) |
3111 | { | 3194 | { |
@@ -3165,6 +3248,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3165 | CameraAtAxis = cAgent.AtAxis; | 3248 | CameraAtAxis = cAgent.AtAxis; |
3166 | CameraLeftAxis = cAgent.LeftAxis; | 3249 | CameraLeftAxis = cAgent.LeftAxis; |
3167 | m_CameraUpAxis = cAgent.UpAxis; | 3250 | m_CameraUpAxis = cAgent.UpAxis; |
3251 | ParentUUID = cAgent.ParentPart; | ||
3252 | m_prevSitOffset = cAgent.SitOffset; | ||
3168 | 3253 | ||
3169 | // When we get to the point of re-computing neighbors everytime this | 3254 | // When we get to the point of re-computing neighbors everytime this |
3170 | // changes, then start using the agent's drawdistance rather than the | 3255 | // changes, then start using the agent's drawdistance rather than the |
@@ -3371,6 +3456,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3371 | } | 3456 | } |
3372 | } | 3457 | } |
3373 | 3458 | ||
3459 | RaiseCollisionScriptEvents(coldata); | ||
3460 | |||
3374 | if (Invulnerable) | 3461 | if (Invulnerable) |
3375 | return; | 3462 | return; |
3376 | 3463 | ||
@@ -3882,6 +3969,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3882 | 3969 | ||
3883 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 3970 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3884 | { | 3971 | { |
3972 | string reason; | ||
3973 | |||
3974 | // Honor bans | ||
3975 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
3976 | return; | ||
3977 | |||
3885 | SceneObjectGroup telehub = null; | 3978 | SceneObjectGroup telehub = null; |
3886 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 3979 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
3887 | { | 3980 | { |
@@ -3921,11 +4014,173 @@ namespace OpenSim.Region.Framework.Scenes | |||
3921 | pos = land.LandData.UserLocation; | 4014 | pos = land.LandData.UserLocation; |
3922 | } | 4015 | } |
3923 | } | 4016 | } |
3924 | 4017 | ||
3925 | land.SendLandUpdateToClient(ControllingClient); | 4018 | land.SendLandUpdateToClient(ControllingClient); |
3926 | } | 4019 | } |
3927 | } | 4020 | } |
3928 | 4021 | ||
4022 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4023 | { | ||
4024 | lock(m_collisionEventLock) | ||
4025 | { | ||
4026 | if (m_collisionEventFlag) | ||
4027 | return; | ||
4028 | m_collisionEventFlag = true; | ||
4029 | } | ||
4030 | |||
4031 | Util.FireAndForget(delegate(object x) | ||
4032 | { | ||
4033 | try | ||
4034 | { | ||
4035 | List<uint> thisHitColliders = new List<uint>(); | ||
4036 | List<uint> endedColliders = new List<uint>(); | ||
4037 | List<uint> startedColliders = new List<uint>(); | ||
4038 | |||
4039 | foreach (uint localid in coldata.Keys) | ||
4040 | { | ||
4041 | thisHitColliders.Add(localid); | ||
4042 | if (!m_lastColliders.Contains(localid)) | ||
4043 | { | ||
4044 | startedColliders.Add(localid); | ||
4045 | } | ||
4046 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4047 | } | ||
4048 | |||
4049 | // calculate things that ended colliding | ||
4050 | foreach (uint localID in m_lastColliders) | ||
4051 | { | ||
4052 | if (!thisHitColliders.Contains(localID)) | ||
4053 | { | ||
4054 | endedColliders.Add(localID); | ||
4055 | } | ||
4056 | } | ||
4057 | //add the items that started colliding this time to the last colliders list. | ||
4058 | foreach (uint localID in startedColliders) | ||
4059 | { | ||
4060 | m_lastColliders.Add(localID); | ||
4061 | } | ||
4062 | // remove things that ended colliding from the last colliders list | ||
4063 | foreach (uint localID in endedColliders) | ||
4064 | { | ||
4065 | m_lastColliders.Remove(localID); | ||
4066 | } | ||
4067 | |||
4068 | // do event notification | ||
4069 | if (startedColliders.Count > 0) | ||
4070 | { | ||
4071 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
4072 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4073 | foreach (uint localId in startedColliders) | ||
4074 | { | ||
4075 | if (localId == 0) | ||
4076 | continue; | ||
4077 | |||
4078 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4079 | string data = ""; | ||
4080 | if (obj != null) | ||
4081 | { | ||
4082 | DetectedObject detobj = new DetectedObject(); | ||
4083 | detobj.keyUUID = obj.UUID; | ||
4084 | detobj.nameStr = obj.Name; | ||
4085 | detobj.ownerUUID = obj.OwnerID; | ||
4086 | detobj.posVector = obj.AbsolutePosition; | ||
4087 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4088 | detobj.velVector = obj.Velocity; | ||
4089 | detobj.colliderType = 0; | ||
4090 | detobj.groupUUID = obj.GroupID; | ||
4091 | colliding.Add(detobj); | ||
4092 | } | ||
4093 | } | ||
4094 | |||
4095 | if (colliding.Count > 0) | ||
4096 | { | ||
4097 | StartCollidingMessage.Colliders = colliding; | ||
4098 | |||
4099 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4100 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
4101 | } | ||
4102 | } | ||
4103 | |||
4104 | if (endedColliders.Count > 0) | ||
4105 | { | ||
4106 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
4107 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4108 | foreach (uint localId in endedColliders) | ||
4109 | { | ||
4110 | if (localId == 0) | ||
4111 | continue; | ||
4112 | |||
4113 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4114 | string data = ""; | ||
4115 | if (obj != null) | ||
4116 | { | ||
4117 | DetectedObject detobj = new DetectedObject(); | ||
4118 | detobj.keyUUID = obj.UUID; | ||
4119 | detobj.nameStr = obj.Name; | ||
4120 | detobj.ownerUUID = obj.OwnerID; | ||
4121 | detobj.posVector = obj.AbsolutePosition; | ||
4122 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4123 | detobj.velVector = obj.Velocity; | ||
4124 | detobj.colliderType = 0; | ||
4125 | detobj.groupUUID = obj.GroupID; | ||
4126 | colliding.Add(detobj); | ||
4127 | } | ||
4128 | } | ||
4129 | |||
4130 | if (colliding.Count > 0) | ||
4131 | { | ||
4132 | EndCollidingMessage.Colliders = colliding; | ||
4133 | |||
4134 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4135 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
4136 | } | ||
4137 | } | ||
4138 | |||
4139 | if (thisHitColliders.Count > 0) | ||
4140 | { | ||
4141 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
4142 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4143 | foreach (uint localId in thisHitColliders) | ||
4144 | { | ||
4145 | if (localId == 0) | ||
4146 | continue; | ||
4147 | |||
4148 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4149 | string data = ""; | ||
4150 | if (obj != null) | ||
4151 | { | ||
4152 | DetectedObject detobj = new DetectedObject(); | ||
4153 | detobj.keyUUID = obj.UUID; | ||
4154 | detobj.nameStr = obj.Name; | ||
4155 | detobj.ownerUUID = obj.OwnerID; | ||
4156 | detobj.posVector = obj.AbsolutePosition; | ||
4157 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4158 | detobj.velVector = obj.Velocity; | ||
4159 | detobj.colliderType = 0; | ||
4160 | detobj.groupUUID = obj.GroupID; | ||
4161 | colliding.Add(detobj); | ||
4162 | } | ||
4163 | } | ||
4164 | |||
4165 | if (colliding.Count > 0) | ||
4166 | { | ||
4167 | CollidingMessage.Colliders = colliding; | ||
4168 | |||
4169 | lock (m_attachments) | ||
4170 | { | ||
4171 | foreach (SceneObjectGroup att in m_attachments) | ||
4172 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4173 | } | ||
4174 | } | ||
4175 | } | ||
4176 | } | ||
4177 | finally | ||
4178 | { | ||
4179 | m_collisionEventFlag = false; | ||
4180 | } | ||
4181 | }); | ||
4182 | } | ||
4183 | |||
3929 | private void TeleportFlagsDebug() { | 4184 | private void TeleportFlagsDebug() { |
3930 | 4185 | ||
3931 | // Some temporary debugging help to show all the TeleportFlags we have... | 4186 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -3950,6 +4205,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
3950 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4205 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
3951 | 4206 | ||
3952 | } | 4207 | } |
3953 | |||
3954 | } | 4208 | } |
3955 | } | 4209 | } |