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 3fee642..087697f 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",
@@ -3358,6 +3366,8 @@ namespace OpenSim.Region.Framework.Scenes
3358 } 3366 }
3359 } 3367 }
3360 3368
3369 RaiseCollisionScriptEvents(coldata);
3370
3361 if (Invulnerable) 3371 if (Invulnerable)
3362 return; 3372 return;
3363 3373
@@ -3796,5 +3806,204 @@ namespace OpenSim.Region.Framework.Scenes
3796 m_reprioritization_called = false; 3806 m_reprioritization_called = false;
3797 } 3807 }
3798 } 3808 }
3809
3810 private void CheckLandingPoint(ref Vector3 pos)
3811 {
3812 // Never constrain lures
3813 if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
3814 return;
3815
3816 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3817 return;
3818
3819 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3820
3821 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3822 land.LandData.UserLocation != Vector3.Zero &&
3823 land.LandData.OwnerID != m_uuid &&
3824 (!m_scene.Permissions.IsGod(m_uuid)) &&
3825 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
3826 {
3827 float curr = Vector3.Distance(AbsolutePosition, pos);
3828 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
3829 pos = land.LandData.UserLocation;
3830 else
3831 ControllingClient.SendAlertMessage("Can't teleport closer to destination");
3832 }
3833 }
3834
3835 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3836 {
3837 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3838 if (land != null)
3839 {
3840 // If we come in via login, landmark or map, we want to
3841 // honor landing points. If we come in via Lure, we want
3842 // to ignore them.
3843 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3844 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3845 (m_teleportFlags & TeleportFlags.ViaLocation) != 0)
3846 {
3847 // Don't restrict gods, estate managers, or land owners to
3848 // the TP point. This behaviour mimics agni.
3849 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3850 land.LandData.UserLocation != Vector3.Zero &&
3851 GodLevel < 200 &&
3852 ((land.LandData.OwnerID != m_uuid &&
3853 (!m_scene.Permissions.IsGod(m_uuid)) &&
3854 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0))
3855 {
3856 pos = land.LandData.UserLocation;
3857 }
3858 }
3859
3860 land.SendLandUpdateToClient(ControllingClient);
3861 }
3862 }
3863
3864 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
3865 {
3866 List<uint> thisHitColliders = new List<uint>();
3867 List<uint> endedColliders = new List<uint>();
3868 List<uint> startedColliders = new List<uint>();
3869
3870 foreach (uint localid in coldata.Keys)
3871 {
3872 thisHitColliders.Add(localid);
3873 if (!m_lastColliders.Contains(localid))
3874 {
3875 startedColliders.Add(localid);
3876 }
3877 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
3878 }
3879
3880 // calculate things that ended colliding
3881 foreach (uint localID in m_lastColliders)
3882 {
3883 if (!thisHitColliders.Contains(localID))
3884 {
3885 endedColliders.Add(localID);
3886 }
3887 }
3888 //add the items that started colliding this time to the last colliders list.
3889 foreach (uint localID in startedColliders)
3890 {
3891 m_lastColliders.Add(localID);
3892 }
3893 // remove things that ended colliding from the last colliders list
3894 foreach (uint localID in endedColliders)
3895 {
3896 m_lastColliders.Remove(localID);
3897 }
3898
3899 // do event notification
3900 if (startedColliders.Count > 0)
3901 {
3902 ColliderArgs StartCollidingMessage = new ColliderArgs();
3903 List<DetectedObject> colliding = new List<DetectedObject>();
3904 foreach (uint localId in startedColliders)
3905 {
3906 if (localId == 0)
3907 continue;
3908
3909 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3910 string data = "";
3911 if (obj != null)
3912 {
3913 DetectedObject detobj = new DetectedObject();
3914 detobj.keyUUID = obj.UUID;
3915 detobj.nameStr = obj.Name;
3916 detobj.ownerUUID = obj.OwnerID;
3917 detobj.posVector = obj.AbsolutePosition;
3918 detobj.rotQuat = obj.GetWorldRotation();
3919 detobj.velVector = obj.Velocity;
3920 detobj.colliderType = 0;
3921 detobj.groupUUID = obj.GroupID;
3922 colliding.Add(detobj);
3923 }
3924 }
3925
3926 if (colliding.Count > 0)
3927 {
3928 StartCollidingMessage.Colliders = colliding;
3929
3930 foreach (SceneObjectGroup att in GetAttachments())
3931 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
3932 }
3933 }
3934
3935 if (endedColliders.Count > 0)
3936 {
3937 ColliderArgs EndCollidingMessage = new ColliderArgs();
3938 List<DetectedObject> colliding = new List<DetectedObject>();
3939 foreach (uint localId in endedColliders)
3940 {
3941 if (localId == 0)
3942 continue;
3943
3944 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3945 string data = "";
3946 if (obj != null)
3947 {
3948 DetectedObject detobj = new DetectedObject();
3949 detobj.keyUUID = obj.UUID;
3950 detobj.nameStr = obj.Name;
3951 detobj.ownerUUID = obj.OwnerID;
3952 detobj.posVector = obj.AbsolutePosition;
3953 detobj.rotQuat = obj.GetWorldRotation();
3954 detobj.velVector = obj.Velocity;
3955 detobj.colliderType = 0;
3956 detobj.groupUUID = obj.GroupID;
3957 colliding.Add(detobj);
3958 }
3959 }
3960
3961 if (colliding.Count > 0)
3962 {
3963 EndCollidingMessage.Colliders = colliding;
3964
3965 foreach (SceneObjectGroup att in GetAttachments())
3966 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
3967 }
3968 }
3969
3970 if (thisHitColliders.Count > 0)
3971 {
3972 ColliderArgs CollidingMessage = new ColliderArgs();
3973 List<DetectedObject> colliding = new List<DetectedObject>();
3974 foreach (uint localId in thisHitColliders)
3975 {
3976 if (localId == 0)
3977 continue;
3978
3979 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3980 string data = "";
3981 if (obj != null)
3982 {
3983 DetectedObject detobj = new DetectedObject();
3984 detobj.keyUUID = obj.UUID;
3985 detobj.nameStr = obj.Name;
3986 detobj.ownerUUID = obj.OwnerID;
3987 detobj.posVector = obj.AbsolutePosition;
3988 detobj.rotQuat = obj.GetWorldRotation();
3989 detobj.velVector = obj.Velocity;
3990 detobj.colliderType = 0;
3991 detobj.groupUUID = obj.GroupID;
3992 colliding.Add(detobj);
3993 }
3994 }
3995
3996 if (colliding.Count > 0)
3997 {
3998 CollidingMessage.Colliders = colliding;
3999
4000 lock (m_attachments)
4001 {
4002 foreach (SceneObjectGroup att in m_attachments)
4003 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4004 }
4005 }
4006 }
4007 }
3799 } 4008 }
3800} 4009}