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 5b9438b..3c97852 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>
@@ -901,6 +913,8 @@ namespace OpenSim.Region.Framework.Scenes
901 pos.Y = crossedBorder.BorderLine.Z - 1; 913 pos.Y = crossedBorder.BorderLine.Z - 1;
902 } 914 }
903 915
916 CheckAndAdjustLandingPoint(ref pos);
917
904 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 918 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
905 { 919 {
906 m_log.WarnFormat( 920 m_log.WarnFormat(
@@ -1067,6 +1081,7 @@ namespace OpenSim.Region.Framework.Scenes
1067 1081
1068 RemoveFromPhysicalScene(); 1082 RemoveFromPhysicalScene();
1069 Velocity = Vector3.Zero; 1083 Velocity = Vector3.Zero;
1084 CheckLandingPoint(ref pos);
1070 AbsolutePosition = pos; 1085 AbsolutePosition = pos;
1071 AddToPhysicalScene(isFlying); 1086 AddToPhysicalScene(isFlying);
1072 1087
@@ -1080,6 +1095,7 @@ namespace OpenSim.Region.Framework.Scenes
1080 isFlying = PhysicsActor.Flying; 1095 isFlying = PhysicsActor.Flying;
1081 1096
1082 RemoveFromPhysicalScene(); 1097 RemoveFromPhysicalScene();
1098 CheckLandingPoint(ref pos);
1083 AbsolutePosition = pos; 1099 AbsolutePosition = pos;
1084 AddToPhysicalScene(isFlying); 1100 AddToPhysicalScene(isFlying);
1085 1101
@@ -1847,6 +1863,7 @@ namespace OpenSim.Region.Framework.Scenes
1847 if (part.SitTargetAvatar == UUID) 1863 if (part.SitTargetAvatar == UUID)
1848 part.SitTargetAvatar = UUID.Zero; 1864 part.SitTargetAvatar = UUID.Zero;
1849 1865
1866 part.ParentGroup.DeleteAvatar(UUID);
1850 ParentPosition = part.GetWorldPosition(); 1867 ParentPosition = part.GetWorldPosition();
1851 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1868 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1852 } 1869 }
@@ -2270,11 +2287,13 @@ namespace OpenSim.Region.Framework.Scenes
2270 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; 2287 m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT;
2271 Rotation = sitTargetOrient; 2288 Rotation = sitTargetOrient;
2272 ParentPosition = part.AbsolutePosition; 2289 ParentPosition = part.AbsolutePosition;
2290 part.ParentGroup.AddAvatar(UUID);
2273 } 2291 }
2274 else 2292 else
2275 { 2293 {
2276 m_pos -= part.AbsolutePosition; 2294 m_pos -= part.AbsolutePosition;
2277 ParentPosition = part.AbsolutePosition; 2295 ParentPosition = part.AbsolutePosition;
2296 part.ParentGroup.AddAvatar(UUID);
2278 2297
2279// m_log.DebugFormat( 2298// m_log.DebugFormat(
2280// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", 2299// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
@@ -2746,6 +2765,9 @@ namespace OpenSim.Region.Framework.Scenes
2746 if (IsChildAgent) 2765 if (IsChildAgent)
2747 return; 2766 return;
2748 2767
2768 if (ParentID != 0)
2769 return;
2770
2749 Vector3 pos2 = AbsolutePosition; 2771 Vector3 pos2 = AbsolutePosition;
2750 Vector3 vel = Velocity; 2772 Vector3 vel = Velocity;
2751 int neighbor = 0; 2773 int neighbor = 0;
@@ -3349,6 +3371,8 @@ namespace OpenSim.Region.Framework.Scenes
3349 } 3371 }
3350 } 3372 }
3351 3373
3374 RaiseCollisionScriptEvents(coldata);
3375
3352 if (Invulnerable) 3376 if (Invulnerable)
3353 return; 3377 return;
3354 3378
@@ -3785,5 +3809,204 @@ namespace OpenSim.Region.Framework.Scenes
3785 m_reprioritization_called = false; 3809 m_reprioritization_called = false;
3786 } 3810 }
3787 } 3811 }
3812
3813 private void CheckLandingPoint(ref Vector3 pos)
3814 {
3815 // Never constrain lures
3816 if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
3817 return;
3818
3819 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
3820 return;
3821
3822 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3823
3824 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3825 land.LandData.UserLocation != Vector3.Zero &&
3826 land.LandData.OwnerID != m_uuid &&
3827 (!m_scene.Permissions.IsGod(m_uuid)) &&
3828 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
3829 {
3830 float curr = Vector3.Distance(AbsolutePosition, pos);
3831 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
3832 pos = land.LandData.UserLocation;
3833 else
3834 ControllingClient.SendAlertMessage("Can't teleport closer to destination");
3835 }
3836 }
3837
3838 private void CheckAndAdjustLandingPoint(ref Vector3 pos)
3839 {
3840 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
3841 if (land != null)
3842 {
3843 // If we come in via login, landmark or map, we want to
3844 // honor landing points. If we come in via Lure, we want
3845 // to ignore them.
3846 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
3847 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
3848 (m_teleportFlags & TeleportFlags.ViaLocation) != 0)
3849 {
3850 // Don't restrict gods, estate managers, or land owners to
3851 // the TP point. This behaviour mimics agni.
3852 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
3853 land.LandData.UserLocation != Vector3.Zero &&
3854 GodLevel < 200 &&
3855 ((land.LandData.OwnerID != m_uuid &&
3856 (!m_scene.Permissions.IsGod(m_uuid)) &&
3857 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0))
3858 {
3859 pos = land.LandData.UserLocation;
3860 }
3861 }
3862
3863 land.SendLandUpdateToClient(ControllingClient);
3864 }
3865 }
3866
3867 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
3868 {
3869 List<uint> thisHitColliders = new List<uint>();
3870 List<uint> endedColliders = new List<uint>();
3871 List<uint> startedColliders = new List<uint>();
3872
3873 foreach (uint localid in coldata.Keys)
3874 {
3875 thisHitColliders.Add(localid);
3876 if (!m_lastColliders.Contains(localid))
3877 {
3878 startedColliders.Add(localid);
3879 }
3880 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
3881 }
3882
3883 // calculate things that ended colliding
3884 foreach (uint localID in m_lastColliders)
3885 {
3886 if (!thisHitColliders.Contains(localID))
3887 {
3888 endedColliders.Add(localID);
3889 }
3890 }
3891 //add the items that started colliding this time to the last colliders list.
3892 foreach (uint localID in startedColliders)
3893 {
3894 m_lastColliders.Add(localID);
3895 }
3896 // remove things that ended colliding from the last colliders list
3897 foreach (uint localID in endedColliders)
3898 {
3899 m_lastColliders.Remove(localID);
3900 }
3901
3902 // do event notification
3903 if (startedColliders.Count > 0)
3904 {
3905 ColliderArgs StartCollidingMessage = new ColliderArgs();
3906 List<DetectedObject> colliding = new List<DetectedObject>();
3907 foreach (uint localId in startedColliders)
3908 {
3909 if (localId == 0)
3910 continue;
3911
3912 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3913 string data = "";
3914 if (obj != null)
3915 {
3916 DetectedObject detobj = new DetectedObject();
3917 detobj.keyUUID = obj.UUID;
3918 detobj.nameStr = obj.Name;
3919 detobj.ownerUUID = obj.OwnerID;
3920 detobj.posVector = obj.AbsolutePosition;
3921 detobj.rotQuat = obj.GetWorldRotation();
3922 detobj.velVector = obj.Velocity;
3923 detobj.colliderType = 0;
3924 detobj.groupUUID = obj.GroupID;
3925 colliding.Add(detobj);
3926 }
3927 }
3928
3929 if (colliding.Count > 0)
3930 {
3931 StartCollidingMessage.Colliders = colliding;
3932
3933 foreach (SceneObjectGroup att in GetAttachments())
3934 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
3935 }
3936 }
3937
3938 if (endedColliders.Count > 0)
3939 {
3940 ColliderArgs EndCollidingMessage = new ColliderArgs();
3941 List<DetectedObject> colliding = new List<DetectedObject>();
3942 foreach (uint localId in endedColliders)
3943 {
3944 if (localId == 0)
3945 continue;
3946
3947 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3948 string data = "";
3949 if (obj != null)
3950 {
3951 DetectedObject detobj = new DetectedObject();
3952 detobj.keyUUID = obj.UUID;
3953 detobj.nameStr = obj.Name;
3954 detobj.ownerUUID = obj.OwnerID;
3955 detobj.posVector = obj.AbsolutePosition;
3956 detobj.rotQuat = obj.GetWorldRotation();
3957 detobj.velVector = obj.Velocity;
3958 detobj.colliderType = 0;
3959 detobj.groupUUID = obj.GroupID;
3960 colliding.Add(detobj);
3961 }
3962 }
3963
3964 if (colliding.Count > 0)
3965 {
3966 EndCollidingMessage.Colliders = colliding;
3967
3968 foreach (SceneObjectGroup att in GetAttachments())
3969 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
3970 }
3971 }
3972
3973 if (thisHitColliders.Count > 0)
3974 {
3975 ColliderArgs CollidingMessage = new ColliderArgs();
3976 List<DetectedObject> colliding = new List<DetectedObject>();
3977 foreach (uint localId in thisHitColliders)
3978 {
3979 if (localId == 0)
3980 continue;
3981
3982 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3983 string data = "";
3984 if (obj != null)
3985 {
3986 DetectedObject detobj = new DetectedObject();
3987 detobj.keyUUID = obj.UUID;
3988 detobj.nameStr = obj.Name;
3989 detobj.ownerUUID = obj.OwnerID;
3990 detobj.posVector = obj.AbsolutePosition;
3991 detobj.rotQuat = obj.GetWorldRotation();
3992 detobj.velVector = obj.Velocity;
3993 detobj.colliderType = 0;
3994 detobj.groupUUID = obj.GroupID;
3995 colliding.Add(detobj);
3996 }
3997 }
3998
3999 if (colliding.Count > 0)
4000 {
4001 CollidingMessage.Colliders = colliding;
4002
4003 lock (m_attachments)
4004 {
4005 foreach (SceneObjectGroup att in m_attachments)
4006 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4007 }
4008 }
4009 }
4010 }
3788 } 4011 }
3789} 4012}