diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fdf944b..fe2dfef 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 |
@@ -922,6 +923,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
922 | pos.Y = crossedBorder.BorderLine.Z - 1; | 923 | pos.Y = crossedBorder.BorderLine.Z - 1; |
923 | } | 924 | } |
924 | 925 | ||
926 | CheckAndAdjustLandingPoint(ref pos); | ||
927 | |||
925 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 928 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
926 | { | 929 | { |
927 | m_log.WarnFormat( | 930 | m_log.WarnFormat( |
@@ -1084,6 +1087,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1084 | 1087 | ||
1085 | RemoveFromPhysicalScene(); | 1088 | RemoveFromPhysicalScene(); |
1086 | Velocity = Vector3.Zero; | 1089 | Velocity = Vector3.Zero; |
1090 | CheckLandingPoint(ref pos); | ||
1087 | AbsolutePosition = pos; | 1091 | AbsolutePosition = pos; |
1088 | AddToPhysicalScene(isFlying); | 1092 | AddToPhysicalScene(isFlying); |
1089 | 1093 | ||
@@ -1097,6 +1101,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1097 | isFlying = PhysicsActor.Flying; | 1101 | isFlying = PhysicsActor.Flying; |
1098 | 1102 | ||
1099 | RemoveFromPhysicalScene(); | 1103 | RemoveFromPhysicalScene(); |
1104 | CheckLandingPoint(ref pos); | ||
1100 | AbsolutePosition = pos; | 1105 | AbsolutePosition = pos; |
1101 | AddToPhysicalScene(isFlying); | 1106 | AddToPhysicalScene(isFlying); |
1102 | 1107 | ||
@@ -1916,6 +1921,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1916 | if (part.SitTargetAvatar == UUID) | 1921 | if (part.SitTargetAvatar == UUID) |
1917 | part.SitTargetAvatar = UUID.Zero; | 1922 | part.SitTargetAvatar = UUID.Zero; |
1918 | 1923 | ||
1924 | part.ParentGroup.DeleteAvatar(UUID); | ||
1919 | ParentPosition = part.GetWorldPosition(); | 1925 | ParentPosition = part.GetWorldPosition(); |
1920 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1926 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1921 | } | 1927 | } |
@@ -2349,11 +2355,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2349 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2355 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; |
2350 | Rotation = sitTargetOrient; | 2356 | Rotation = sitTargetOrient; |
2351 | ParentPosition = part.AbsolutePosition; | 2357 | ParentPosition = part.AbsolutePosition; |
2358 | part.ParentGroup.AddAvatar(UUID); | ||
2352 | } | 2359 | } |
2353 | else | 2360 | else |
2354 | { | 2361 | { |
2355 | m_pos -= part.AbsolutePosition; | 2362 | m_pos -= part.AbsolutePosition; |
2356 | ParentPosition = part.AbsolutePosition; | 2363 | ParentPosition = part.AbsolutePosition; |
2364 | part.ParentGroup.AddAvatar(UUID); | ||
2357 | 2365 | ||
2358 | // m_log.DebugFormat( | 2366 | // m_log.DebugFormat( |
2359 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2367 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -3412,6 +3420,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3412 | } | 3420 | } |
3413 | } | 3421 | } |
3414 | 3422 | ||
3423 | RaiseCollisionScriptEvents(coldata); | ||
3424 | |||
3415 | if (Invulnerable) | 3425 | if (Invulnerable) |
3416 | return; | 3426 | return; |
3417 | 3427 | ||
@@ -3850,5 +3860,204 @@ namespace OpenSim.Region.Framework.Scenes | |||
3850 | m_reprioritization_called = false; | 3860 | m_reprioritization_called = false; |
3851 | } | 3861 | } |
3852 | } | 3862 | } |
3863 | |||
3864 | private void CheckLandingPoint(ref Vector3 pos) | ||
3865 | { | ||
3866 | // Never constrain lures | ||
3867 | if ((TeleportFlags & TeleportFlags.ViaLure) != 0) | ||
3868 | return; | ||
3869 | |||
3870 | if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) | ||
3871 | return; | ||
3872 | |||
3873 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
3874 | |||
3875 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
3876 | land.LandData.UserLocation != Vector3.Zero && | ||
3877 | land.LandData.OwnerID != m_uuid && | ||
3878 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
3879 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | ||
3880 | { | ||
3881 | float curr = Vector3.Distance(AbsolutePosition, pos); | ||
3882 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | ||
3883 | pos = land.LandData.UserLocation; | ||
3884 | else | ||
3885 | ControllingClient.SendAlertMessage("Can't teleport closer to destination"); | ||
3886 | } | ||
3887 | } | ||
3888 | |||
3889 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | ||
3890 | { | ||
3891 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
3892 | if (land != null) | ||
3893 | { | ||
3894 | // If we come in via login, landmark or map, we want to | ||
3895 | // honor landing points. If we come in via Lure, we want | ||
3896 | // to ignore them. | ||
3897 | if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || | ||
3898 | (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || | ||
3899 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0) | ||
3900 | { | ||
3901 | // Don't restrict gods, estate managers, or land owners to | ||
3902 | // the TP point. This behaviour mimics agni. | ||
3903 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
3904 | land.LandData.UserLocation != Vector3.Zero && | ||
3905 | GodLevel < 200 && | ||
3906 | ((land.LandData.OwnerID != m_uuid && | ||
3907 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
3908 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) | ||
3909 | { | ||
3910 | pos = land.LandData.UserLocation; | ||
3911 | } | ||
3912 | } | ||
3913 | |||
3914 | land.SendLandUpdateToClient(ControllingClient); | ||
3915 | } | ||
3916 | } | ||
3917 | |||
3918 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
3919 | { | ||
3920 | List<uint> thisHitColliders = new List<uint>(); | ||
3921 | List<uint> endedColliders = new List<uint>(); | ||
3922 | List<uint> startedColliders = new List<uint>(); | ||
3923 | |||
3924 | foreach (uint localid in coldata.Keys) | ||
3925 | { | ||
3926 | thisHitColliders.Add(localid); | ||
3927 | if (!m_lastColliders.Contains(localid)) | ||
3928 | { | ||
3929 | startedColliders.Add(localid); | ||
3930 | } | ||
3931 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3932 | } | ||
3933 | |||
3934 | // calculate things that ended colliding | ||
3935 | foreach (uint localID in m_lastColliders) | ||
3936 | { | ||
3937 | if (!thisHitColliders.Contains(localID)) | ||
3938 | { | ||
3939 | endedColliders.Add(localID); | ||
3940 | } | ||
3941 | } | ||
3942 | //add the items that started colliding this time to the last colliders list. | ||
3943 | foreach (uint localID in startedColliders) | ||
3944 | { | ||
3945 | m_lastColliders.Add(localID); | ||
3946 | } | ||
3947 | // remove things that ended colliding from the last colliders list | ||
3948 | foreach (uint localID in endedColliders) | ||
3949 | { | ||
3950 | m_lastColliders.Remove(localID); | ||
3951 | } | ||
3952 | |||
3953 | // do event notification | ||
3954 | if (startedColliders.Count > 0) | ||
3955 | { | ||
3956 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3957 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3958 | foreach (uint localId in startedColliders) | ||
3959 | { | ||
3960 | if (localId == 0) | ||
3961 | continue; | ||
3962 | |||
3963 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3964 | string data = ""; | ||
3965 | if (obj != null) | ||
3966 | { | ||
3967 | DetectedObject detobj = new DetectedObject(); | ||
3968 | detobj.keyUUID = obj.UUID; | ||
3969 | detobj.nameStr = obj.Name; | ||
3970 | detobj.ownerUUID = obj.OwnerID; | ||
3971 | detobj.posVector = obj.AbsolutePosition; | ||
3972 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3973 | detobj.velVector = obj.Velocity; | ||
3974 | detobj.colliderType = 0; | ||
3975 | detobj.groupUUID = obj.GroupID; | ||
3976 | colliding.Add(detobj); | ||
3977 | } | ||
3978 | } | ||
3979 | |||
3980 | if (colliding.Count > 0) | ||
3981 | { | ||
3982 | StartCollidingMessage.Colliders = colliding; | ||
3983 | |||
3984 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3985 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3986 | } | ||
3987 | } | ||
3988 | |||
3989 | if (endedColliders.Count > 0) | ||
3990 | { | ||
3991 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3992 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3993 | foreach (uint localId in endedColliders) | ||
3994 | { | ||
3995 | if (localId == 0) | ||
3996 | continue; | ||
3997 | |||
3998 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3999 | string data = ""; | ||
4000 | if (obj != null) | ||
4001 | { | ||
4002 | DetectedObject detobj = new DetectedObject(); | ||
4003 | detobj.keyUUID = obj.UUID; | ||
4004 | detobj.nameStr = obj.Name; | ||
4005 | detobj.ownerUUID = obj.OwnerID; | ||
4006 | detobj.posVector = obj.AbsolutePosition; | ||
4007 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4008 | detobj.velVector = obj.Velocity; | ||
4009 | detobj.colliderType = 0; | ||
4010 | detobj.groupUUID = obj.GroupID; | ||
4011 | colliding.Add(detobj); | ||
4012 | } | ||
4013 | } | ||
4014 | |||
4015 | if (colliding.Count > 0) | ||
4016 | { | ||
4017 | EndCollidingMessage.Colliders = colliding; | ||
4018 | |||
4019 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4020 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
4021 | } | ||
4022 | } | ||
4023 | |||
4024 | if (thisHitColliders.Count > 0) | ||
4025 | { | ||
4026 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
4027 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4028 | foreach (uint localId in thisHitColliders) | ||
4029 | { | ||
4030 | if (localId == 0) | ||
4031 | continue; | ||
4032 | |||
4033 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4034 | string data = ""; | ||
4035 | if (obj != null) | ||
4036 | { | ||
4037 | DetectedObject detobj = new DetectedObject(); | ||
4038 | detobj.keyUUID = obj.UUID; | ||
4039 | detobj.nameStr = obj.Name; | ||
4040 | detobj.ownerUUID = obj.OwnerID; | ||
4041 | detobj.posVector = obj.AbsolutePosition; | ||
4042 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4043 | detobj.velVector = obj.Velocity; | ||
4044 | detobj.colliderType = 0; | ||
4045 | detobj.groupUUID = obj.GroupID; | ||
4046 | colliding.Add(detobj); | ||
4047 | } | ||
4048 | } | ||
4049 | |||
4050 | if (colliding.Count > 0) | ||
4051 | { | ||
4052 | CollidingMessage.Colliders = colliding; | ||
4053 | |||
4054 | lock (m_attachments) | ||
4055 | { | ||
4056 | foreach (SceneObjectGroup att in m_attachments) | ||
4057 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4058 | } | ||
4059 | } | ||
4060 | } | ||
4061 | } | ||
3853 | } | 4062 | } |
3854 | } | 4063 | } |