diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 99be46d..eb3597d 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 | ||
@@ -3401,6 +3406,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3401 | } | 3406 | } |
3402 | } | 3407 | } |
3403 | 3408 | ||
3409 | RaiseCollisionScriptEvents(coldata); | ||
3410 | |||
3404 | if (Invulnerable) | 3411 | if (Invulnerable) |
3405 | return; | 3412 | return; |
3406 | 3413 | ||
@@ -3839,5 +3846,204 @@ namespace OpenSim.Region.Framework.Scenes | |||
3839 | m_reprioritization_called = false; | 3846 | m_reprioritization_called = false; |
3840 | } | 3847 | } |
3841 | } | 3848 | } |
3849 | |||
3850 | private void CheckLandingPoint(ref Vector3 pos) | ||
3851 | { | ||
3852 | // Never constrain lures | ||
3853 | if ((TeleportFlags & TeleportFlags.ViaLure) != 0) | ||
3854 | return; | ||
3855 | |||
3856 | if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) | ||
3857 | return; | ||
3858 | |||
3859 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
3860 | |||
3861 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
3862 | land.LandData.UserLocation != Vector3.Zero && | ||
3863 | land.LandData.OwnerID != m_uuid && | ||
3864 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
3865 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | ||
3866 | { | ||
3867 | float curr = Vector3.Distance(AbsolutePosition, pos); | ||
3868 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | ||
3869 | pos = land.LandData.UserLocation; | ||
3870 | else | ||
3871 | ControllingClient.SendAlertMessage("Can't teleport closer to destination"); | ||
3872 | } | ||
3873 | } | ||
3874 | |||
3875 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | ||
3876 | { | ||
3877 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
3878 | if (land != null) | ||
3879 | { | ||
3880 | // If we come in via login, landmark or map, we want to | ||
3881 | // honor landing points. If we come in via Lure, we want | ||
3882 | // to ignore them. | ||
3883 | if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || | ||
3884 | (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || | ||
3885 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0) | ||
3886 | { | ||
3887 | // Don't restrict gods, estate managers, or land owners to | ||
3888 | // the TP point. This behaviour mimics agni. | ||
3889 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
3890 | land.LandData.UserLocation != Vector3.Zero && | ||
3891 | GodLevel < 200 && | ||
3892 | ((land.LandData.OwnerID != m_uuid && | ||
3893 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
3894 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) | ||
3895 | { | ||
3896 | pos = land.LandData.UserLocation; | ||
3897 | } | ||
3898 | } | ||
3899 | |||
3900 | land.SendLandUpdateToClient(ControllingClient); | ||
3901 | } | ||
3902 | } | ||
3903 | |||
3904 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
3905 | { | ||
3906 | List<uint> thisHitColliders = new List<uint>(); | ||
3907 | List<uint> endedColliders = new List<uint>(); | ||
3908 | List<uint> startedColliders = new List<uint>(); | ||
3909 | |||
3910 | foreach (uint localid in coldata.Keys) | ||
3911 | { | ||
3912 | thisHitColliders.Add(localid); | ||
3913 | if (!m_lastColliders.Contains(localid)) | ||
3914 | { | ||
3915 | startedColliders.Add(localid); | ||
3916 | } | ||
3917 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3918 | } | ||
3919 | |||
3920 | // calculate things that ended colliding | ||
3921 | foreach (uint localID in m_lastColliders) | ||
3922 | { | ||
3923 | if (!thisHitColliders.Contains(localID)) | ||
3924 | { | ||
3925 | endedColliders.Add(localID); | ||
3926 | } | ||
3927 | } | ||
3928 | //add the items that started colliding this time to the last colliders list. | ||
3929 | foreach (uint localID in startedColliders) | ||
3930 | { | ||
3931 | m_lastColliders.Add(localID); | ||
3932 | } | ||
3933 | // remove things that ended colliding from the last colliders list | ||
3934 | foreach (uint localID in endedColliders) | ||
3935 | { | ||
3936 | m_lastColliders.Remove(localID); | ||
3937 | } | ||
3938 | |||
3939 | // do event notification | ||
3940 | if (startedColliders.Count > 0) | ||
3941 | { | ||
3942 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3943 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3944 | foreach (uint localId in startedColliders) | ||
3945 | { | ||
3946 | if (localId == 0) | ||
3947 | continue; | ||
3948 | |||
3949 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3950 | string data = ""; | ||
3951 | if (obj != null) | ||
3952 | { | ||
3953 | DetectedObject detobj = new DetectedObject(); | ||
3954 | detobj.keyUUID = obj.UUID; | ||
3955 | detobj.nameStr = obj.Name; | ||
3956 | detobj.ownerUUID = obj.OwnerID; | ||
3957 | detobj.posVector = obj.AbsolutePosition; | ||
3958 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3959 | detobj.velVector = obj.Velocity; | ||
3960 | detobj.colliderType = 0; | ||
3961 | detobj.groupUUID = obj.GroupID; | ||
3962 | colliding.Add(detobj); | ||
3963 | } | ||
3964 | } | ||
3965 | |||
3966 | if (colliding.Count > 0) | ||
3967 | { | ||
3968 | StartCollidingMessage.Colliders = colliding; | ||
3969 | |||
3970 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3971 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3972 | } | ||
3973 | } | ||
3974 | |||
3975 | if (endedColliders.Count > 0) | ||
3976 | { | ||
3977 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3978 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3979 | foreach (uint localId in endedColliders) | ||
3980 | { | ||
3981 | if (localId == 0) | ||
3982 | continue; | ||
3983 | |||
3984 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3985 | string data = ""; | ||
3986 | if (obj != null) | ||
3987 | { | ||
3988 | DetectedObject detobj = new DetectedObject(); | ||
3989 | detobj.keyUUID = obj.UUID; | ||
3990 | detobj.nameStr = obj.Name; | ||
3991 | detobj.ownerUUID = obj.OwnerID; | ||
3992 | detobj.posVector = obj.AbsolutePosition; | ||
3993 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3994 | detobj.velVector = obj.Velocity; | ||
3995 | detobj.colliderType = 0; | ||
3996 | detobj.groupUUID = obj.GroupID; | ||
3997 | colliding.Add(detobj); | ||
3998 | } | ||
3999 | } | ||
4000 | |||
4001 | if (colliding.Count > 0) | ||
4002 | { | ||
4003 | EndCollidingMessage.Colliders = colliding; | ||
4004 | |||
4005 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4006 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
4007 | } | ||
4008 | } | ||
4009 | |||
4010 | if (thisHitColliders.Count > 0) | ||
4011 | { | ||
4012 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
4013 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4014 | foreach (uint localId in thisHitColliders) | ||
4015 | { | ||
4016 | if (localId == 0) | ||
4017 | continue; | ||
4018 | |||
4019 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4020 | string data = ""; | ||
4021 | if (obj != null) | ||
4022 | { | ||
4023 | DetectedObject detobj = new DetectedObject(); | ||
4024 | detobj.keyUUID = obj.UUID; | ||
4025 | detobj.nameStr = obj.Name; | ||
4026 | detobj.ownerUUID = obj.OwnerID; | ||
4027 | detobj.posVector = obj.AbsolutePosition; | ||
4028 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4029 | detobj.velVector = obj.Velocity; | ||
4030 | detobj.colliderType = 0; | ||
4031 | detobj.groupUUID = obj.GroupID; | ||
4032 | colliding.Add(detobj); | ||
4033 | } | ||
4034 | } | ||
4035 | |||
4036 | if (colliding.Count > 0) | ||
4037 | { | ||
4038 | CollidingMessage.Colliders = colliding; | ||
4039 | |||
4040 | lock (m_attachments) | ||
4041 | { | ||
4042 | foreach (SceneObjectGroup att in m_attachments) | ||
4043 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
4044 | } | ||
4045 | } | ||
4046 | } | ||
4047 | } | ||
3842 | } | 4048 | } |
3843 | } | 4049 | } |