diff options
author | Melanie | 2011-12-10 14:47:00 +0100 |
---|---|---|
committer | Melanie | 2011-12-10 14:47:00 +0100 |
commit | db98698bbea1777fd3ba50d7c441d581a733addd (patch) | |
tree | 24e30a6e13f5acd1010769d49730409f2d5b1028 /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC-db98698bbea1777fd3ba50d7c441d581a733addd.zip opensim-SC-db98698bbea1777fd3ba50d7c441d581a733addd.tar.gz opensim-SC-db98698bbea1777fd3ba50d7c441d581a733addd.tar.bz2 opensim-SC-db98698bbea1777fd3ba50d7c441d581a733addd.tar.xz |
Prevent spurious error message when client tries to move a null item
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 258 |
1 files changed, 139 insertions, 119 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5dda9e1..8ff804b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -214,6 +214,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
214 | //private int m_moveToPositionStateStatus; | 214 | //private int m_moveToPositionStateStatus; |
215 | //***************************************************** | 215 | //***************************************************** |
216 | 216 | ||
217 | private bool m_collisionEventFlag = false; | ||
218 | private object m_collisionEventLock = new Object(); | ||
219 | |||
217 | protected AvatarAppearance m_appearance; | 220 | protected AvatarAppearance m_appearance; |
218 | 221 | ||
219 | public AvatarAppearance Appearance | 222 | public AvatarAppearance Appearance |
@@ -3860,147 +3863,164 @@ namespace OpenSim.Region.Framework.Scenes | |||
3860 | 3863 | ||
3861 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | 3864 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) |
3862 | { | 3865 | { |
3863 | List<uint> thisHitColliders = new List<uint>(); | 3866 | lock(m_collisionEventLock) |
3864 | List<uint> endedColliders = new List<uint>(); | ||
3865 | List<uint> startedColliders = new List<uint>(); | ||
3866 | |||
3867 | foreach (uint localid in coldata.Keys) | ||
3868 | { | ||
3869 | thisHitColliders.Add(localid); | ||
3870 | if (!m_lastColliders.Contains(localid)) | ||
3871 | { | ||
3872 | startedColliders.Add(localid); | ||
3873 | } | ||
3874 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3875 | } | ||
3876 | |||
3877 | // calculate things that ended colliding | ||
3878 | foreach (uint localID in m_lastColliders) | ||
3879 | { | 3867 | { |
3880 | if (!thisHitColliders.Contains(localID)) | 3868 | if (m_collisionEventFlag) |
3881 | { | 3869 | return; |
3882 | endedColliders.Add(localID); | 3870 | m_collisionEventFlag = true; |
3883 | } | ||
3884 | } | ||
3885 | //add the items that started colliding this time to the last colliders list. | ||
3886 | foreach (uint localID in startedColliders) | ||
3887 | { | ||
3888 | m_lastColliders.Add(localID); | ||
3889 | } | ||
3890 | // remove things that ended colliding from the last colliders list | ||
3891 | foreach (uint localID in endedColliders) | ||
3892 | { | ||
3893 | m_lastColliders.Remove(localID); | ||
3894 | } | 3871 | } |
3895 | 3872 | ||
3896 | // do event notification | 3873 | Util.FireAndForget(delegate(object x) |
3897 | if (startedColliders.Count > 0) | ||
3898 | { | 3874 | { |
3899 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | 3875 | try |
3900 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3901 | foreach (uint localId in startedColliders) | ||
3902 | { | 3876 | { |
3903 | if (localId == 0) | 3877 | List<uint> thisHitColliders = new List<uint>(); |
3904 | continue; | 3878 | List<uint> endedColliders = new List<uint>(); |
3879 | List<uint> startedColliders = new List<uint>(); | ||
3905 | 3880 | ||
3906 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | 3881 | foreach (uint localid in coldata.Keys) |
3907 | string data = ""; | ||
3908 | if (obj != null) | ||
3909 | { | 3882 | { |
3910 | DetectedObject detobj = new DetectedObject(); | 3883 | thisHitColliders.Add(localid); |
3911 | detobj.keyUUID = obj.UUID; | 3884 | if (!m_lastColliders.Contains(localid)) |
3912 | detobj.nameStr = obj.Name; | 3885 | { |
3913 | detobj.ownerUUID = obj.OwnerID; | 3886 | startedColliders.Add(localid); |
3914 | detobj.posVector = obj.AbsolutePosition; | 3887 | } |
3915 | detobj.rotQuat = obj.GetWorldRotation(); | 3888 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); |
3916 | detobj.velVector = obj.Velocity; | 3889 | } |
3917 | detobj.colliderType = 0; | 3890 | |
3918 | detobj.groupUUID = obj.GroupID; | 3891 | // calculate things that ended colliding |
3919 | colliding.Add(detobj); | 3892 | foreach (uint localID in m_lastColliders) |
3893 | { | ||
3894 | if (!thisHitColliders.Contains(localID)) | ||
3895 | { | ||
3896 | endedColliders.Add(localID); | ||
3897 | } | ||
3898 | } | ||
3899 | //add the items that started colliding this time to the last colliders list. | ||
3900 | foreach (uint localID in startedColliders) | ||
3901 | { | ||
3902 | m_lastColliders.Add(localID); | ||
3903 | } | ||
3904 | // remove things that ended colliding from the last colliders list | ||
3905 | foreach (uint localID in endedColliders) | ||
3906 | { | ||
3907 | m_lastColliders.Remove(localID); | ||
3920 | } | 3908 | } |
3921 | } | ||
3922 | 3909 | ||
3923 | if (colliding.Count > 0) | 3910 | // do event notification |
3924 | { | 3911 | if (startedColliders.Count > 0) |
3925 | StartCollidingMessage.Colliders = colliding; | 3912 | { |
3913 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3914 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3915 | foreach (uint localId in startedColliders) | ||
3916 | { | ||
3917 | if (localId == 0) | ||
3918 | continue; | ||
3926 | 3919 | ||
3927 | foreach (SceneObjectGroup att in GetAttachments()) | 3920 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); |
3928 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | 3921 | string data = ""; |
3929 | } | 3922 | if (obj != null) |
3930 | } | 3923 | { |
3924 | DetectedObject detobj = new DetectedObject(); | ||
3925 | detobj.keyUUID = obj.UUID; | ||
3926 | detobj.nameStr = obj.Name; | ||
3927 | detobj.ownerUUID = obj.OwnerID; | ||
3928 | detobj.posVector = obj.AbsolutePosition; | ||
3929 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3930 | detobj.velVector = obj.Velocity; | ||
3931 | detobj.colliderType = 0; | ||
3932 | detobj.groupUUID = obj.GroupID; | ||
3933 | colliding.Add(detobj); | ||
3934 | } | ||
3935 | } | ||
3931 | 3936 | ||
3932 | if (endedColliders.Count > 0) | 3937 | if (colliding.Count > 0) |
3933 | { | 3938 | { |
3934 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | 3939 | StartCollidingMessage.Colliders = colliding; |
3935 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3936 | foreach (uint localId in endedColliders) | ||
3937 | { | ||
3938 | if (localId == 0) | ||
3939 | continue; | ||
3940 | 3940 | ||
3941 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | 3941 | foreach (SceneObjectGroup att in GetAttachments()) |
3942 | string data = ""; | 3942 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); |
3943 | if (obj != null) | 3943 | } |
3944 | { | ||
3945 | DetectedObject detobj = new DetectedObject(); | ||
3946 | detobj.keyUUID = obj.UUID; | ||
3947 | detobj.nameStr = obj.Name; | ||
3948 | detobj.ownerUUID = obj.OwnerID; | ||
3949 | detobj.posVector = obj.AbsolutePosition; | ||
3950 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3951 | detobj.velVector = obj.Velocity; | ||
3952 | detobj.colliderType = 0; | ||
3953 | detobj.groupUUID = obj.GroupID; | ||
3954 | colliding.Add(detobj); | ||
3955 | } | 3944 | } |
3956 | } | ||
3957 | 3945 | ||
3958 | if (colliding.Count > 0) | 3946 | if (endedColliders.Count > 0) |
3959 | { | 3947 | { |
3960 | EndCollidingMessage.Colliders = colliding; | 3948 | ColliderArgs EndCollidingMessage = new ColliderArgs(); |
3949 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3950 | foreach (uint localId in endedColliders) | ||
3951 | { | ||
3952 | if (localId == 0) | ||
3953 | continue; | ||
3961 | 3954 | ||
3962 | foreach (SceneObjectGroup att in GetAttachments()) | 3955 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); |
3963 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | 3956 | string data = ""; |
3964 | } | 3957 | if (obj != null) |
3965 | } | 3958 | { |
3959 | DetectedObject detobj = new DetectedObject(); | ||
3960 | detobj.keyUUID = obj.UUID; | ||
3961 | detobj.nameStr = obj.Name; | ||
3962 | detobj.ownerUUID = obj.OwnerID; | ||
3963 | detobj.posVector = obj.AbsolutePosition; | ||
3964 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3965 | detobj.velVector = obj.Velocity; | ||
3966 | detobj.colliderType = 0; | ||
3967 | detobj.groupUUID = obj.GroupID; | ||
3968 | colliding.Add(detobj); | ||
3969 | } | ||
3970 | } | ||
3966 | 3971 | ||
3967 | if (thisHitColliders.Count > 0) | 3972 | if (colliding.Count > 0) |
3968 | { | 3973 | { |
3969 | ColliderArgs CollidingMessage = new ColliderArgs(); | 3974 | EndCollidingMessage.Colliders = colliding; |
3970 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3971 | foreach (uint localId in thisHitColliders) | ||
3972 | { | ||
3973 | if (localId == 0) | ||
3974 | continue; | ||
3975 | 3975 | ||
3976 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | 3976 | foreach (SceneObjectGroup att in GetAttachments()) |
3977 | string data = ""; | 3977 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); |
3978 | if (obj != null) | 3978 | } |
3979 | { | ||
3980 | DetectedObject detobj = new DetectedObject(); | ||
3981 | detobj.keyUUID = obj.UUID; | ||
3982 | detobj.nameStr = obj.Name; | ||
3983 | detobj.ownerUUID = obj.OwnerID; | ||
3984 | detobj.posVector = obj.AbsolutePosition; | ||
3985 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3986 | detobj.velVector = obj.Velocity; | ||
3987 | detobj.colliderType = 0; | ||
3988 | detobj.groupUUID = obj.GroupID; | ||
3989 | colliding.Add(detobj); | ||
3990 | } | 3979 | } |
3991 | } | ||
3992 | |||
3993 | if (colliding.Count > 0) | ||
3994 | { | ||
3995 | CollidingMessage.Colliders = colliding; | ||
3996 | 3980 | ||
3997 | lock (m_attachments) | 3981 | if (thisHitColliders.Count > 0) |
3998 | { | 3982 | { |
3999 | foreach (SceneObjectGroup att in m_attachments) | 3983 | ColliderArgs CollidingMessage = new ColliderArgs(); |
4000 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | 3984 | List<DetectedObject> colliding = new List<DetectedObject>(); |
3985 | foreach (uint localId in thisHitColliders) | ||
3986 | { | ||
3987 | if (localId == 0) | ||
3988 | continue; | ||
3989 | |||
3990 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3991 | string data = ""; | ||
3992 | if (obj != null) | ||
3993 | { | ||
3994 | DetectedObject detobj = new DetectedObject(); | ||
3995 | detobj.keyUUID = obj.UUID; | ||
3996 | detobj.nameStr = obj.Name; | ||
3997 | detobj.ownerUUID = obj.OwnerID; | ||
3998 | detobj.posVector = obj.AbsolutePosition; | ||
3999 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4000 | detobj.velVector = obj.Velocity; | ||
4001 | detobj.colliderType = 0; | ||
4002 | detobj.groupUUID = obj.GroupID; | ||
4003 | colliding.Add(detobj); | ||
4004 | } | ||
4005 | } | ||
4006 | |||
4007 | if (colliding.Count > 0) | ||
4008 | { | ||
4009 | CollidingMessage.Colliders = colliding; | ||
4010 | |||
4011 | lock (m_attachments) | ||
4012 | { | ||
4013 | foreach (SceneObjectGroup att in m_attachments) | ||
4014 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4015 | } | ||
4016 | } | ||
4001 | } | 4017 | } |
4002 | } | 4018 | } |
4003 | } | 4019 | finally |
4020 | { | ||
4021 | m_collisionEventFlag = false; | ||
4022 | } | ||
4023 | }); | ||
4004 | } | 4024 | } |
4005 | } | 4025 | } |
4006 | } | 4026 | } |