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