mantis 8740: rename osObjectTeleport as osTeleportObject, replaced the stop parameter by flags, add flags OSTPOBJ_STOPATTARRGET and OSTPOBJ_SETROT

httptests
UbitUmarov 2017-04-04 14:34:25 +01:00
parent 056b765fbc
commit ca250e0b0b
5 changed files with 37 additions and 18 deletions

View File

@ -853,7 +853,13 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); 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) if(inTransit || IsDeleted || IsAttachmentCheckFull() || IsSelected || Scene == null)
return; return;
@ -900,38 +906,44 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
bool stop = (flags & OSTPOBJ_STOPATTARRGET) != 0;
bool setrot = (flags & OSTPOBJ_SETROT) != 0;
rotation.Normalize(); rotation.Normalize();
bool dorot = (Math.Abs(rotation.W) < 0.999);
Quaternion currentRot = RootPart.RotationOffset;
if(dorot && setrot)
rotation = rotation * Quaternion.Conjugate(currentRot);
if(stop) if(stop)
{ {
RootPart.Stop(); RootPart.Stop();
if(Math.Abs(rotation.W) < 0.999)
{
Quaternion rot = RootPart.RotationOffset;
rot *= rotation;
RootPart.RotationOffset = rot;
}
} }
else else
{ {
if(Math.Abs(rotation.W) < 0.999) if(dorot)
{ {
Quaternion rot = RootPart.RotationOffset;
Vector3 vel = RootPart.Velocity; Vector3 vel = RootPart.Velocity;
Vector3 avel = RootPart.AngularVelocity; Vector3 avel = RootPart.AngularVelocity;
Vector3 acc = RootPart.Acceleration; Vector3 acc = RootPart.Acceleration;
rot *= rotation;
vel *= rotation; vel *= rotation;
avel *= rotation; avel *= rotation;
acc *= rotation; acc *= rotation;
RootPart.RotationOffset = rot;
RootPart.Velocity = vel; RootPart.Velocity = vel;
RootPart.AngularVelocity = avel; RootPart.AngularVelocity = avel;
RootPart.Acceleration = acc; RootPart.Acceleration = acc;
} }
} }
if(dorot)
{
currentRot *= rotation;
RootPart.RotationOffset = currentRot;
}
Vector3 s = RootPart.Scale * RootPart.RotationOffset; Vector3 s = RootPart.Scale * RootPart.RotationOffset;
float h = Scene.GetGroundHeight(posX, posY) + 0.5f * (float)Math.Abs(s.Z) + 0.01f; float h = Scene.GetGroundHeight(posX, posY) + 0.5f * (float)Math.Abs(s.Z) + 0.01f;
if(targetPosition.Z < h) if(targetPosition.Z < h)

View File

@ -4632,17 +4632,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// <param name="objectUUID">the id of the linkset to teleport</param> /// <param name="objectUUID">the id of the linkset to teleport</param>
/// <param name="targetPos">target position</param> /// <param name="targetPos">target position</param>
/// <param name="rotation"> a rotation to apply</param> /// <param name="rotation"> a rotation to apply</param>
/// <param name="stop">if TRUE (!=0) stop at destination</param> /// <param name="flags">several flags/param>
/// <remarks> /// <remarks>
/// only does teleport local to region /// 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 /// object owner must have rights to enter ojects on target location
/// target location parcel must have enought free prims capacity for the linkset prims /// 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 /// all avatars siting on the object must have access to target location
/// has a cool down time. retries before expire reset it /// has a cool down time. retries before expire reset it
/// fail conditions are silent ignored /// fail conditions are silent ignored
/// </remarks> /// </remarks>
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"); CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
@ -4660,7 +4660,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID myid = m_host.ParentGroup.UUID; 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 // a delay here may break vehicles
} }
} }

View File

@ -496,6 +496,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass); 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 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);
} }
} }

View File

@ -853,5 +853,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
/// process message parameter as regex /// process message parameter as regex
/// </summary> /// </summary>
public const int OS_LISTEN_REGEX_MESSAGE = 0x2; 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
} }
} }

View File

@ -1140,9 +1140,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osClearInertia(); 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);
} }
} }
} }