aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs188
1 files changed, 182 insertions, 6 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 77f7b32..13854c7 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
@@ -1748,9 +1752,9 @@ namespace OpenSim.Region.Framework.Scenes
1748 if (pos.Z - terrainHeight < 0.2) 1752 if (pos.Z - terrainHeight < 0.2)
1749 pos.Z = terrainHeight; 1753 pos.Z = terrainHeight;
1750 1754
1751 m_log.DebugFormat( 1755// m_log.DebugFormat(
1752 "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", 1756// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}",
1753 Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); 1757// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
1754 1758
1755 if (noFly) 1759 if (noFly)
1756 Flying = false; 1760 Flying = false;
@@ -1834,6 +1838,7 @@ namespace OpenSim.Region.Framework.Scenes
1834 if (part.SitTargetAvatar == UUID) 1838 if (part.SitTargetAvatar == UUID)
1835 part.SitTargetAvatar = UUID.Zero; 1839 part.SitTargetAvatar = UUID.Zero;
1836 1840
1841 part.ParentGroup.DeleteAvatar(UUID);
1837 ParentPosition = part.GetWorldPosition(); 1842 ParentPosition = part.GetWorldPosition();
1838 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1843 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1839 } 1844 }
@@ -1972,7 +1977,7 @@ namespace OpenSim.Region.Framework.Scenes
1972 forceMouselook = part.GetForceMouselook(); 1977 forceMouselook = part.GetForceMouselook();
1973 1978
1974 ControllingClient.SendSitResponse( 1979 ControllingClient.SendSitResponse(
1975 targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 1980 part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
1976 1981
1977 m_requestedSitTargetUUID = targetID; 1982 m_requestedSitTargetUUID = targetID;
1978 1983
@@ -2257,11 +2262,13 @@ namespace OpenSim.Region.Framework.Scenes
2257 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2262 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT;
2258 Rotation = sitTargetOrient; 2263 Rotation = sitTargetOrient;
2259 ParentPosition = part.AbsolutePosition; 2264 ParentPosition = part.AbsolutePosition;
2265 part.ParentGroup.AddAvatar(UUID);
2260 } 2266 }
2261 else 2267 else
2262 { 2268 {
2263 m_pos -= part.AbsolutePosition; 2269 m_pos -= part.AbsolutePosition;
2264 ParentPosition = part.AbsolutePosition; 2270 ParentPosition = part.AbsolutePosition;
2271 part.ParentGroup.AddAvatar(UUID);
2265 2272
2266// m_log.DebugFormat( 2273// m_log.DebugFormat(
2267// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", 2274// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
@@ -3367,6 +3374,8 @@ namespace OpenSim.Region.Framework.Scenes
3367 } 3374 }
3368 } 3375 }
3369 3376
3377 RaiseCollisionScriptEvents(coldata);
3378
3370 if (Invulnerable) 3379 if (Invulnerable)
3371 return; 3380 return;
3372 3381
@@ -3878,6 +3887,12 @@ namespace OpenSim.Region.Framework.Scenes
3878 3887
3879 private void CheckAndAdjustLandingPoint(ref Vector3 pos) 3888 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3880 { 3889 {
3890 string reason;
3891
3892 // Honor bans
3893 if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y))
3894 return;
3895
3881 SceneObjectGroup telehub = null; 3896 SceneObjectGroup telehub = null;
3882 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) 3897 if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null)
3883 { 3898 {
@@ -3917,11 +3932,173 @@ namespace OpenSim.Region.Framework.Scenes
3917 pos = land.LandData.UserLocation; 3932 pos = land.LandData.UserLocation;
3918 } 3933 }
3919 } 3934 }
3920 3935
3921 land.SendLandUpdateToClient(ControllingClient); 3936 land.SendLandUpdateToClient(ControllingClient);
3922 } 3937 }
3923 } 3938 }
3924 3939
3940 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
3941 {
3942 lock(m_collisionEventLock)
3943 {
3944 if (m_collisionEventFlag)
3945 return;
3946 m_collisionEventFlag = true;
3947 }
3948
3949 Util.FireAndForget(delegate(object x)
3950 {
3951 try
3952 {
3953 List<uint> thisHitColliders = new List<uint>();
3954 List<uint> endedColliders = new List<uint>();
3955 List<uint> startedColliders = new List<uint>();
3956
3957 foreach (uint localid in coldata.Keys)
3958 {
3959 thisHitColliders.Add(localid);
3960 if (!m_lastColliders.Contains(localid))
3961 {
3962 startedColliders.Add(localid);
3963 }
3964 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
3965 }
3966
3967 // calculate things that ended colliding
3968 foreach (uint localID in m_lastColliders)
3969 {
3970 if (!thisHitColliders.Contains(localID))
3971 {
3972 endedColliders.Add(localID);
3973 }
3974 }
3975 //add the items that started colliding this time to the last colliders list.
3976 foreach (uint localID in startedColliders)
3977 {
3978 m_lastColliders.Add(localID);
3979 }
3980 // remove things that ended colliding from the last colliders list
3981 foreach (uint localID in endedColliders)
3982 {
3983 m_lastColliders.Remove(localID);
3984 }
3985
3986 // do event notification
3987 if (startedColliders.Count > 0)
3988 {
3989 ColliderArgs StartCollidingMessage = new ColliderArgs();
3990 List<DetectedObject> colliding = new List<DetectedObject>();
3991 foreach (uint localId in startedColliders)
3992 {
3993 if (localId == 0)
3994 continue;
3995
3996 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3997 string data = "";
3998 if (obj != null)
3999 {
4000 DetectedObject detobj = new DetectedObject();
4001 detobj.keyUUID = obj.UUID;
4002 detobj.nameStr = obj.Name;
4003 detobj.ownerUUID = obj.OwnerID;
4004 detobj.posVector = obj.AbsolutePosition;
4005 detobj.rotQuat = obj.GetWorldRotation();
4006 detobj.velVector = obj.Velocity;
4007 detobj.colliderType = 0;
4008 detobj.groupUUID = obj.GroupID;
4009 colliding.Add(detobj);
4010 }
4011 }
4012
4013 if (colliding.Count > 0)
4014 {
4015 StartCollidingMessage.Colliders = colliding;
4016
4017 foreach (SceneObjectGroup att in GetAttachments())
4018 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
4019 }
4020 }
4021
4022 if (endedColliders.Count > 0)
4023 {
4024 ColliderArgs EndCollidingMessage = new ColliderArgs();
4025 List<DetectedObject> colliding = new List<DetectedObject>();
4026 foreach (uint localId in endedColliders)
4027 {
4028 if (localId == 0)
4029 continue;
4030
4031 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
4032 string data = "";
4033 if (obj != null)
4034 {
4035 DetectedObject detobj = new DetectedObject();
4036 detobj.keyUUID = obj.UUID;
4037 detobj.nameStr = obj.Name;
4038 detobj.ownerUUID = obj.OwnerID;
4039 detobj.posVector = obj.AbsolutePosition;
4040 detobj.rotQuat = obj.GetWorldRotation();
4041 detobj.velVector = obj.Velocity;
4042 detobj.colliderType = 0;
4043 detobj.groupUUID = obj.GroupID;
4044 colliding.Add(detobj);
4045 }
4046 }
4047
4048 if (colliding.Count > 0)
4049 {
4050 EndCollidingMessage.Colliders = colliding;
4051
4052 foreach (SceneObjectGroup att in GetAttachments())
4053 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
4054 }
4055 }
4056
4057 if (thisHitColliders.Count > 0)
4058 {
4059 ColliderArgs CollidingMessage = new ColliderArgs();
4060 List<DetectedObject> colliding = new List<DetectedObject>();
4061 foreach (uint localId in thisHitColliders)
4062 {
4063 if (localId == 0)
4064 continue;
4065
4066 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
4067 string data = "";
4068 if (obj != null)
4069 {
4070 DetectedObject detobj = new DetectedObject();
4071 detobj.keyUUID = obj.UUID;
4072 detobj.nameStr = obj.Name;
4073 detobj.ownerUUID = obj.OwnerID;
4074 detobj.posVector = obj.AbsolutePosition;
4075 detobj.rotQuat = obj.GetWorldRotation();
4076 detobj.velVector = obj.Velocity;
4077 detobj.colliderType = 0;
4078 detobj.groupUUID = obj.GroupID;
4079 colliding.Add(detobj);
4080 }
4081 }
4082
4083 if (colliding.Count > 0)
4084 {
4085 CollidingMessage.Colliders = colliding;
4086
4087 lock (m_attachments)
4088 {
4089 foreach (SceneObjectGroup att in m_attachments)
4090 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4091 }
4092 }
4093 }
4094 }
4095 finally
4096 {
4097 m_collisionEventFlag = false;
4098 }
4099 });
4100 }
4101
3925 private void TeleportFlagsDebug() { 4102 private void TeleportFlagsDebug() {
3926 4103
3927 // Some temporary debugging help to show all the TeleportFlags we have... 4104 // Some temporary debugging help to show all the TeleportFlags we have...
@@ -3946,6 +4123,5 @@ namespace OpenSim.Region.Framework.Scenes
3946 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); 4123 m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************");
3947 4124
3948 } 4125 }
3949
3950 } 4126 }
3951} 4127}