diff options
author | UbitUmarov | 2017-04-03 17:19:28 +0100 |
---|---|---|
committer | UbitUmarov | 2017-04-03 17:19:28 +0100 |
commit | 2bb5e985740b7c6aa75cd31aa057d39d56f024b6 (patch) | |
tree | bbc3c48111f874ef69bf0bfb10f649293f824c0d /OpenSim/Region/Framework | |
parent | add bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject land) pe... (diff) | |
download | opensim-SC-2bb5e985740b7c6aa75cd31aa057d39d56f024b6.zip opensim-SC-2bb5e985740b7c6aa75cd31aa057d39d56f024b6.tar.gz opensim-SC-2bb5e985740b7c6aa75cd31aa057d39d56f024b6.tar.bz2 opensim-SC-2bb5e985740b7c6aa75cd31aa057d39d56f024b6.tar.xz |
add EXPERIMENTAL osObjectTeleport(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer stop)
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/Scene.cs | 31 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 85 |
2 files changed, 109 insertions, 7 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c5b082c..3b9f551 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -808,6 +808,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
808 | private float m_minReprioritizationDistance = 32f; | 808 | private float m_minReprioritizationDistance = 32f; |
809 | public bool ObjectsCullingByDistance = false; | 809 | public bool ObjectsCullingByDistance = false; |
810 | 810 | ||
811 | private ExpiringCache<UUID, UUID> TeleportTargetsCoolDown = new ExpiringCache<UUID, UUID>(); | ||
812 | |||
811 | public AgentCircuitManager AuthenticateHandler | 813 | public AgentCircuitManager AuthenticateHandler |
812 | { | 814 | { |
813 | get { return m_authenticateHandler; } | 815 | get { return m_authenticateHandler; } |
@@ -2983,15 +2985,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2983 | // Return 'true' if position inside region. | 2985 | // Return 'true' if position inside region. |
2984 | public bool PositionIsInCurrentRegion(Vector3 pos) | 2986 | public bool PositionIsInCurrentRegion(Vector3 pos) |
2985 | { | 2987 | { |
2986 | bool ret = false; | 2988 | int xx = (int)pos.X; |
2987 | int xx = (int)Math.Floor(pos.X); | 2989 | if (xx < 0 || xx >= RegionInfo.RegionSizeX) |
2988 | int yy = (int)Math.Floor(pos.Y); | ||
2989 | if (xx < 0 || yy < 0) | ||
2990 | return false; | 2990 | return false; |
2991 | 2991 | ||
2992 | if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY ) | 2992 | int yy = (int)pos.Y; |
2993 | ret = true; | 2993 | if (yy < 0 || yy >= RegionInfo.RegionSizeX) |
2994 | return ret; | 2994 | return false; |
2995 | return true; | ||
2995 | } | 2996 | } |
2996 | 2997 | ||
2997 | /// <summary> | 2998 | /// <summary> |
@@ -6526,5 +6527,21 @@ Environment.Exit(1); | |||
6526 | 6527 | ||
6527 | m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); | 6528 | m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); |
6528 | } | 6529 | } |
6530 | |||
6531 | public bool InTeleportTargetsCoolDown(UUID sourceID, UUID targetID, double timeout) | ||
6532 | { | ||
6533 | lock(TeleportTargetsCoolDown) | ||
6534 | { | ||
6535 | UUID lastSource = UUID.Zero; | ||
6536 | TeleportTargetsCoolDown.TryGetValue(targetID, out lastSource); | ||
6537 | if(lastSource == UUID.Zero) | ||
6538 | { | ||
6539 | TeleportTargetsCoolDown.Add(targetID, sourceID, timeout); | ||
6540 | return false; | ||
6541 | } | ||
6542 | TeleportTargetsCoolDown.AddOrUpdate(targetID, sourceID, timeout); | ||
6543 | return lastSource == sourceID; | ||
6544 | } | ||
6545 | } | ||
6529 | } | 6546 | } |
6530 | } | 6547 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 719a5dd..402e5f7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -853,6 +853,91 @@ namespace OpenSim.Region.Framework.Scenes | |||
853 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | 853 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); |
854 | } | 854 | } |
855 | */ | 855 | */ |
856 | public void ObjectTeleport(UUID sourceID, Vector3 targetPosition, Quaternion rotation, bool stop) | ||
857 | { | ||
858 | if(inTransit || IsDeleted || IsAttachmentCheckFull() || IsSelected || Scene == null) | ||
859 | return; | ||
860 | |||
861 | inTransit = true; | ||
862 | |||
863 | PhysicsActor pa = RootPart.PhysActor; | ||
864 | if(pa == null || RootPart.KeyframeMotion != null /*|| m_sittingAvatars.Count == 0*/) | ||
865 | { | ||
866 | inTransit = false; | ||
867 | return; | ||
868 | } | ||
869 | |||
870 | if(Scene.PositionIsInCurrentRegion(targetPosition)) | ||
871 | { | ||
872 | if(Scene.InTeleportTargetsCoolDown(UUID, sourceID, 1.0)) | ||
873 | { | ||
874 | inTransit = false; | ||
875 | return; | ||
876 | } | ||
877 | |||
878 | Vector3 curPos = AbsolutePosition; | ||
879 | ILandObject curLand = Scene.LandChannel.GetLandObject(curPos.X, curPos.Y); | ||
880 | float posX = targetPosition.X; | ||
881 | float posY = targetPosition.Y; | ||
882 | ILandObject land = Scene.LandChannel.GetLandObject(posX, posY); | ||
883 | if(land != null && land != curLand) | ||
884 | { | ||
885 | if(!Scene.Permissions.CanObjectEnterWithScripts(this, land)) | ||
886 | { | ||
887 | inTransit = false; | ||
888 | return; | ||
889 | } | ||
890 | |||
891 | UUID agentID; | ||
892 | foreach (ScenePresence av in m_sittingAvatars) | ||
893 | { | ||
894 | agentID = av.UUID; | ||
895 | if(land.IsRestrictedFromLand(agentID) || land.IsBannedFromLand(agentID)) | ||
896 | { | ||
897 | inTransit = false; | ||
898 | return; | ||
899 | } | ||
900 | } | ||
901 | } | ||
902 | |||
903 | if(stop) | ||
904 | RootPart.Stop(); | ||
905 | else | ||
906 | { | ||
907 | rotation.Normalize(); | ||
908 | if(Math.Abs(rotation.W) < 0.999) | ||
909 | { | ||
910 | Quaternion rot = RootPart.RotationOffset; | ||
911 | Vector3 vel = RootPart.Velocity; | ||
912 | Vector3 avel = RootPart.AngularVelocity; | ||
913 | Vector3 acc = RootPart.Acceleration; | ||
914 | |||
915 | rot *= rotation; | ||
916 | vel *= rotation; | ||
917 | avel *= rotation; | ||
918 | acc *= rotation; | ||
919 | |||
920 | RootPart.RotationOffset = rot; | ||
921 | RootPart.Velocity = vel; | ||
922 | RootPart.AngularVelocity = avel; | ||
923 | RootPart.Acceleration = acc; | ||
924 | } | ||
925 | } | ||
926 | |||
927 | Vector3 s = RootPart.Scale * RootPart.RotationOffset; | ||
928 | float h = Scene.GetGroundHeight(posX, posY) + 0.5f * (float)Math.Abs(s.Z) + 0.01f; | ||
929 | if(targetPosition.Z < h) | ||
930 | targetPosition.Z = h; | ||
931 | |||
932 | inTransit = false; | ||
933 | AbsolutePosition = targetPosition; | ||
934 | RootPart.ScheduleTerseUpdate(); | ||
935 | return; | ||
936 | } | ||
937 | |||
938 | inTransit = false; | ||
939 | } | ||
940 | |||
856 | public override Vector3 Velocity | 941 | public override Vector3 Velocity |
857 | { | 942 | { |
858 | get { return RootPart.Velocity; } | 943 | get { return RootPart.Velocity; } |