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.cs231
1 files changed, 230 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 42cd4be..a301ccb 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
@@ -892,6 +896,8 @@ namespace OpenSim.Region.Framework.Scenes
892 pos.Y = crossedBorder.BorderLine.Z - 1; 896 pos.Y = crossedBorder.BorderLine.Z - 1;
893 } 897 }
894 898
899 CheckAndAdjustLandingPoint(ref pos);
900
895 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 901 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
896 { 902 {
897 m_log.WarnFormat( 903 m_log.WarnFormat(
@@ -1056,6 +1062,7 @@ namespace OpenSim.Region.Framework.Scenes
1056 bool isFlying = Flying; 1062 bool isFlying = Flying;
1057 RemoveFromPhysicalScene(); 1063 RemoveFromPhysicalScene();
1058 Velocity = Vector3.Zero; 1064 Velocity = Vector3.Zero;
1065 CheckLandingPoint(ref pos);
1059 AbsolutePosition = pos; 1066 AbsolutePosition = pos;
1060 AddToPhysicalScene(isFlying); 1067 AddToPhysicalScene(isFlying);
1061 1068
@@ -1066,6 +1073,7 @@ namespace OpenSim.Region.Framework.Scenes
1066 { 1073 {
1067 bool isFlying = Flying; 1074 bool isFlying = Flying;
1068 RemoveFromPhysicalScene(); 1075 RemoveFromPhysicalScene();
1076 CheckLandingPoint(ref pos);
1069 AbsolutePosition = pos; 1077 AbsolutePosition = pos;
1070 AddToPhysicalScene(isFlying); 1078 AddToPhysicalScene(isFlying);
1071 1079
@@ -1831,6 +1839,7 @@ namespace OpenSim.Region.Framework.Scenes
1831 if (part.SitTargetAvatar == UUID) 1839 if (part.SitTargetAvatar == UUID)
1832 part.SitTargetAvatar = UUID.Zero; 1840 part.SitTargetAvatar = UUID.Zero;
1833 1841
1842 part.ParentGroup.DeleteAvatar(UUID);
1834 ParentPosition = part.GetWorldPosition(); 1843 ParentPosition = part.GetWorldPosition();
1835 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1844 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1836 } 1845 }
@@ -1969,7 +1978,7 @@ namespace OpenSim.Region.Framework.Scenes
1969 forceMouselook = part.GetForceMouselook(); 1978 forceMouselook = part.GetForceMouselook();
1970 1979
1971 ControllingClient.SendSitResponse( 1980 ControllingClient.SendSitResponse(
1972 targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 1981 part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
1973 1982
1974 m_requestedSitTargetUUID = targetID; 1983 m_requestedSitTargetUUID = targetID;
1975 1984
@@ -2254,11 +2263,13 @@ namespace OpenSim.Region.Framework.Scenes
2254 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2263 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT;
2255 Rotation = sitTargetOrient; 2264 Rotation = sitTargetOrient;
2256 ParentPosition = part.AbsolutePosition; 2265 ParentPosition = part.AbsolutePosition;
2266 part.ParentGroup.AddAvatar(UUID);
2257 } 2267 }
2258 else 2268 else
2259 { 2269 {
2260 m_pos -= part.AbsolutePosition; 2270 m_pos -= part.AbsolutePosition;
2261 ParentPosition = part.AbsolutePosition; 2271 ParentPosition = part.AbsolutePosition;
2272 part.ParentGroup.AddAvatar(UUID);
2262 2273
2263// m_log.DebugFormat( 2274// m_log.DebugFormat(
2264// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", 2275// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
@@ -3362,6 +3373,8 @@ namespace OpenSim.Region.Framework.Scenes
3362 } 3373 }
3363 } 3374 }
3364 3375
3376 RaiseCollisionScriptEvents(coldata);
3377
3365 if (Invulnerable) 3378 if (Invulnerable)
3366 return; 3379 return;
3367 3380
@@ -3801,5 +3814,221 @@ namespace OpenSim.Region.Framework.Scenes
3801 m_reprioritization_called = false; 3814 m_reprioritization_called = false;
3802 } 3815 }
3803 } 3816 }
3817
3818 private void CheckLandingPoint(ref Vector3 pos)
3819 {
3820 // Never constrain lures
3821 if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
3822 return;
3823
3824 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3825 return;
3826
3827 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3828
3829 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3830 land.LandData.UserLocation != Vector3.Zero &&
3831 land.LandData.OwnerID != m_uuid &&
3832 (!m_scene.Permissions.IsGod(m_uuid)) &&
3833 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
3834 {
3835 float curr = Vector3.Distance(AbsolutePosition, pos);
3836 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
3837 pos = land.LandData.UserLocation;
3838 else
3839 ControllingClient.SendAlertMessage("Can't teleport closer to destination");
3840 }
3841 }
3842
3843 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3844 {
3845 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3846 if (land != null)
3847 {
3848 // If we come in via login, landmark or map, we want to
3849 // honor landing points. If we come in via Lure, we want
3850 // to ignore them.
3851 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3852 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3853 (m_teleportFlags & TeleportFlags.ViaLocation) != 0)
3854 {
3855 // Don't restrict gods, estate managers, or land owners to
3856 // the TP point. This behaviour mimics agni.
3857 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3858 land.LandData.UserLocation != Vector3.Zero &&
3859 GodLevel < 200 &&
3860 ((land.LandData.OwnerID != m_uuid &&
3861 (!m_scene.Permissions.IsGod(m_uuid)) &&
3862 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0))
3863 {
3864 pos = land.LandData.UserLocation;
3865 }
3866 }
3867
3868 land.SendLandUpdateToClient(ControllingClient);
3869 }
3870 }
3871
3872 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
3873 {
3874 lock(m_collisionEventLock)
3875 {
3876 if (m_collisionEventFlag)
3877 return;
3878 m_collisionEventFlag = true;
3879 }
3880
3881 Util.FireAndForget(delegate(object x)
3882 {
3883 try
3884 {
3885 List<uint> thisHitColliders = new List<uint>();
3886 List<uint> endedColliders = new List<uint>();
3887 List<uint> startedColliders = new List<uint>();
3888
3889 foreach (uint localid in coldata.Keys)
3890 {
3891 thisHitColliders.Add(localid);
3892 if (!m_lastColliders.Contains(localid))
3893 {
3894 startedColliders.Add(localid);
3895 }
3896 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
3897 }
3898
3899 // calculate things that ended colliding
3900 foreach (uint localID in m_lastColliders)
3901 {
3902 if (!thisHitColliders.Contains(localID))
3903 {
3904 endedColliders.Add(localID);
3905 }
3906 }
3907 //add the items that started colliding this time to the last colliders list.
3908 foreach (uint localID in startedColliders)
3909 {
3910 m_lastColliders.Add(localID);
3911 }
3912 // remove things that ended colliding from the last colliders list
3913 foreach (uint localID in endedColliders)
3914 {
3915 m_lastColliders.Remove(localID);
3916 }
3917
3918 // do event notification
3919 if (startedColliders.Count > 0)
3920 {
3921 ColliderArgs StartCollidingMessage = new ColliderArgs();
3922 List<DetectedObject> colliding = new List<DetectedObject>();
3923 foreach (uint localId in startedColliders)
3924 {
3925 if (localId == 0)
3926 continue;
3927
3928 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3929 string data = "";
3930 if (obj != null)
3931 {
3932 DetectedObject detobj = new DetectedObject();
3933 detobj.keyUUID = obj.UUID;
3934 detobj.nameStr = obj.Name;
3935 detobj.ownerUUID = obj.OwnerID;
3936 detobj.posVector = obj.AbsolutePosition;
3937 detobj.rotQuat = obj.GetWorldRotation();
3938 detobj.velVector = obj.Velocity;
3939 detobj.colliderType = 0;
3940 detobj.groupUUID = obj.GroupID;
3941 colliding.Add(detobj);
3942 }
3943 }
3944
3945 if (colliding.Count > 0)
3946 {
3947 StartCollidingMessage.Colliders = colliding;
3948
3949 foreach (SceneObjectGroup att in GetAttachments())
3950 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
3951 }
3952 }
3953
3954 if (endedColliders.Count > 0)
3955 {
3956 ColliderArgs EndCollidingMessage = new ColliderArgs();
3957 List<DetectedObject> colliding = new List<DetectedObject>();
3958 foreach (uint localId in endedColliders)
3959 {
3960 if (localId == 0)
3961 continue;
3962
3963 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3964 string data = "";
3965 if (obj != null)
3966 {
3967 DetectedObject detobj = new DetectedObject();
3968 detobj.keyUUID = obj.UUID;
3969 detobj.nameStr = obj.Name;
3970 detobj.ownerUUID = obj.OwnerID;
3971 detobj.posVector = obj.AbsolutePosition;
3972 detobj.rotQuat = obj.GetWorldRotation();
3973 detobj.velVector = obj.Velocity;
3974 detobj.colliderType = 0;
3975 detobj.groupUUID = obj.GroupID;
3976 colliding.Add(detobj);
3977 }
3978 }
3979
3980 if (colliding.Count > 0)
3981 {
3982 EndCollidingMessage.Colliders = colliding;
3983
3984 foreach (SceneObjectGroup att in GetAttachments())
3985 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
3986 }
3987 }
3988
3989 if (thisHitColliders.Count > 0)
3990 {
3991 ColliderArgs CollidingMessage = new ColliderArgs();
3992 List<DetectedObject> colliding = new List<DetectedObject>();
3993 foreach (uint localId in thisHitColliders)
3994 {
3995 if (localId == 0)
3996 continue;
3997
3998 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3999 string data = "";
4000 if (obj != null)
4001 {
4002 DetectedObject detobj = new DetectedObject();
4003 detobj.keyUUID = obj.UUID;
4004 detobj.nameStr = obj.Name;
4005 detobj.ownerUUID = obj.OwnerID;
4006 detobj.posVector = obj.AbsolutePosition;
4007 detobj.rotQuat = obj.GetWorldRotation();
4008 detobj.velVector = obj.Velocity;
4009 detobj.colliderType = 0;
4010 detobj.groupUUID = obj.GroupID;
4011 colliding.Add(detobj);
4012 }
4013 }
4014
4015 if (colliding.Count > 0)
4016 {
4017 CollidingMessage.Colliders = colliding;
4018
4019 lock (m_attachments)
4020 {
4021 foreach (SceneObjectGroup att in m_attachments)
4022 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4023 }
4024 }
4025 }
4026 }
4027 finally
4028 {
4029 m_collisionEventFlag = false;
4030 }
4031 });
4032 }
3804 } 4033 }
3805} 4034}