diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 176 |
1 files changed, 173 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3c9bde8..94989de 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -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,9 @@ 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 | |||
232 | protected AvatarAppearance m_appearance; | 236 | protected AvatarAppearance m_appearance; |
233 | 237 | ||
234 | public AvatarAppearance Appearance | 238 | public AvatarAppearance Appearance |
@@ -1837,6 +1841,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1837 | if (part.SitTargetAvatar == UUID) | 1841 | if (part.SitTargetAvatar == UUID) |
1838 | part.SitTargetAvatar = UUID.Zero; | 1842 | part.SitTargetAvatar = UUID.Zero; |
1839 | 1843 | ||
1844 | part.ParentGroup.DeleteAvatar(UUID); | ||
1840 | ParentPosition = part.GetWorldPosition(); | 1845 | ParentPosition = part.GetWorldPosition(); |
1841 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1846 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1842 | } | 1847 | } |
@@ -1975,7 +1980,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1975 | forceMouselook = part.GetForceMouselook(); | 1980 | forceMouselook = part.GetForceMouselook(); |
1976 | 1981 | ||
1977 | ControllingClient.SendSitResponse( | 1982 | ControllingClient.SendSitResponse( |
1978 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 1983 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1979 | 1984 | ||
1980 | m_requestedSitTargetUUID = targetID; | 1985 | m_requestedSitTargetUUID = targetID; |
1981 | 1986 | ||
@@ -2260,11 +2265,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2260 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2265 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; |
2261 | Rotation = sitTargetOrient; | 2266 | Rotation = sitTargetOrient; |
2262 | ParentPosition = part.AbsolutePosition; | 2267 | ParentPosition = part.AbsolutePosition; |
2268 | part.ParentGroup.AddAvatar(UUID); | ||
2263 | } | 2269 | } |
2264 | else | 2270 | else |
2265 | { | 2271 | { |
2266 | m_pos -= part.AbsolutePosition; | 2272 | m_pos -= part.AbsolutePosition; |
2267 | ParentPosition = part.AbsolutePosition; | 2273 | ParentPosition = part.AbsolutePosition; |
2274 | part.ParentGroup.AddAvatar(UUID); | ||
2268 | 2275 | ||
2269 | // m_log.DebugFormat( | 2276 | // m_log.DebugFormat( |
2270 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2277 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -3370,6 +3377,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3370 | } | 3377 | } |
3371 | } | 3378 | } |
3372 | 3379 | ||
3380 | RaiseCollisionScriptEvents(coldata); | ||
3381 | |||
3373 | if (Invulnerable) | 3382 | if (Invulnerable) |
3374 | return; | 3383 | return; |
3375 | 3384 | ||
@@ -3867,11 +3876,173 @@ namespace OpenSim.Region.Framework.Scenes | |||
3867 | pos = land.LandData.UserLocation; | 3876 | pos = land.LandData.UserLocation; |
3868 | } | 3877 | } |
3869 | } | 3878 | } |
3870 | 3879 | ||
3871 | land.SendLandUpdateToClient(ControllingClient); | 3880 | land.SendLandUpdateToClient(ControllingClient); |
3872 | } | 3881 | } |
3873 | } | 3882 | } |
3874 | 3883 | ||
3884 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
3885 | { | ||
3886 | lock(m_collisionEventLock) | ||
3887 | { | ||
3888 | if (m_collisionEventFlag) | ||
3889 | return; | ||
3890 | m_collisionEventFlag = true; | ||
3891 | } | ||
3892 | |||
3893 | Util.FireAndForget(delegate(object x) | ||
3894 | { | ||
3895 | try | ||
3896 | { | ||
3897 | List<uint> thisHitColliders = new List<uint>(); | ||
3898 | List<uint> endedColliders = new List<uint>(); | ||
3899 | List<uint> startedColliders = new List<uint>(); | ||
3900 | |||
3901 | foreach (uint localid in coldata.Keys) | ||
3902 | { | ||
3903 | thisHitColliders.Add(localid); | ||
3904 | if (!m_lastColliders.Contains(localid)) | ||
3905 | { | ||
3906 | startedColliders.Add(localid); | ||
3907 | } | ||
3908 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3909 | } | ||
3910 | |||
3911 | // calculate things that ended colliding | ||
3912 | foreach (uint localID in m_lastColliders) | ||
3913 | { | ||
3914 | if (!thisHitColliders.Contains(localID)) | ||
3915 | { | ||
3916 | endedColliders.Add(localID); | ||
3917 | } | ||
3918 | } | ||
3919 | //add the items that started colliding this time to the last colliders list. | ||
3920 | foreach (uint localID in startedColliders) | ||
3921 | { | ||
3922 | m_lastColliders.Add(localID); | ||
3923 | } | ||
3924 | // remove things that ended colliding from the last colliders list | ||
3925 | foreach (uint localID in endedColliders) | ||
3926 | { | ||
3927 | m_lastColliders.Remove(localID); | ||
3928 | } | ||
3929 | |||
3930 | // do event notification | ||
3931 | if (startedColliders.Count > 0) | ||
3932 | { | ||
3933 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3934 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3935 | foreach (uint localId in startedColliders) | ||
3936 | { | ||
3937 | if (localId == 0) | ||
3938 | continue; | ||
3939 | |||
3940 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3941 | string data = ""; | ||
3942 | if (obj != null) | ||
3943 | { | ||
3944 | DetectedObject detobj = new DetectedObject(); | ||
3945 | detobj.keyUUID = obj.UUID; | ||
3946 | detobj.nameStr = obj.Name; | ||
3947 | detobj.ownerUUID = obj.OwnerID; | ||
3948 | detobj.posVector = obj.AbsolutePosition; | ||
3949 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3950 | detobj.velVector = obj.Velocity; | ||
3951 | detobj.colliderType = 0; | ||
3952 | detobj.groupUUID = obj.GroupID; | ||
3953 | colliding.Add(detobj); | ||
3954 | } | ||
3955 | } | ||
3956 | |||
3957 | if (colliding.Count > 0) | ||
3958 | { | ||
3959 | StartCollidingMessage.Colliders = colliding; | ||
3960 | |||
3961 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3962 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3963 | } | ||
3964 | } | ||
3965 | |||
3966 | if (endedColliders.Count > 0) | ||
3967 | { | ||
3968 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3969 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3970 | foreach (uint localId in endedColliders) | ||
3971 | { | ||
3972 | if (localId == 0) | ||
3973 | continue; | ||
3974 | |||
3975 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3976 | string data = ""; | ||
3977 | if (obj != null) | ||
3978 | { | ||
3979 | DetectedObject detobj = new DetectedObject(); | ||
3980 | detobj.keyUUID = obj.UUID; | ||
3981 | detobj.nameStr = obj.Name; | ||
3982 | detobj.ownerUUID = obj.OwnerID; | ||
3983 | detobj.posVector = obj.AbsolutePosition; | ||
3984 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3985 | detobj.velVector = obj.Velocity; | ||
3986 | detobj.colliderType = 0; | ||
3987 | detobj.groupUUID = obj.GroupID; | ||
3988 | colliding.Add(detobj); | ||
3989 | } | ||
3990 | } | ||
3991 | |||
3992 | if (colliding.Count > 0) | ||
3993 | { | ||
3994 | EndCollidingMessage.Colliders = colliding; | ||
3995 | |||
3996 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3997 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3998 | } | ||
3999 | } | ||
4000 | |||
4001 | if (thisHitColliders.Count > 0) | ||
4002 | { | ||
4003 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
4004 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4005 | foreach (uint localId in thisHitColliders) | ||
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 | CollidingMessage.Colliders = colliding; | ||
4030 | |||
4031 | lock (m_attachments) | ||
4032 | { | ||
4033 | foreach (SceneObjectGroup att in m_attachments) | ||
4034 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4035 | } | ||
4036 | } | ||
4037 | } | ||
4038 | } | ||
4039 | finally | ||
4040 | { | ||
4041 | m_collisionEventFlag = false; | ||
4042 | } | ||
4043 | }); | ||
4044 | } | ||
4045 | |||
3875 | private void TeleportFlagsDebug() { | 4046 | private void TeleportFlagsDebug() { |
3876 | 4047 | ||
3877 | // Some temporary debugging help to show all the TeleportFlags we have... | 4048 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -3896,6 +4067,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
3896 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4067 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
3897 | 4068 | ||
3898 | } | 4069 | } |
3899 | |||
3900 | } | 4070 | } |
3901 | } | 4071 | } |