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 7d901c9..d89c1c0 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 |
@@ -904,6 +905,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
904 | pos.Y = crossedBorder.BorderLine.Z - 1; | 905 | pos.Y = crossedBorder.BorderLine.Z - 1; |
905 | } | 906 | } |
906 | 907 | ||
908 | CheckAndAdjustLandingPoint(ref pos); | ||
909 | |||
907 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 910 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
908 | { | 911 | { |
909 | m_log.WarnFormat( | 912 | m_log.WarnFormat( |
@@ -1066,6 +1069,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1066 | 1069 | ||
1067 | RemoveFromPhysicalScene(); | 1070 | RemoveFromPhysicalScene(); |
1068 | Velocity = Vector3.Zero; | 1071 | Velocity = Vector3.Zero; |
1072 | CheckLandingPoint(ref pos); | ||
1069 | AbsolutePosition = pos; | 1073 | AbsolutePosition = pos; |
1070 | AddToPhysicalScene(isFlying); | 1074 | AddToPhysicalScene(isFlying); |
1071 | 1075 | ||
@@ -1079,6 +1083,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1079 | isFlying = PhysicsActor.Flying; | 1083 | isFlying = PhysicsActor.Flying; |
1080 | 1084 | ||
1081 | RemoveFromPhysicalScene(); | 1085 | RemoveFromPhysicalScene(); |
1086 | CheckLandingPoint(ref pos); | ||
1082 | AbsolutePosition = pos; | 1087 | AbsolutePosition = pos; |
1083 | AddToPhysicalScene(isFlying); | 1088 | AddToPhysicalScene(isFlying); |
1084 | 1089 | ||
@@ -1846,6 +1851,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1846 | if (part.SitTargetAvatar == UUID) | 1851 | if (part.SitTargetAvatar == UUID) |
1847 | part.SitTargetAvatar = UUID.Zero; | 1852 | part.SitTargetAvatar = UUID.Zero; |
1848 | 1853 | ||
1854 | part.ParentGroup.DeleteAvatar(UUID); | ||
1849 | ParentPosition = part.GetWorldPosition(); | 1855 | ParentPosition = part.GetWorldPosition(); |
1850 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1856 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1851 | } | 1857 | } |
@@ -2269,11 +2275,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2269 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2275 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; |
2270 | Rotation = sitTargetOrient; | 2276 | Rotation = sitTargetOrient; |
2271 | ParentPosition = part.AbsolutePosition; | 2277 | ParentPosition = part.AbsolutePosition; |
2278 | part.ParentGroup.AddAvatar(UUID); | ||
2272 | } | 2279 | } |
2273 | else | 2280 | else |
2274 | { | 2281 | { |
2275 | m_pos -= part.AbsolutePosition; | 2282 | m_pos -= part.AbsolutePosition; |
2276 | ParentPosition = part.AbsolutePosition; | 2283 | ParentPosition = part.AbsolutePosition; |
2284 | part.ParentGroup.AddAvatar(UUID); | ||
2277 | 2285 | ||
2278 | // m_log.DebugFormat( | 2286 | // m_log.DebugFormat( |
2279 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2287 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -3340,6 +3348,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3340 | } | 3348 | } |
3341 | } | 3349 | } |
3342 | 3350 | ||
3351 | RaiseCollisionScriptEvents(coldata); | ||
3352 | |||
3343 | if (Invulnerable) | 3353 | if (Invulnerable) |
3344 | return; | 3354 | return; |
3345 | 3355 | ||
@@ -3776,5 +3786,204 @@ namespace OpenSim.Region.Framework.Scenes | |||
3776 | m_reprioritization_called = false; | 3786 | m_reprioritization_called = false; |
3777 | } | 3787 | } |
3778 | } | 3788 | } |
3789 | |||
3790 | private void CheckLandingPoint(ref Vector3 pos) | ||
3791 | { | ||
3792 | // Never constrain lures | ||
3793 | if ((TeleportFlags & TeleportFlags.ViaLure) != 0) | ||
3794 | return; | ||
3795 | |||
3796 | if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) | ||
3797 | return; | ||
3798 | |||
3799 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
3800 | |||
3801 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
3802 | land.LandData.UserLocation != Vector3.Zero && | ||
3803 | land.LandData.OwnerID != m_uuid && | ||
3804 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
3805 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | ||
3806 | { | ||
3807 | float curr = Vector3.Distance(AbsolutePosition, pos); | ||
3808 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | ||
3809 | pos = land.LandData.UserLocation; | ||
3810 | else | ||
3811 | ControllingClient.SendAlertMessage("Can't teleport closer to destination"); | ||
3812 | } | ||
3813 | } | ||
3814 | |||
3815 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | ||
3816 | { | ||
3817 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
3818 | if (land != null) | ||
3819 | { | ||
3820 | // If we come in via login, landmark or map, we want to | ||
3821 | // honor landing points. If we come in via Lure, we want | ||
3822 | // to ignore them. | ||
3823 | if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || | ||
3824 | (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || | ||
3825 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0) | ||
3826 | { | ||
3827 | // Don't restrict gods, estate managers, or land owners to | ||
3828 | // the TP point. This behaviour mimics agni. | ||
3829 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
3830 | land.LandData.UserLocation != Vector3.Zero && | ||
3831 | GodLevel < 200 && | ||
3832 | ((land.LandData.OwnerID != m_uuid && | ||
3833 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
3834 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) | ||
3835 | { | ||
3836 | pos = land.LandData.UserLocation; | ||
3837 | } | ||
3838 | } | ||
3839 | |||
3840 | land.SendLandUpdateToClient(ControllingClient); | ||
3841 | } | ||
3842 | } | ||
3843 | |||
3844 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
3845 | { | ||
3846 | List<uint> thisHitColliders = new List<uint>(); | ||
3847 | List<uint> endedColliders = new List<uint>(); | ||
3848 | List<uint> startedColliders = new List<uint>(); | ||
3849 | |||
3850 | foreach (uint localid in coldata.Keys) | ||
3851 | { | ||
3852 | thisHitColliders.Add(localid); | ||
3853 | if (!m_lastColliders.Contains(localid)) | ||
3854 | { | ||
3855 | startedColliders.Add(localid); | ||
3856 | } | ||
3857 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3858 | } | ||
3859 | |||
3860 | // calculate things that ended colliding | ||
3861 | foreach (uint localID in m_lastColliders) | ||
3862 | { | ||
3863 | if (!thisHitColliders.Contains(localID)) | ||
3864 | { | ||
3865 | endedColliders.Add(localID); | ||
3866 | } | ||
3867 | } | ||
3868 | //add the items that started colliding this time to the last colliders list. | ||
3869 | foreach (uint localID in startedColliders) | ||
3870 | { | ||
3871 | m_lastColliders.Add(localID); | ||
3872 | } | ||
3873 | // remove things that ended colliding from the last colliders list | ||
3874 | foreach (uint localID in endedColliders) | ||
3875 | { | ||
3876 | m_lastColliders.Remove(localID); | ||
3877 | } | ||
3878 | |||
3879 | // do event notification | ||
3880 | if (startedColliders.Count > 0) | ||
3881 | { | ||
3882 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3883 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3884 | foreach (uint localId in startedColliders) | ||
3885 | { | ||
3886 | if (localId == 0) | ||
3887 | continue; | ||
3888 | |||
3889 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3890 | string data = ""; | ||
3891 | if (obj != null) | ||
3892 | { | ||
3893 | DetectedObject detobj = new DetectedObject(); | ||
3894 | detobj.keyUUID = obj.UUID; | ||
3895 | detobj.nameStr = obj.Name; | ||
3896 | detobj.ownerUUID = obj.OwnerID; | ||
3897 | detobj.posVector = obj.AbsolutePosition; | ||
3898 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3899 | detobj.velVector = obj.Velocity; | ||
3900 | detobj.colliderType = 0; | ||
3901 | detobj.groupUUID = obj.GroupID; | ||
3902 | colliding.Add(detobj); | ||
3903 | } | ||
3904 | } | ||
3905 | |||
3906 | if (colliding.Count > 0) | ||
3907 | { | ||
3908 | StartCollidingMessage.Colliders = colliding; | ||
3909 | |||
3910 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3911 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3912 | } | ||
3913 | } | ||
3914 | |||
3915 | if (endedColliders.Count > 0) | ||
3916 | { | ||
3917 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3918 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3919 | foreach (uint localId in endedColliders) | ||
3920 | { | ||
3921 | if (localId == 0) | ||
3922 | continue; | ||
3923 | |||
3924 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3925 | string data = ""; | ||
3926 | if (obj != null) | ||
3927 | { | ||
3928 | DetectedObject detobj = new DetectedObject(); | ||
3929 | detobj.keyUUID = obj.UUID; | ||
3930 | detobj.nameStr = obj.Name; | ||
3931 | detobj.ownerUUID = obj.OwnerID; | ||
3932 | detobj.posVector = obj.AbsolutePosition; | ||
3933 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3934 | detobj.velVector = obj.Velocity; | ||
3935 | detobj.colliderType = 0; | ||
3936 | detobj.groupUUID = obj.GroupID; | ||
3937 | colliding.Add(detobj); | ||
3938 | } | ||
3939 | } | ||
3940 | |||
3941 | if (colliding.Count > 0) | ||
3942 | { | ||
3943 | EndCollidingMessage.Colliders = colliding; | ||
3944 | |||
3945 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3946 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3947 | } | ||
3948 | } | ||
3949 | |||
3950 | if (thisHitColliders.Count > 0) | ||
3951 | { | ||
3952 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3953 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3954 | foreach (uint localId in thisHitColliders) | ||
3955 | { | ||
3956 | if (localId == 0) | ||
3957 | continue; | ||
3958 | |||
3959 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3960 | string data = ""; | ||
3961 | if (obj != null) | ||
3962 | { | ||
3963 | DetectedObject detobj = new DetectedObject(); | ||
3964 | detobj.keyUUID = obj.UUID; | ||
3965 | detobj.nameStr = obj.Name; | ||
3966 | detobj.ownerUUID = obj.OwnerID; | ||
3967 | detobj.posVector = obj.AbsolutePosition; | ||
3968 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3969 | detobj.velVector = obj.Velocity; | ||
3970 | detobj.colliderType = 0; | ||
3971 | detobj.groupUUID = obj.GroupID; | ||
3972 | colliding.Add(detobj); | ||
3973 | } | ||
3974 | } | ||
3975 | |||
3976 | if (colliding.Count > 0) | ||
3977 | { | ||
3978 | CollidingMessage.Colliders = colliding; | ||
3979 | |||
3980 | lock (m_attachments) | ||
3981 | { | ||
3982 | foreach (SceneObjectGroup att in m_attachments) | ||
3983 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
3984 | } | ||
3985 | } | ||
3986 | } | ||
3987 | } | ||
3779 | } | 3988 | } |
3780 | } | 3989 | } |