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 | |
parent | add bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject land) pe... (diff) | |
download | opensim-SC_OLD-2bb5e985740b7c6aa75cd31aa057d39d56f024b6.zip opensim-SC_OLD-2bb5e985740b7c6aa75cd31aa057d39d56f024b6.tar.gz opensim-SC_OLD-2bb5e985740b7c6aa75cd31aa057d39d56f024b6.tar.bz2 opensim-SC_OLD-2bb5e985740b7c6aa75cd31aa057d39d56f024b6.tar.xz |
add EXPERIMENTAL osObjectTeleport(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer stop)
Diffstat (limited to 'OpenSim/Region')
5 files changed, 161 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; } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 6c094ee..ddf5078 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -4418,6 +4418,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4418 | /// </returns> | 4418 | /// </returns> |
4419 | public LSL_List osGetInertiaData() | 4419 | public LSL_List osGetInertiaData() |
4420 | { | 4420 | { |
4421 | m_host.AddScriptLPS(1); | ||
4422 | |||
4421 | LSL_List result = new LSL_List(); | 4423 | LSL_List result = new LSL_List(); |
4422 | float TotalMass; | 4424 | float TotalMass; |
4423 | Vector3 CenterOfMass; | 4425 | Vector3 CenterOfMass; |
@@ -4463,6 +4465,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4463 | 4465 | ||
4464 | public void osSetInertia(LSL_Float mass, LSL_Vector centerOfMass, LSL_Vector principalInertiaScaled, LSL_Rotation lslrot) | 4466 | public void osSetInertia(LSL_Float mass, LSL_Vector centerOfMass, LSL_Vector principalInertiaScaled, LSL_Rotation lslrot) |
4465 | { | 4467 | { |
4468 | m_host.AddScriptLPS(1); | ||
4466 | SceneObjectGroup sog = m_host.ParentGroup; | 4469 | SceneObjectGroup sog = m_host.ParentGroup; |
4467 | if(sog== null || sog.IsDeleted) | 4470 | if(sog== null || sog.IsDeleted) |
4468 | return; | 4471 | return; |
@@ -4499,6 +4502,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4499 | /// </remarks> | 4502 | /// </remarks> |
4500 | public void osSetInertiaAsBox(LSL_Float mass, LSL_Vector boxSize, LSL_Vector centerOfMass, LSL_Rotation lslrot) | 4503 | public void osSetInertiaAsBox(LSL_Float mass, LSL_Vector boxSize, LSL_Vector centerOfMass, LSL_Rotation lslrot) |
4501 | { | 4504 | { |
4505 | m_host.AddScriptLPS(1); | ||
4506 | |||
4502 | SceneObjectGroup sog = m_host.ParentGroup; | 4507 | SceneObjectGroup sog = m_host.ParentGroup; |
4503 | if(sog== null || sog.IsDeleted) | 4508 | if(sog== null || sog.IsDeleted) |
4504 | return; | 4509 | return; |
@@ -4538,6 +4543,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4538 | /// </remarks> | 4543 | /// </remarks> |
4539 | public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, LSL_Vector centerOfMass) | 4544 | public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, LSL_Vector centerOfMass) |
4540 | { | 4545 | { |
4546 | m_host.AddScriptLPS(1); | ||
4541 | SceneObjectGroup sog = m_host.ParentGroup; | 4547 | SceneObjectGroup sog = m_host.ParentGroup; |
4542 | if(sog== null || sog.IsDeleted) | 4548 | if(sog== null || sog.IsDeleted) |
4543 | return; | 4549 | return; |
@@ -4575,6 +4581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4575 | /// </remarks> | 4581 | /// </remarks> |
4576 | public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, LSL_Vector centerOfMass, LSL_Rotation lslrot) | 4582 | public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, LSL_Vector centerOfMass, LSL_Rotation lslrot) |
4577 | { | 4583 | { |
4584 | m_host.AddScriptLPS(1); | ||
4578 | SceneObjectGroup sog = m_host.ParentGroup; | 4585 | SceneObjectGroup sog = m_host.ParentGroup; |
4579 | if(sog== null || sog.IsDeleted) | 4586 | if(sog== null || sog.IsDeleted) |
4580 | return; | 4587 | return; |
@@ -4611,11 +4618,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4611 | /// </summary> | 4618 | /// </summary> |
4612 | public void osClearInertia() | 4619 | public void osClearInertia() |
4613 | { | 4620 | { |
4621 | m_host.AddScriptLPS(1); | ||
4614 | SceneObjectGroup sog = m_host.ParentGroup; | 4622 | SceneObjectGroup sog = m_host.ParentGroup; |
4615 | if(sog== null || sog.IsDeleted) | 4623 | if(sog== null || sog.IsDeleted) |
4616 | return; | 4624 | return; |
4617 | 4625 | ||
4618 | sog.SetInertiaData(-1, Vector3.Zero, Vector3.Zero, Vector4.Zero ); | 4626 | sog.SetInertiaData(-1, Vector3.Zero, Vector3.Zero, Vector4.Zero ); |
4619 | } | 4627 | } |
4628 | |||
4629 | /// <summary> | ||
4630 | /// teleports a object (full linkset) | ||
4631 | /// </summary> | ||
4632 | /// <param name="objectUUID">the id of the linkset to teleport</param> | ||
4633 | /// <param name="targetPos">target position</param> | ||
4634 | /// <param name="rotation"> a rotation to apply</param> | ||
4635 | /// <param name="stop">if TRUE (!=0) stop at destination</param> | ||
4636 | /// <remarks> | ||
4637 | /// only does teleport local to region | ||
4638 | /// object owner must have rights to run scripts on target location | ||
4639 | /// object owner must have rights to enter ojects on target location | ||
4640 | /// target location parcel must have enought free prims capacity for the linkset prims | ||
4641 | /// all avatars siting on the object must have access to target location | ||
4642 | /// has a cool down time. retries before expire reset it | ||
4643 | /// fail conditions are silent ignored | ||
4644 | /// </remarks> | ||
4645 | public void osObjectTeleport(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer stop) | ||
4646 | { | ||
4647 | CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); | ||
4648 | m_host.AddScriptLPS(1); | ||
4649 | |||
4650 | UUID objUUID; | ||
4651 | if (!UUID.TryParse(objectUUID, out objUUID)) | ||
4652 | { | ||
4653 | OSSLShoutError("osObjectTeleport() invalid object Key"); | ||
4654 | return; | ||
4655 | } | ||
4656 | |||
4657 | SceneObjectGroup sog = World.GetSceneObjectGroup(objUUID); | ||
4658 | if(sog== null || sog.IsDeleted) | ||
4659 | return; | ||
4660 | |||
4661 | UUID myid = m_host.ParentGroup.UUID; | ||
4662 | |||
4663 | sog.ObjectTeleport(myid, targetPos, rotation, stop != 0); | ||
4664 | // a delay here may break vehicles | ||
4665 | } | ||
4620 | } | 4666 | } |
4621 | } | 4667 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index f76ff7f..4722fed 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -495,5 +495,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
495 | void osSetInertiaAsBox(LSL_Float mass, vector boxSize, vector centerOfMass, rotation rot); | 495 | void osSetInertiaAsBox(LSL_Float mass, vector boxSize, vector centerOfMass, rotation rot); |
496 | void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass); | 496 | void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass); |
497 | void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot); | 497 | void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot); |
498 | |||
499 | void osObjectTeleport(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer stop); | ||
498 | } | 500 | } |
499 | } | 501 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 09337e5..37e7a17 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -1140,5 +1140,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1140 | m_OSSL_Functions.osClearInertia(); | 1140 | m_OSSL_Functions.osClearInertia(); |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | public void osObjectTeleport(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer stop) | ||
1144 | { | ||
1145 | m_OSSL_Functions.osObjectTeleport(objectUUID, targetPos, targetrotation, stop); | ||
1146 | } | ||
1143 | } | 1147 | } |
1144 | } | 1148 | } |