From ca250e0b0b564efaaeb5c0b80760126cfd710c5e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 4 Apr 2017 14:34:25 +0100 Subject: [PATCH] mantis 8740: rename osObjectTeleport as osTeleportObject, replaced the stop parameter by flags, add flags OSTPOBJ_STOPATTARRGET and OSTPOBJ_SETROT --- .../Framework/Scenes/SceneObjectGroup.cs | 34 +++++++++++++------ .../Shared/Api/Implementation/OSSL_Api.cs | 8 ++--- .../Shared/Api/Interface/IOSSL_Api.cs | 2 +- .../Shared/Api/Runtime/LSL_Constants.cs | 7 ++++ .../Shared/Api/Runtime/OSSL_Stub.cs | 4 +-- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 24cdc7af9c..a0d7bfd678 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -853,7 +853,13 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); } */ - public void ObjectTeleport(UUID sourceID, Vector3 targetPosition, Quaternion rotation, bool stop) + + // copy from LSL_constants.cs + const int OSTPOBJ_STOPATTARRGET = 0x1; // stops at destination + const int OSTPOBJ_STOPONFAIL = 0x2; // stops at start if tp fails + const int OSTPOBJ_SETROT = 0x4; // the rotation is the final rotation, otherwise is a added rotation + + public void TeleportObject(UUID sourceID, Vector3 targetPosition, Quaternion rotation, int flags) { if(inTransit || IsDeleted || IsAttachmentCheckFull() || IsSelected || Scene == null) return; @@ -900,38 +906,44 @@ namespace OpenSim.Region.Framework.Scenes } } + bool stop = (flags & OSTPOBJ_STOPATTARRGET) != 0; + bool setrot = (flags & OSTPOBJ_SETROT) != 0; + rotation.Normalize(); + bool dorot = (Math.Abs(rotation.W) < 0.999); + + Quaternion currentRot = RootPart.RotationOffset; + if(dorot && setrot) + rotation = rotation * Quaternion.Conjugate(currentRot); + if(stop) { RootPart.Stop(); - if(Math.Abs(rotation.W) < 0.999) - { - Quaternion rot = RootPart.RotationOffset; - rot *= rotation; - RootPart.RotationOffset = rot; - } } else { - if(Math.Abs(rotation.W) < 0.999) + if(dorot) { - Quaternion rot = RootPart.RotationOffset; Vector3 vel = RootPart.Velocity; Vector3 avel = RootPart.AngularVelocity; Vector3 acc = RootPart.Acceleration; - rot *= rotation; vel *= rotation; avel *= rotation; acc *= rotation; - RootPart.RotationOffset = rot; RootPart.Velocity = vel; RootPart.AngularVelocity = avel; RootPart.Acceleration = acc; } } + if(dorot) + { + currentRot *= rotation; + RootPart.RotationOffset = currentRot; + } + Vector3 s = RootPart.Scale * RootPart.RotationOffset; float h = Scene.GetGroundHeight(posX, posY) + 0.5f * (float)Math.Abs(s.Z) + 0.01f; if(targetPosition.Z < h) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index ddf5078c92..b50ae28827 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -4632,17 +4632,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// the id of the linkset to teleport /// target position /// a rotation to apply - /// if TRUE (!=0) stop at destination + /// several flags/param> /// /// only does teleport local to region - /// object owner must have rights to run scripts on target location + /// if object has scripts, owner must have rights to run scripts on target location /// object owner must have rights to enter ojects on target location /// target location parcel must have enought free prims capacity for the linkset prims /// all avatars siting on the object must have access to target location /// has a cool down time. retries before expire reset it /// fail conditions are silent ignored /// - public void osObjectTeleport(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer stop) + public void osTeleportObject(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer flags) { CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); m_host.AddScriptLPS(1); @@ -4660,7 +4660,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID myid = m_host.ParentGroup.UUID; - sog.ObjectTeleport(myid, targetPos, rotation, stop != 0); + sog.TeleportObject(myid, targetPos, rotation, flags); // a delay here may break vehicles } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 4722fedf07..879fe51e9a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -496,6 +496,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass); void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot); - void osObjectTeleport(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer stop); + void osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 3a90c7704e..59493a3b72 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -853,5 +853,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase /// process message parameter as regex /// public const int OS_LISTEN_REGEX_MESSAGE = 0x2; + + // for osTeleportObject + public const int OSTPOBJ_NONE = 0x0; + public const int OSTPOBJ_STOPATTARRGET = 0x1; // stops at destination + public const int OSTPOBJ_STOPONFAIL = 0x2; // stops at jump point if tp fails + public const int OSTPOBJ_SETROT = 0x4; // the rotation is the final rotation, otherwise is a added rotation + } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 37e7a174f7..3c8e02da6f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -1140,9 +1140,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osClearInertia(); } - public void osObjectTeleport(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer stop) + public void osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags) { - m_OSSL_Functions.osObjectTeleport(objectUUID, targetPos, targetrotation, stop); + m_OSSL_Functions.osTeleportObject(objectUUID, targetPos, targetrotation, flags); } } }