diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 175 |
1 files changed, 173 insertions, 2 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b861c28..e17d886 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -167,6 +167,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
167 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 167 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
168 | // private int m_updateCount = 0; //KF: Update Anims for a while | 168 | // private int m_updateCount = 0; //KF: Update Anims for a while |
169 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 169 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
170 | private List<uint> m_lastColliders = new List<uint>(); | ||
170 | 171 | ||
171 | private TeleportFlags m_teleportFlags; | 172 | private TeleportFlags m_teleportFlags; |
172 | public TeleportFlags TeleportFlags | 173 | public TeleportFlags TeleportFlags |
@@ -228,6 +229,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
228 | //private int m_moveToPositionStateStatus; | 229 | //private int m_moveToPositionStateStatus; |
229 | //***************************************************** | 230 | //***************************************************** |
230 | 231 | ||
232 | private bool m_collisionEventFlag = false; | ||
233 | private object m_collisionEventLock = new Object(); | ||
234 | |||
231 | protected AvatarAppearance m_appearance; | 235 | protected AvatarAppearance m_appearance; |
232 | 236 | ||
233 | public AvatarAppearance Appearance | 237 | public AvatarAppearance Appearance |
@@ -1836,6 +1840,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1836 | if (part.SitTargetAvatar == UUID) | 1840 | if (part.SitTargetAvatar == UUID) |
1837 | part.SitTargetAvatar = UUID.Zero; | 1841 | part.SitTargetAvatar = UUID.Zero; |
1838 | 1842 | ||
1843 | part.ParentGroup.DeleteAvatar(UUID); | ||
1839 | ParentPosition = part.GetWorldPosition(); | 1844 | ParentPosition = part.GetWorldPosition(); |
1840 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1845 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1841 | } | 1846 | } |
@@ -1974,7 +1979,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1974 | forceMouselook = part.GetForceMouselook(); | 1979 | forceMouselook = part.GetForceMouselook(); |
1975 | 1980 | ||
1976 | ControllingClient.SendSitResponse( | 1981 | ControllingClient.SendSitResponse( |
1977 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 1982 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1978 | 1983 | ||
1979 | m_requestedSitTargetUUID = targetID; | 1984 | m_requestedSitTargetUUID = targetID; |
1980 | 1985 | ||
@@ -2259,11 +2264,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2259 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2264 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; |
2260 | Rotation = sitTargetOrient; | 2265 | Rotation = sitTargetOrient; |
2261 | ParentPosition = part.AbsolutePosition; | 2266 | ParentPosition = part.AbsolutePosition; |
2267 | part.ParentGroup.AddAvatar(UUID); | ||
2262 | } | 2268 | } |
2263 | else | 2269 | else |
2264 | { | 2270 | { |
2265 | m_pos -= part.AbsolutePosition; | 2271 | m_pos -= part.AbsolutePosition; |
2266 | ParentPosition = part.AbsolutePosition; | 2272 | ParentPosition = part.AbsolutePosition; |
2273 | part.ParentGroup.AddAvatar(UUID); | ||
2267 | 2274 | ||
2268 | // m_log.DebugFormat( | 2275 | // m_log.DebugFormat( |
2269 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2276 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -3369,6 +3376,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3369 | } | 3376 | } |
3370 | } | 3377 | } |
3371 | 3378 | ||
3379 | RaiseCollisionScriptEvents(coldata); | ||
3380 | |||
3372 | if (Invulnerable) | 3381 | if (Invulnerable) |
3373 | return; | 3382 | return; |
3374 | 3383 | ||
@@ -3858,9 +3867,171 @@ namespace OpenSim.Region.Framework.Scenes | |||
3858 | pos = land.LandData.UserLocation; | 3867 | pos = land.LandData.UserLocation; |
3859 | } | 3868 | } |
3860 | } | 3869 | } |
3861 | 3870 | ||
3862 | land.SendLandUpdateToClient(ControllingClient); | 3871 | land.SendLandUpdateToClient(ControllingClient); |
3863 | } | 3872 | } |
3864 | } | 3873 | } |
3874 | |||
3875 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
3876 | { | ||
3877 | lock(m_collisionEventLock) | ||
3878 | { | ||
3879 | if (m_collisionEventFlag) | ||
3880 | return; | ||
3881 | m_collisionEventFlag = true; | ||
3882 | } | ||
3883 | |||
3884 | Util.FireAndForget(delegate(object x) | ||
3885 | { | ||
3886 | try | ||
3887 | { | ||
3888 | List<uint> thisHitColliders = new List<uint>(); | ||
3889 | List<uint> endedColliders = new List<uint>(); | ||
3890 | List<uint> startedColliders = new List<uint>(); | ||
3891 | |||
3892 | foreach (uint localid in coldata.Keys) | ||
3893 | { | ||
3894 | thisHitColliders.Add(localid); | ||
3895 | if (!m_lastColliders.Contains(localid)) | ||
3896 | { | ||
3897 | startedColliders.Add(localid); | ||
3898 | } | ||
3899 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3900 | } | ||
3901 | |||
3902 | // calculate things that ended colliding | ||
3903 | foreach (uint localID in m_lastColliders) | ||
3904 | { | ||
3905 | if (!thisHitColliders.Contains(localID)) | ||
3906 | { | ||
3907 | endedColliders.Add(localID); | ||
3908 | } | ||
3909 | } | ||
3910 | //add the items that started colliding this time to the last colliders list. | ||
3911 | foreach (uint localID in startedColliders) | ||
3912 | { | ||
3913 | m_lastColliders.Add(localID); | ||
3914 | } | ||
3915 | // remove things that ended colliding from the last colliders list | ||
3916 | foreach (uint localID in endedColliders) | ||
3917 | { | ||
3918 | m_lastColliders.Remove(localID); | ||
3919 | } | ||
3920 | |||
3921 | // do event notification | ||
3922 | if (startedColliders.Count > 0) | ||
3923 | { | ||
3924 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3925 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3926 | foreach (uint localId in startedColliders) | ||
3927 | { | ||
3928 | if (localId == 0) | ||
3929 | continue; | ||
3930 | |||
3931 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3932 | string data = ""; | ||
3933 | if (obj != null) | ||
3934 | { | ||
3935 | DetectedObject detobj = new DetectedObject(); | ||
3936 | detobj.keyUUID = obj.UUID; | ||
3937 | detobj.nameStr = obj.Name; | ||
3938 | detobj.ownerUUID = obj.OwnerID; | ||
3939 | detobj.posVector = obj.AbsolutePosition; | ||
3940 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3941 | detobj.velVector = obj.Velocity; | ||
3942 | detobj.colliderType = 0; | ||
3943 | detobj.groupUUID = obj.GroupID; | ||
3944 | colliding.Add(detobj); | ||
3945 | } | ||
3946 | } | ||
3947 | |||
3948 | if (colliding.Count > 0) | ||
3949 | { | ||
3950 | StartCollidingMessage.Colliders = colliding; | ||
3951 | |||
3952 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3953 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3954 | } | ||
3955 | } | ||
3956 | |||
3957 | if (endedColliders.Count > 0) | ||
3958 | { | ||
3959 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3960 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3961 | foreach (uint localId in endedColliders) | ||
3962 | { | ||
3963 | if (localId == 0) | ||
3964 | continue; | ||
3965 | |||
3966 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3967 | string data = ""; | ||
3968 | if (obj != null) | ||
3969 | { | ||
3970 | DetectedObject detobj = new DetectedObject(); | ||
3971 | detobj.keyUUID = obj.UUID; | ||
3972 | detobj.nameStr = obj.Name; | ||
3973 | detobj.ownerUUID = obj.OwnerID; | ||
3974 | detobj.posVector = obj.AbsolutePosition; | ||
3975 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3976 | detobj.velVector = obj.Velocity; | ||
3977 | detobj.colliderType = 0; | ||
3978 | detobj.groupUUID = obj.GroupID; | ||
3979 | colliding.Add(detobj); | ||
3980 | } | ||
3981 | } | ||
3982 | |||
3983 | if (colliding.Count > 0) | ||
3984 | { | ||
3985 | EndCollidingMessage.Colliders = colliding; | ||
3986 | |||
3987 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3988 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3989 | } | ||
3990 | } | ||
3991 | |||
3992 | if (thisHitColliders.Count > 0) | ||
3993 | { | ||
3994 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3995 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3996 | foreach (uint localId in thisHitColliders) | ||
3997 | { | ||
3998 | if (localId == 0) | ||
3999 | continue; | ||
4000 | |||
4001 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4002 | string data = ""; | ||
4003 | if (obj != null) | ||
4004 | { | ||
4005 | DetectedObject detobj = new DetectedObject(); | ||
4006 | detobj.keyUUID = obj.UUID; | ||
4007 | detobj.nameStr = obj.Name; | ||
4008 | detobj.ownerUUID = obj.OwnerID; | ||
4009 | detobj.posVector = obj.AbsolutePosition; | ||
4010 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4011 | detobj.velVector = obj.Velocity; | ||
4012 | detobj.colliderType = 0; | ||
4013 | detobj.groupUUID = obj.GroupID; | ||
4014 | colliding.Add(detobj); | ||
4015 | } | ||
4016 | } | ||
4017 | |||
4018 | if (colliding.Count > 0) | ||
4019 | { | ||
4020 | CollidingMessage.Colliders = colliding; | ||
4021 | |||
4022 | lock (m_attachments) | ||
4023 | { | ||
4024 | foreach (SceneObjectGroup att in m_attachments) | ||
4025 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4026 | } | ||
4027 | } | ||
4028 | } | ||
4029 | } | ||
4030 | finally | ||
4031 | { | ||
4032 | m_collisionEventFlag = false; | ||
4033 | } | ||
4034 | }); | ||
4035 | } | ||
3865 | } | 4036 | } |
3866 | } | 4037 | } |