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.cs209
1 files changed, 209 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 9ebb6dd..8906c6f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -153,6 +153,7 @@ namespace OpenSim.Region.Framework.Scenes
153 private int m_lastColCount = -1; //KF: Look for Collision chnages 153 private int m_lastColCount = -1; //KF: Look for Collision chnages
154 private int m_updateCount = 0; //KF: Update Anims for a while 154 private int m_updateCount = 0; //KF: Update Anims for a while
155 private static readonly int UPDATE_COUNT = 10; // how many frames to update for 155 private static readonly int UPDATE_COUNT = 10; // how many frames to update for
156 private List<uint> m_lastColliders = new List<uint>();
156 157
157 private TeleportFlags m_teleportFlags; 158 private TeleportFlags m_teleportFlags;
158 public TeleportFlags TeleportFlags 159 public TeleportFlags TeleportFlags
@@ -918,6 +919,8 @@ namespace OpenSim.Region.Framework.Scenes
918 pos.Y = crossedBorder.BorderLine.Z - 1; 919 pos.Y = crossedBorder.BorderLine.Z - 1;
919 } 920 }
920 921
922 CheckAndAdjustLandingPoint(ref pos);
923
921 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 924 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
922 { 925 {
923 m_log.WarnFormat( 926 m_log.WarnFormat(
@@ -1080,6 +1083,7 @@ namespace OpenSim.Region.Framework.Scenes
1080 1083
1081 RemoveFromPhysicalScene(); 1084 RemoveFromPhysicalScene();
1082 Velocity = Vector3.Zero; 1085 Velocity = Vector3.Zero;
1086 CheckLandingPoint(ref pos);
1083 AbsolutePosition = pos; 1087 AbsolutePosition = pos;
1084 AddToPhysicalScene(isFlying); 1088 AddToPhysicalScene(isFlying);
1085 1089
@@ -1093,6 +1097,7 @@ namespace OpenSim.Region.Framework.Scenes
1093 isFlying = PhysicsActor.Flying; 1097 isFlying = PhysicsActor.Flying;
1094 1098
1095 RemoveFromPhysicalScene(); 1099 RemoveFromPhysicalScene();
1100 CheckLandingPoint(ref pos);
1096 AbsolutePosition = pos; 1101 AbsolutePosition = pos;
1097 AddToPhysicalScene(isFlying); 1102 AddToPhysicalScene(isFlying);
1098 1103
@@ -1860,6 +1865,7 @@ namespace OpenSim.Region.Framework.Scenes
1860 if (part.SitTargetAvatar == UUID) 1865 if (part.SitTargetAvatar == UUID)
1861 part.SitTargetAvatar = UUID.Zero; 1866 part.SitTargetAvatar = UUID.Zero;
1862 1867
1868 part.ParentGroup.DeleteAvatar(UUID);
1863 ParentPosition = part.GetWorldPosition(); 1869 ParentPosition = part.GetWorldPosition();
1864 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1870 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1865 } 1871 }
@@ -2283,11 +2289,13 @@ namespace OpenSim.Region.Framework.Scenes
2283 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2289 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT;
2284 Rotation = sitTargetOrient; 2290 Rotation = sitTargetOrient;
2285 ParentPosition = part.AbsolutePosition; 2291 ParentPosition = part.AbsolutePosition;
2292 part.ParentGroup.AddAvatar(UUID);
2286 } 2293 }
2287 else 2294 else
2288 { 2295 {
2289 m_pos -= part.AbsolutePosition; 2296 m_pos -= part.AbsolutePosition;
2290 ParentPosition = part.AbsolutePosition; 2297 ParentPosition = part.AbsolutePosition;
2298 part.ParentGroup.AddAvatar(UUID);
2291 2299
2292// m_log.DebugFormat( 2300// m_log.DebugFormat(
2293// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", 2301// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
@@ -3360,6 +3368,8 @@ namespace OpenSim.Region.Framework.Scenes
3360 } 3368 }
3361 } 3369 }
3362 3370
3371 RaiseCollisionScriptEvents(coldata);
3372
3363 if (Invulnerable) 3373 if (Invulnerable)
3364 return; 3374 return;
3365 3375
@@ -3798,5 +3808,204 @@ namespace OpenSim.Region.Framework.Scenes
3798 m_reprioritization_called = false; 3808 m_reprioritization_called = false;
3799 } 3809 }
3800 } 3810 }
3811
3812 private void CheckLandingPoint(ref Vector3 pos)
3813 {
3814 // Never constrain lures
3815 if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
3816 return;
3817
3818 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3819 return;
3820
3821 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3822
3823 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3824 land.LandData.UserLocation != Vector3.Zero &&
3825 land.LandData.OwnerID != m_uuid &&
3826 (!m_scene.Permissions.IsGod(m_uuid)) &&
3827 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
3828 {
3829 float curr = Vector3.Distance(AbsolutePosition, pos);
3830 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
3831 pos = land.LandData.UserLocation;
3832 else
3833 ControllingClient.SendAlertMessage("Can't teleport closer to destination");
3834 }
3835 }
3836
3837 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3838 {
3839 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3840 if (land != null)
3841 {
3842 // If we come in via login, landmark or map, we want to
3843 // honor landing points. If we come in via Lure, we want
3844 // to ignore them.
3845 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3846 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3847 (m_teleportFlags & TeleportFlags.ViaLocation) != 0)
3848 {
3849 // Don't restrict gods, estate managers, or land owners to
3850 // the TP point. This behaviour mimics agni.
3851 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3852 land.LandData.UserLocation != Vector3.Zero &&
3853 GodLevel < 200 &&
3854 ((land.LandData.OwnerID != m_uuid &&
3855 (!m_scene.Permissions.IsGod(m_uuid)) &&
3856 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0))
3857 {
3858 pos = land.LandData.UserLocation;
3859 }
3860 }
3861
3862 land.SendLandUpdateToClient(ControllingClient);
3863 }
3864 }
3865
3866 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
3867 {
3868 List<uint> thisHitColliders = new List<uint>();
3869 List<uint> endedColliders = new List<uint>();
3870 List<uint> startedColliders = new List<uint>();
3871
3872 foreach (uint localid in coldata.Keys)
3873 {
3874 thisHitColliders.Add(localid);
3875 if (!m_lastColliders.Contains(localid))
3876 {
3877 startedColliders.Add(localid);
3878 }
3879 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
3880 }
3881
3882 // calculate things that ended colliding
3883 foreach (uint localID in m_lastColliders)
3884 {
3885 if (!thisHitColliders.Contains(localID))
3886 {
3887 endedColliders.Add(localID);
3888 }
3889 }
3890 //add the items that started colliding this time to the last colliders list.
3891 foreach (uint localID in startedColliders)
3892 {
3893 m_lastColliders.Add(localID);
3894 }
3895 // remove things that ended colliding from the last colliders list
3896 foreach (uint localID in endedColliders)
3897 {
3898 m_lastColliders.Remove(localID);
3899 }
3900
3901 // do event notification
3902 if (startedColliders.Count > 0)
3903 {
3904 ColliderArgs StartCollidingMessage = new ColliderArgs();
3905 List<DetectedObject> colliding = new List<DetectedObject>();
3906 foreach (uint localId in startedColliders)
3907 {
3908 if (localId == 0)
3909 continue;
3910
3911 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3912 string data = "";
3913 if (obj != null)
3914 {
3915 DetectedObject detobj = new DetectedObject();
3916 detobj.keyUUID = obj.UUID;
3917 detobj.nameStr = obj.Name;
3918 detobj.ownerUUID = obj.OwnerID;
3919 detobj.posVector = obj.AbsolutePosition;
3920 detobj.rotQuat = obj.GetWorldRotation();
3921 detobj.velVector = obj.Velocity;
3922 detobj.colliderType = 0;
3923 detobj.groupUUID = obj.GroupID;
3924 colliding.Add(detobj);
3925 }
3926 }
3927
3928 if (colliding.Count > 0)
3929 {
3930 StartCollidingMessage.Colliders = colliding;
3931
3932 foreach (SceneObjectGroup att in GetAttachments())
3933 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
3934 }
3935 }
3936
3937 if (endedColliders.Count > 0)
3938 {
3939 ColliderArgs EndCollidingMessage = new ColliderArgs();
3940 List<DetectedObject> colliding = new List<DetectedObject>();
3941 foreach (uint localId in endedColliders)
3942 {
3943 if (localId == 0)
3944 continue;
3945
3946 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3947 string data = "";
3948 if (obj != null)
3949 {
3950 DetectedObject detobj = new DetectedObject();
3951 detobj.keyUUID = obj.UUID;
3952 detobj.nameStr = obj.Name;
3953 detobj.ownerUUID = obj.OwnerID;
3954 detobj.posVector = obj.AbsolutePosition;
3955 detobj.rotQuat = obj.GetWorldRotation();
3956 detobj.velVector = obj.Velocity;
3957 detobj.colliderType = 0;
3958 detobj.groupUUID = obj.GroupID;
3959 colliding.Add(detobj);
3960 }
3961 }
3962
3963 if (colliding.Count > 0)
3964 {
3965 EndCollidingMessage.Colliders = colliding;
3966
3967 foreach (SceneObjectGroup att in GetAttachments())
3968 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
3969 }
3970 }
3971
3972 if (thisHitColliders.Count > 0)
3973 {
3974 ColliderArgs CollidingMessage = new ColliderArgs();
3975 List<DetectedObject> colliding = new List<DetectedObject>();
3976 foreach (uint localId in thisHitColliders)
3977 {
3978 if (localId == 0)
3979 continue;
3980
3981 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3982 string data = "";
3983 if (obj != null)
3984 {
3985 DetectedObject detobj = new DetectedObject();
3986 detobj.keyUUID = obj.UUID;
3987 detobj.nameStr = obj.Name;
3988 detobj.ownerUUID = obj.OwnerID;
3989 detobj.posVector = obj.AbsolutePosition;
3990 detobj.rotQuat = obj.GetWorldRotation();
3991 detobj.velVector = obj.Velocity;
3992 detobj.colliderType = 0;
3993 detobj.groupUUID = obj.GroupID;
3994 colliding.Add(detobj);
3995 }
3996 }
3997
3998 if (colliding.Count > 0)
3999 {
4000 CollidingMessage.Colliders = colliding;
4001
4002 lock (m_attachments)
4003 {
4004 foreach (SceneObjectGroup att in m_attachments)
4005 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4006 }
4007 }
4008 }
4009 }
3801 } 4010 }
3802} 4011}