diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 188 |
1 files changed, 182 insertions, 6 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5c56150..c7c90da 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 |
@@ -1751,9 +1755,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1751 | if (pos.Z - terrainHeight < 0.2) | 1755 | if (pos.Z - terrainHeight < 0.2) |
1752 | pos.Z = terrainHeight; | 1756 | pos.Z = terrainHeight; |
1753 | 1757 | ||
1754 | m_log.DebugFormat( | 1758 | // m_log.DebugFormat( |
1755 | "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", | 1759 | // "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", |
1756 | Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); | 1760 | // Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); |
1757 | 1761 | ||
1758 | if (noFly) | 1762 | if (noFly) |
1759 | Flying = false; | 1763 | Flying = false; |
@@ -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 | ||
@@ -3881,6 +3890,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3881 | 3890 | ||
3882 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 3891 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3883 | { | 3892 | { |
3893 | string reason; | ||
3894 | |||
3895 | // Honor bans | ||
3896 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
3897 | return; | ||
3898 | |||
3884 | SceneObjectGroup telehub = null; | 3899 | SceneObjectGroup telehub = null; |
3885 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 3900 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
3886 | { | 3901 | { |
@@ -3920,11 +3935,173 @@ namespace OpenSim.Region.Framework.Scenes | |||
3920 | pos = land.LandData.UserLocation; | 3935 | pos = land.LandData.UserLocation; |
3921 | } | 3936 | } |
3922 | } | 3937 | } |
3923 | 3938 | ||
3924 | land.SendLandUpdateToClient(ControllingClient); | 3939 | land.SendLandUpdateToClient(ControllingClient); |
3925 | } | 3940 | } |
3926 | } | 3941 | } |
3927 | 3942 | ||
3943 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
3944 | { | ||
3945 | lock(m_collisionEventLock) | ||
3946 | { | ||
3947 | if (m_collisionEventFlag) | ||
3948 | return; | ||
3949 | m_collisionEventFlag = true; | ||
3950 | } | ||
3951 | |||
3952 | Util.FireAndForget(delegate(object x) | ||
3953 | { | ||
3954 | try | ||
3955 | { | ||
3956 | List<uint> thisHitColliders = new List<uint>(); | ||
3957 | List<uint> endedColliders = new List<uint>(); | ||
3958 | List<uint> startedColliders = new List<uint>(); | ||
3959 | |||
3960 | foreach (uint localid in coldata.Keys) | ||
3961 | { | ||
3962 | thisHitColliders.Add(localid); | ||
3963 | if (!m_lastColliders.Contains(localid)) | ||
3964 | { | ||
3965 | startedColliders.Add(localid); | ||
3966 | } | ||
3967 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3968 | } | ||
3969 | |||
3970 | // calculate things that ended colliding | ||
3971 | foreach (uint localID in m_lastColliders) | ||
3972 | { | ||
3973 | if (!thisHitColliders.Contains(localID)) | ||
3974 | { | ||
3975 | endedColliders.Add(localID); | ||
3976 | } | ||
3977 | } | ||
3978 | //add the items that started colliding this time to the last colliders list. | ||
3979 | foreach (uint localID in startedColliders) | ||
3980 | { | ||
3981 | m_lastColliders.Add(localID); | ||
3982 | } | ||
3983 | // remove things that ended colliding from the last colliders list | ||
3984 | foreach (uint localID in endedColliders) | ||
3985 | { | ||
3986 | m_lastColliders.Remove(localID); | ||
3987 | } | ||
3988 | |||
3989 | // do event notification | ||
3990 | if (startedColliders.Count > 0) | ||
3991 | { | ||
3992 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3993 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3994 | foreach (uint localId in startedColliders) | ||
3995 | { | ||
3996 | if (localId == 0) | ||
3997 | continue; | ||
3998 | |||
3999 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4000 | string data = ""; | ||
4001 | if (obj != null) | ||
4002 | { | ||
4003 | DetectedObject detobj = new DetectedObject(); | ||
4004 | detobj.keyUUID = obj.UUID; | ||
4005 | detobj.nameStr = obj.Name; | ||
4006 | detobj.ownerUUID = obj.OwnerID; | ||
4007 | detobj.posVector = obj.AbsolutePosition; | ||
4008 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4009 | detobj.velVector = obj.Velocity; | ||
4010 | detobj.colliderType = 0; | ||
4011 | detobj.groupUUID = obj.GroupID; | ||
4012 | colliding.Add(detobj); | ||
4013 | } | ||
4014 | } | ||
4015 | |||
4016 | if (colliding.Count > 0) | ||
4017 | { | ||
4018 | StartCollidingMessage.Colliders = colliding; | ||
4019 | |||
4020 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4021 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
4022 | } | ||
4023 | } | ||
4024 | |||
4025 | if (endedColliders.Count > 0) | ||
4026 | { | ||
4027 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
4028 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4029 | foreach (uint localId in endedColliders) | ||
4030 | { | ||
4031 | if (localId == 0) | ||
4032 | continue; | ||
4033 | |||
4034 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4035 | string data = ""; | ||
4036 | if (obj != null) | ||
4037 | { | ||
4038 | DetectedObject detobj = new DetectedObject(); | ||
4039 | detobj.keyUUID = obj.UUID; | ||
4040 | detobj.nameStr = obj.Name; | ||
4041 | detobj.ownerUUID = obj.OwnerID; | ||
4042 | detobj.posVector = obj.AbsolutePosition; | ||
4043 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4044 | detobj.velVector = obj.Velocity; | ||
4045 | detobj.colliderType = 0; | ||
4046 | detobj.groupUUID = obj.GroupID; | ||
4047 | colliding.Add(detobj); | ||
4048 | } | ||
4049 | } | ||
4050 | |||
4051 | if (colliding.Count > 0) | ||
4052 | { | ||
4053 | EndCollidingMessage.Colliders = colliding; | ||
4054 | |||
4055 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4056 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
4057 | } | ||
4058 | } | ||
4059 | |||
4060 | if (thisHitColliders.Count > 0) | ||
4061 | { | ||
4062 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
4063 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4064 | foreach (uint localId in thisHitColliders) | ||
4065 | { | ||
4066 | if (localId == 0) | ||
4067 | continue; | ||
4068 | |||
4069 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4070 | string data = ""; | ||
4071 | if (obj != null) | ||
4072 | { | ||
4073 | DetectedObject detobj = new DetectedObject(); | ||
4074 | detobj.keyUUID = obj.UUID; | ||
4075 | detobj.nameStr = obj.Name; | ||
4076 | detobj.ownerUUID = obj.OwnerID; | ||
4077 | detobj.posVector = obj.AbsolutePosition; | ||
4078 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4079 | detobj.velVector = obj.Velocity; | ||
4080 | detobj.colliderType = 0; | ||
4081 | detobj.groupUUID = obj.GroupID; | ||
4082 | colliding.Add(detobj); | ||
4083 | } | ||
4084 | } | ||
4085 | |||
4086 | if (colliding.Count > 0) | ||
4087 | { | ||
4088 | CollidingMessage.Colliders = colliding; | ||
4089 | |||
4090 | lock (m_attachments) | ||
4091 | { | ||
4092 | foreach (SceneObjectGroup att in m_attachments) | ||
4093 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4094 | } | ||
4095 | } | ||
4096 | } | ||
4097 | } | ||
4098 | finally | ||
4099 | { | ||
4100 | m_collisionEventFlag = false; | ||
4101 | } | ||
4102 | }); | ||
4103 | } | ||
4104 | |||
3928 | private void TeleportFlagsDebug() { | 4105 | private void TeleportFlagsDebug() { |
3929 | 4106 | ||
3930 | // Some temporary debugging help to show all the TeleportFlags we have... | 4107 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -3949,6 +4126,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
3949 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4126 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
3950 | 4127 | ||
3951 | } | 4128 | } |
3952 | |||
3953 | } | 4129 | } |
3954 | } | 4130 | } |