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 fa731a7..5dda9e1 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
@@ -542,8 +543,12 @@ namespace OpenSim.Region.Framework.Scenes
542 } 543 }
543 } 544 }
544 545
545 m_pos = value; 546 // Don't update while sitting
546 ParentPosition = Vector3.Zero; 547 if (ParentID == 0)
548 {
549 m_pos = value;
550 ParentPosition = Vector3.Zero;
551 }
547 552
548// m_log.DebugFormat( 553// m_log.DebugFormat(
549// "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", 554// "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
@@ -558,6 +563,13 @@ namespace OpenSim.Region.Framework.Scenes
558 public Vector3 OffsetPosition 563 public Vector3 OffsetPosition
559 { 564 {
560 get { return m_pos; } 565 get { return m_pos; }
566 set
567 {
568 // There is no offset position when not seated
569 if (ParentID == 0)
570 return;
571 m_pos = value;
572 }
561 } 573 }
562 574
563 /// <summary> 575 /// <summary>
@@ -877,6 +889,8 @@ namespace OpenSim.Region.Framework.Scenes
877 pos.Y = crossedBorder.BorderLine.Z - 1; 889 pos.Y = crossedBorder.BorderLine.Z - 1;
878 } 890 }
879 891
892 CheckAndAdjustLandingPoint(ref pos);
893
880 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 894 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
881 { 895 {
882 m_log.WarnFormat( 896 m_log.WarnFormat(
@@ -1043,6 +1057,7 @@ namespace OpenSim.Region.Framework.Scenes
1043 1057
1044 RemoveFromPhysicalScene(); 1058 RemoveFromPhysicalScene();
1045 Velocity = Vector3.Zero; 1059 Velocity = Vector3.Zero;
1060 CheckLandingPoint(ref pos);
1046 AbsolutePosition = pos; 1061 AbsolutePosition = pos;
1047 AddToPhysicalScene(isFlying); 1062 AddToPhysicalScene(isFlying);
1048 1063
@@ -1056,6 +1071,7 @@ namespace OpenSim.Region.Framework.Scenes
1056 isFlying = PhysicsActor.Flying; 1071 isFlying = PhysicsActor.Flying;
1057 1072
1058 RemoveFromPhysicalScene(); 1073 RemoveFromPhysicalScene();
1074 CheckLandingPoint(ref pos);
1059 AbsolutePosition = pos; 1075 AbsolutePosition = pos;
1060 AddToPhysicalScene(isFlying); 1076 AddToPhysicalScene(isFlying);
1061 1077
@@ -1823,6 +1839,7 @@ namespace OpenSim.Region.Framework.Scenes
1823 if (part.SitTargetAvatar == UUID) 1839 if (part.SitTargetAvatar == UUID)
1824 part.SitTargetAvatar = UUID.Zero; 1840 part.SitTargetAvatar = UUID.Zero;
1825 1841
1842 part.ParentGroup.DeleteAvatar(UUID);
1826 ParentPosition = part.GetWorldPosition(); 1843 ParentPosition = part.GetWorldPosition();
1827 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1844 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1828 } 1845 }
@@ -2246,11 +2263,13 @@ namespace OpenSim.Region.Framework.Scenes
2246 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2263 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT;
2247 Rotation = sitTargetOrient; 2264 Rotation = sitTargetOrient;
2248 ParentPosition = part.AbsolutePosition; 2265 ParentPosition = part.AbsolutePosition;
2266 part.ParentGroup.AddAvatar(UUID);
2249 } 2267 }
2250 else 2268 else
2251 { 2269 {
2252 m_pos -= part.AbsolutePosition; 2270 m_pos -= part.AbsolutePosition;
2253 ParentPosition = part.AbsolutePosition; 2271 ParentPosition = part.AbsolutePosition;
2272 part.ParentGroup.AddAvatar(UUID);
2254 2273
2255// m_log.DebugFormat( 2274// m_log.DebugFormat(
2256// "[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",
@@ -2740,6 +2759,9 @@ namespace OpenSim.Region.Framework.Scenes
2740 if (IsChildAgent) 2759 if (IsChildAgent)
2741 return; 2760 return;
2742 2761
2762 if (ParentID != 0)
2763 return;
2764
2743 Vector3 pos2 = AbsolutePosition; 2765 Vector3 pos2 = AbsolutePosition;
2744 Vector3 vel = Velocity; 2766 Vector3 vel = Velocity;
2745 int neighbor = 0; 2767 int neighbor = 0;
@@ -3343,6 +3365,8 @@ namespace OpenSim.Region.Framework.Scenes
3343 } 3365 }
3344 } 3366 }
3345 3367
3368 RaiseCollisionScriptEvents(coldata);
3369
3346 if (Invulnerable) 3370 if (Invulnerable)
3347 return; 3371 return;
3348 3372
@@ -3779,5 +3803,204 @@ namespace OpenSim.Region.Framework.Scenes
3779 m_reprioritization_called = false; 3803 m_reprioritization_called = false;
3780 } 3804 }
3781 } 3805 }
3806
3807 private void CheckLandingPoint(ref Vector3 pos)
3808 {
3809 // Never constrain lures
3810 if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
3811 return;
3812
3813 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3814 return;
3815
3816 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3817
3818 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3819 land.LandData.UserLocation != Vector3.Zero &&
3820 land.LandData.OwnerID != m_uuid &&
3821 (!m_scene.Permissions.IsGod(m_uuid)) &&
3822 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
3823 {
3824 float curr = Vector3.Distance(AbsolutePosition, pos);
3825 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
3826 pos = land.LandData.UserLocation;
3827 else
3828 ControllingClient.SendAlertMessage("Can't teleport closer to destination");
3829 }
3830 }
3831
3832 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3833 {
3834 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3835 if (land != null)
3836 {
3837 // If we come in via login, landmark or map, we want to
3838 // honor landing points. If we come in via Lure, we want
3839 // to ignore them.
3840 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3841 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3842 (m_teleportFlags & TeleportFlags.ViaLocation) != 0)
3843 {
3844 // Don't restrict gods, estate managers, or land owners to
3845 // the TP point. This behaviour mimics agni.
3846 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3847 land.LandData.UserLocation != Vector3.Zero &&
3848 GodLevel < 200 &&
3849 ((land.LandData.OwnerID != m_uuid &&
3850 (!m_scene.Permissions.IsGod(m_uuid)) &&
3851 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0))
3852 {
3853 pos = land.LandData.UserLocation;
3854 }
3855 }
3856
3857 land.SendLandUpdateToClient(ControllingClient);
3858 }
3859 }
3860
3861 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
3862 {
3863 List<uint> thisHitColliders = new List<uint>();
3864 List<uint> endedColliders = new List<uint>();
3865 List<uint> startedColliders = new List<uint>();
3866
3867 foreach (uint localid in coldata.Keys)
3868 {
3869 thisHitColliders.Add(localid);
3870 if (!m_lastColliders.Contains(localid))
3871 {
3872 startedColliders.Add(localid);
3873 }
3874 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
3875 }
3876
3877 // calculate things that ended colliding
3878 foreach (uint localID in m_lastColliders)
3879 {
3880 if (!thisHitColliders.Contains(localID))
3881 {
3882 endedColliders.Add(localID);
3883 }
3884 }
3885 //add the items that started colliding this time to the last colliders list.
3886 foreach (uint localID in startedColliders)
3887 {
3888 m_lastColliders.Add(localID);
3889 }
3890 // remove things that ended colliding from the last colliders list
3891 foreach (uint localID in endedColliders)
3892 {
3893 m_lastColliders.Remove(localID);
3894 }
3895
3896 // do event notification
3897 if (startedColliders.Count > 0)
3898 {
3899 ColliderArgs StartCollidingMessage = new ColliderArgs();
3900 List<DetectedObject> colliding = new List<DetectedObject>();
3901 foreach (uint localId in startedColliders)
3902 {
3903 if (localId == 0)
3904 continue;
3905
3906 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3907 string data = "";
3908 if (obj != null)
3909 {
3910 DetectedObject detobj = new DetectedObject();
3911 detobj.keyUUID = obj.UUID;
3912 detobj.nameStr = obj.Name;
3913 detobj.ownerUUID = obj.OwnerID;
3914 detobj.posVector = obj.AbsolutePosition;
3915 detobj.rotQuat = obj.GetWorldRotation();
3916 detobj.velVector = obj.Velocity;
3917 detobj.colliderType = 0;
3918 detobj.groupUUID = obj.GroupID;
3919 colliding.Add(detobj);
3920 }
3921 }
3922
3923 if (colliding.Count > 0)
3924 {
3925 StartCollidingMessage.Colliders = colliding;
3926
3927 foreach (SceneObjectGroup att in GetAttachments())
3928 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
3929 }
3930 }
3931
3932 if (endedColliders.Count > 0)
3933 {
3934 ColliderArgs EndCollidingMessage = new ColliderArgs();
3935 List<DetectedObject> colliding = new List<DetectedObject>();
3936 foreach (uint localId in endedColliders)
3937 {
3938 if (localId == 0)
3939 continue;
3940
3941 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3942 string data = "";
3943 if (obj != null)
3944 {
3945 DetectedObject detobj = new DetectedObject();
3946 detobj.keyUUID = obj.UUID;
3947 detobj.nameStr = obj.Name;
3948 detobj.ownerUUID = obj.OwnerID;
3949 detobj.posVector = obj.AbsolutePosition;
3950 detobj.rotQuat = obj.GetWorldRotation();
3951 detobj.velVector = obj.Velocity;
3952 detobj.colliderType = 0;
3953 detobj.groupUUID = obj.GroupID;
3954 colliding.Add(detobj);
3955 }
3956 }
3957
3958 if (colliding.Count > 0)
3959 {
3960 EndCollidingMessage.Colliders = colliding;
3961
3962 foreach (SceneObjectGroup att in GetAttachments())
3963 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
3964 }
3965 }
3966
3967 if (thisHitColliders.Count > 0)
3968 {
3969 ColliderArgs CollidingMessage = new ColliderArgs();
3970 List<DetectedObject> colliding = new List<DetectedObject>();
3971 foreach (uint localId in thisHitColliders)
3972 {
3973 if (localId == 0)
3974 continue;
3975
3976 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3977 string data = "";
3978 if (obj != null)
3979 {
3980 DetectedObject detobj = new DetectedObject();
3981 detobj.keyUUID = obj.UUID;
3982 detobj.nameStr = obj.Name;
3983 detobj.ownerUUID = obj.OwnerID;
3984 detobj.posVector = obj.AbsolutePosition;
3985 detobj.rotQuat = obj.GetWorldRotation();
3986 detobj.velVector = obj.Velocity;
3987 detobj.colliderType = 0;
3988 detobj.groupUUID = obj.GroupID;
3989 colliding.Add(detobj);
3990 }
3991 }
3992
3993 if (colliding.Count > 0)
3994 {
3995 CollidingMessage.Colliders = colliding;
3996
3997 lock (m_attachments)
3998 {
3999 foreach (SceneObjectGroup att in m_attachments)
4000 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4001 }
4002 }
4003 }
4004 }
3782 } 4005 }
3783} 4006}