mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 01:06:30 +08:00
add EXPERIMENTAL osObjectTeleport(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer stop)
This commit is contained in:
@@ -808,6 +808,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
private float m_minReprioritizationDistance = 32f;
|
||||
public bool ObjectsCullingByDistance = false;
|
||||
|
||||
private ExpiringCache<UUID, UUID> TeleportTargetsCoolDown = new ExpiringCache<UUID, UUID>();
|
||||
|
||||
public AgentCircuitManager AuthenticateHandler
|
||||
{
|
||||
get { return m_authenticateHandler; }
|
||||
@@ -2983,15 +2985,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// Return 'true' if position inside region.
|
||||
public bool PositionIsInCurrentRegion(Vector3 pos)
|
||||
{
|
||||
bool ret = false;
|
||||
int xx = (int)Math.Floor(pos.X);
|
||||
int yy = (int)Math.Floor(pos.Y);
|
||||
if (xx < 0 || yy < 0)
|
||||
int xx = (int)pos.X;
|
||||
if (xx < 0 || xx >= RegionInfo.RegionSizeX)
|
||||
return false;
|
||||
|
||||
if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY )
|
||||
ret = true;
|
||||
return ret;
|
||||
int yy = (int)pos.Y;
|
||||
if (yy < 0 || yy >= RegionInfo.RegionSizeX)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -6526,5 +6527,21 @@ Environment.Exit(1);
|
||||
|
||||
m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty);
|
||||
}
|
||||
|
||||
public bool InTeleportTargetsCoolDown(UUID sourceID, UUID targetID, double timeout)
|
||||
{
|
||||
lock(TeleportTargetsCoolDown)
|
||||
{
|
||||
UUID lastSource = UUID.Zero;
|
||||
TeleportTargetsCoolDown.TryGetValue(targetID, out lastSource);
|
||||
if(lastSource == UUID.Zero)
|
||||
{
|
||||
TeleportTargetsCoolDown.Add(targetID, sourceID, timeout);
|
||||
return false;
|
||||
}
|
||||
TeleportTargetsCoolDown.AddOrUpdate(targetID, sourceID, timeout);
|
||||
return lastSource == sourceID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -853,6 +853,91 @@ 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)
|
||||
{
|
||||
if(inTransit || IsDeleted || IsAttachmentCheckFull() || IsSelected || Scene == null)
|
||||
return;
|
||||
|
||||
inTransit = true;
|
||||
|
||||
PhysicsActor pa = RootPart.PhysActor;
|
||||
if(pa == null || RootPart.KeyframeMotion != null /*|| m_sittingAvatars.Count == 0*/)
|
||||
{
|
||||
inTransit = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(Scene.PositionIsInCurrentRegion(targetPosition))
|
||||
{
|
||||
if(Scene.InTeleportTargetsCoolDown(UUID, sourceID, 1.0))
|
||||
{
|
||||
inTransit = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 curPos = AbsolutePosition;
|
||||
ILandObject curLand = Scene.LandChannel.GetLandObject(curPos.X, curPos.Y);
|
||||
float posX = targetPosition.X;
|
||||
float posY = targetPosition.Y;
|
||||
ILandObject land = Scene.LandChannel.GetLandObject(posX, posY);
|
||||
if(land != null && land != curLand)
|
||||
{
|
||||
if(!Scene.Permissions.CanObjectEnterWithScripts(this, land))
|
||||
{
|
||||
inTransit = false;
|
||||
return;
|
||||
}
|
||||
|
||||
UUID agentID;
|
||||
foreach (ScenePresence av in m_sittingAvatars)
|
||||
{
|
||||
agentID = av.UUID;
|
||||
if(land.IsRestrictedFromLand(agentID) || land.IsBannedFromLand(agentID))
|
||||
{
|
||||
inTransit = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(stop)
|
||||
RootPart.Stop();
|
||||
else
|
||||
{
|
||||
rotation.Normalize();
|
||||
if(Math.Abs(rotation.W) < 0.999)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
targetPosition.Z = h;
|
||||
|
||||
inTransit = false;
|
||||
AbsolutePosition = targetPosition;
|
||||
RootPart.ScheduleTerseUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
inTransit = false;
|
||||
}
|
||||
|
||||
public override Vector3 Velocity
|
||||
{
|
||||
get { return RootPart.Velocity; }
|
||||
|
||||
Reference in New Issue
Block a user