a few changes on teleport lookat

This commit is contained in:
UbitUmarov
2021-09-15 23:01:01 +01:00
parent a3ab4db5fc
commit 55fb69f8e0
3 changed files with 24 additions and 4 deletions

View File

@@ -407,6 +407,21 @@ namespace OpenSim.Framework
public Dictionary<string, UUID> MovementAnimationOverRides = new Dictionary<string, UUID>();
public void SetLookAt(Vector3 value)
{
if (value == Vector3.Zero)
{
AtAxis = Vector3.UnitX;
LeftAxis = Vector3.UnitY;
AtAxis = Vector3.UnitZ;
return;
}
AtAxis = new Vector3(value.X, value.Y, 0);
AtAxis.Normalize();
LeftAxis = new Vector3(-AtAxis.Y, AtAxis.X, 0);
UpAxis = Vector3.UnitZ;
}
public virtual OSDMap Pack(EntityTransferContext ctx)
{
// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");

View File

@@ -845,13 +845,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// We're going to fallback to V1 if the destination gives us anything smaller than 0.2
if (ctx.OutboundVersion >= 0.2f)
TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, OutSideViewRange , ctx, out reason);
TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, OutSideViewRange, lookAt, ctx, out reason);
else
TransferAgent_V1(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, OutSideViewRange, ctx, out reason);
TransferAgent_V1(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, OutSideViewRange, lookAt, ctx, out reason);
}
private void TransferAgent_V1(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination,
IPEndPoint endPoint, uint teleportFlags, bool OutSideViewRange, EntityTransferContext ctx, out string reason)
IPEndPoint endPoint, uint teleportFlags, bool OutSideViewRange, Vector3 lookAt, EntityTransferContext ctx, out string reason)
{
ulong destinationHandle = finalDestination.RegionHandle;
AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
@@ -947,6 +947,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Let's send a full update of the agent. This is a synchronous call.
AgentData agent = new AgentData();
sp.CopyTo(agent,false);
agent.SetLookAt(lookAt);
if ((teleportFlags & (uint)TeleportFlags.IsFlying) != 0)
agent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
@@ -1089,7 +1090,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
}
private void TransferAgent_V2(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination,
IPEndPoint endPoint, uint teleportFlags, bool OutSideViewRange, EntityTransferContext ctx, out string reason)
IPEndPoint endPoint, uint teleportFlags, bool OutSideViewRange, Vector3 lookAt, EntityTransferContext ctx, out string reason)
{
ulong destinationHandle = finalDestination.RegionHandle;
@@ -1176,6 +1177,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Let's send a full update of the agent.
AgentData agent = new AgentData();
sp.CopyTo(agent,false);
agent.SetLookAt(lookAt);
agent.Position = agentCircuit.startpos;
if ((teleportFlags & (uint)TeleportFlags.IsFlying) != 0)

View File

@@ -64,6 +64,9 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
/// <returns></returns>
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier)
{
if(string.IsNullOrEmpty(identifier))
return UUID.Zero;
// if we can parse the string as a key, use it.
// else try to locate the name in inventory of object. found returns key,
// not found returns UUID.Zero