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.cs227
1 files changed, 225 insertions, 2 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 8824921..21e3d3f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -152,6 +152,7 @@ namespace OpenSim.Region.Framework.Scenes
152// private int m_lastColCount = -1; //KF: Look for Collision chnages 152// private int m_lastColCount = -1; //KF: Look for Collision chnages
153// private int m_updateCount = 0; //KF: Update Anims for a while 153// private int m_updateCount = 0; //KF: Update Anims for a while
154// private static readonly int UPDATE_COUNT = 10; // how many frames to update for 154// private static readonly int UPDATE_COUNT = 10; // how many frames to update for
155 private List<uint> m_lastColliders = new List<uint>();
155 156
156 private TeleportFlags m_teleportFlags; 157 private TeleportFlags m_teleportFlags;
157 public TeleportFlags TeleportFlags 158 public TeleportFlags TeleportFlags
@@ -546,8 +547,12 @@ namespace OpenSim.Region.Framework.Scenes
546 } 547 }
547 } 548 }
548 549
549 m_pos = value; 550 // Don't update while sitting
550 ParentPosition = Vector3.Zero; 551 if (ParentID == 0)
552 {
553 m_pos = value;
554 ParentPosition = Vector3.Zero;
555 }
551 556
552// m_log.DebugFormat( 557// m_log.DebugFormat(
553// "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", 558// "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
@@ -562,6 +567,13 @@ namespace OpenSim.Region.Framework.Scenes
562 public Vector3 OffsetPosition 567 public Vector3 OffsetPosition
563 { 568 {
564 get { return m_pos; } 569 get { return m_pos; }
570 set
571 {
572 // There is no offset position when not seated
573 if (ParentID == 0)
574 return;
575 m_pos = value;
576 }
565 } 577 }
566 578
567 /// <summary> 579 /// <summary>
@@ -892,6 +904,8 @@ namespace OpenSim.Region.Framework.Scenes
892 pos.Y = crossedBorder.BorderLine.Z - 1; 904 pos.Y = crossedBorder.BorderLine.Z - 1;
893 } 905 }
894 906
907 CheckAndAdjustLandingPoint(ref pos);
908
895 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 909 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
896 { 910 {
897 m_log.WarnFormat( 911 m_log.WarnFormat(
@@ -1058,6 +1072,7 @@ namespace OpenSim.Region.Framework.Scenes
1058 1072
1059 RemoveFromPhysicalScene(); 1073 RemoveFromPhysicalScene();
1060 Velocity = Vector3.Zero; 1074 Velocity = Vector3.Zero;
1075 CheckLandingPoint(ref pos);
1061 AbsolutePosition = pos; 1076 AbsolutePosition = pos;
1062 AddToPhysicalScene(isFlying); 1077 AddToPhysicalScene(isFlying);
1063 1078
@@ -1071,6 +1086,7 @@ namespace OpenSim.Region.Framework.Scenes
1071 isFlying = PhysicsActor.Flying; 1086 isFlying = PhysicsActor.Flying;
1072 1087
1073 RemoveFromPhysicalScene(); 1088 RemoveFromPhysicalScene();
1089 CheckLandingPoint(ref pos);
1074 AbsolutePosition = pos; 1090 AbsolutePosition = pos;
1075 AddToPhysicalScene(isFlying); 1091 AddToPhysicalScene(isFlying);
1076 1092
@@ -1838,6 +1854,7 @@ namespace OpenSim.Region.Framework.Scenes
1838 if (part.SitTargetAvatar == UUID) 1854 if (part.SitTargetAvatar == UUID)
1839 part.SitTargetAvatar = UUID.Zero; 1855 part.SitTargetAvatar = UUID.Zero;
1840 1856
1857 part.ParentGroup.DeleteAvatar(UUID);
1841 ParentPosition = part.GetWorldPosition(); 1858 ParentPosition = part.GetWorldPosition();
1842 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1859 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1843 } 1860 }
@@ -2261,11 +2278,13 @@ namespace OpenSim.Region.Framework.Scenes
2261 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2278 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT;
2262 Rotation = sitTargetOrient; 2279 Rotation = sitTargetOrient;
2263 ParentPosition = part.AbsolutePosition; 2280 ParentPosition = part.AbsolutePosition;
2281 part.ParentGroup.AddAvatar(UUID);
2264 } 2282 }
2265 else 2283 else
2266 { 2284 {
2267 m_pos -= part.AbsolutePosition; 2285 m_pos -= part.AbsolutePosition;
2268 ParentPosition = part.AbsolutePosition; 2286 ParentPosition = part.AbsolutePosition;
2287 part.ParentGroup.AddAvatar(UUID);
2269 2288
2270// m_log.DebugFormat( 2289// m_log.DebugFormat(
2271// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", 2290// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
@@ -2755,6 +2774,9 @@ namespace OpenSim.Region.Framework.Scenes
2755 if (IsChildAgent) 2774 if (IsChildAgent)
2756 return; 2775 return;
2757 2776
2777 if (ParentID != 0)
2778 return;
2779
2758 Vector3 pos2 = AbsolutePosition; 2780 Vector3 pos2 = AbsolutePosition;
2759 Vector3 vel = Velocity; 2781 Vector3 vel = Velocity;
2760 int neighbor = 0; 2782 int neighbor = 0;
@@ -3358,6 +3380,8 @@ namespace OpenSim.Region.Framework.Scenes
3358 } 3380 }
3359 } 3381 }
3360 3382
3383 RaiseCollisionScriptEvents(coldata);
3384
3361 if (Invulnerable) 3385 if (Invulnerable)
3362 return; 3386 return;
3363 3387
@@ -3794,5 +3818,204 @@ namespace OpenSim.Region.Framework.Scenes
3794 m_reprioritization_called = false; 3818 m_reprioritization_called = false;
3795 } 3819 }
3796 } 3820 }
3821
3822 private void CheckLandingPoint(ref Vector3 pos)
3823 {
3824 // Never constrain lures
3825 if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
3826 return;
3827
3828 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3829 return;
3830
3831 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3832
3833 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3834 land.LandData.UserLocation != Vector3.Zero &&
3835 land.LandData.OwnerID != m_uuid &&
3836 (!m_scene.Permissions.IsGod(m_uuid)) &&
3837 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
3838 {
3839 float curr = Vector3.Distance(AbsolutePosition, pos);
3840 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
3841 pos = land.LandData.UserLocation;
3842 else
3843 ControllingClient.SendAlertMessage("Can't teleport closer to destination");
3844 }
3845 }
3846
3847 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3848 {
3849 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3850 if (land != null)
3851 {
3852 // If we come in via login, landmark or map, we want to
3853 // honor landing points. If we come in via Lure, we want
3854 // to ignore them.
3855 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3856 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3857 (m_teleportFlags & TeleportFlags.ViaLocation) != 0)
3858 {
3859 // Don't restrict gods, estate managers, or land owners to
3860 // the TP point. This behaviour mimics agni.
3861 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3862 land.LandData.UserLocation != Vector3.Zero &&
3863 GodLevel < 200 &&
3864 ((land.LandData.OwnerID != m_uuid &&
3865 (!m_scene.Permissions.IsGod(m_uuid)) &&
3866 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0))
3867 {
3868 pos = land.LandData.UserLocation;
3869 }
3870 }
3871
3872 land.SendLandUpdateToClient(ControllingClient);
3873 }
3874 }
3875
3876 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
3877 {
3878 List<uint> thisHitColliders = new List<uint>();
3879 List<uint> endedColliders = new List<uint>();
3880 List<uint> startedColliders = new List<uint>();
3881
3882 foreach (uint localid in coldata.Keys)
3883 {
3884 thisHitColliders.Add(localid);
3885 if (!m_lastColliders.Contains(localid))
3886 {
3887 startedColliders.Add(localid);
3888 }
3889 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
3890 }
3891
3892 // calculate things that ended colliding
3893 foreach (uint localID in m_lastColliders)
3894 {
3895 if (!thisHitColliders.Contains(localID))
3896 {
3897 endedColliders.Add(localID);
3898 }
3899 }
3900 //add the items that started colliding this time to the last colliders list.
3901 foreach (uint localID in startedColliders)
3902 {
3903 m_lastColliders.Add(localID);
3904 }
3905 // remove things that ended colliding from the last colliders list
3906 foreach (uint localID in endedColliders)
3907 {
3908 m_lastColliders.Remove(localID);
3909 }
3910
3911 // do event notification
3912 if (startedColliders.Count > 0)
3913 {
3914 ColliderArgs StartCollidingMessage = new ColliderArgs();
3915 List<DetectedObject> colliding = new List<DetectedObject>();
3916 foreach (uint localId in startedColliders)
3917 {
3918 if (localId == 0)
3919 continue;
3920
3921 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3922 string data = "";
3923 if (obj != null)
3924 {
3925 DetectedObject detobj = new DetectedObject();
3926 detobj.keyUUID = obj.UUID;
3927 detobj.nameStr = obj.Name;
3928 detobj.ownerUUID = obj.OwnerID;
3929 detobj.posVector = obj.AbsolutePosition;
3930 detobj.rotQuat = obj.GetWorldRotation();
3931 detobj.velVector = obj.Velocity;
3932 detobj.colliderType = 0;
3933 detobj.groupUUID = obj.GroupID;
3934 colliding.Add(detobj);
3935 }
3936 }
3937
3938 if (colliding.Count > 0)
3939 {
3940 StartCollidingMessage.Colliders = colliding;
3941
3942 foreach (SceneObjectGroup att in GetAttachments())
3943 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
3944 }
3945 }
3946
3947 if (endedColliders.Count > 0)
3948 {
3949 ColliderArgs EndCollidingMessage = new ColliderArgs();
3950 List<DetectedObject> colliding = new List<DetectedObject>();
3951 foreach (uint localId in endedColliders)
3952 {
3953 if (localId == 0)
3954 continue;
3955
3956 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3957 string data = "";
3958 if (obj != null)
3959 {
3960 DetectedObject detobj = new DetectedObject();
3961 detobj.keyUUID = obj.UUID;
3962 detobj.nameStr = obj.Name;
3963 detobj.ownerUUID = obj.OwnerID;
3964 detobj.posVector = obj.AbsolutePosition;
3965 detobj.rotQuat = obj.GetWorldRotation();
3966 detobj.velVector = obj.Velocity;
3967 detobj.colliderType = 0;
3968 detobj.groupUUID = obj.GroupID;
3969 colliding.Add(detobj);
3970 }
3971 }
3972
3973 if (colliding.Count > 0)
3974 {
3975 EndCollidingMessage.Colliders = colliding;
3976
3977 foreach (SceneObjectGroup att in GetAttachments())
3978 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
3979 }
3980 }
3981
3982 if (thisHitColliders.Count > 0)
3983 {
3984 ColliderArgs CollidingMessage = new ColliderArgs();
3985 List<DetectedObject> colliding = new List<DetectedObject>();
3986 foreach (uint localId in thisHitColliders)
3987 {
3988 if (localId == 0)
3989 continue;
3990
3991 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3992 string data = "";
3993 if (obj != null)
3994 {
3995 DetectedObject detobj = new DetectedObject();
3996 detobj.keyUUID = obj.UUID;
3997 detobj.nameStr = obj.Name;
3998 detobj.ownerUUID = obj.OwnerID;
3999 detobj.posVector = obj.AbsolutePosition;
4000 detobj.rotQuat = obj.GetWorldRotation();
4001 detobj.velVector = obj.Velocity;
4002 detobj.colliderType = 0;
4003 detobj.groupUUID = obj.GroupID;
4004 colliding.Add(detobj);
4005 }
4006 }
4007
4008 if (colliding.Count > 0)
4009 {
4010 CollidingMessage.Colliders = colliding;
4011
4012 lock (m_attachments)
4013 {
4014 foreach (SceneObjectGroup att in m_attachments)
4015 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4016 }
4017 }
4018 }
4019 }
3797 } 4020 }
3798} 4021}