mantis: rotate avatar to lookAt o login/teleports. Some cases may still be wrong

LSLKeyTest
UbitUmarov 2016-08-28 14:59:02 +01:00
parent b2021cf83a
commit 386a13d5d6
2 changed files with 36 additions and 2 deletions

View File

@ -478,9 +478,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
sp.ControllingClient.SendTeleportStart(teleportFlags);
lookAt.Z = 0f;
if(Math.Abs(lookAt.X) < 0.01f && Math.Abs(lookAt.Y) < 0.01f)
{
lookAt.X = 1.0f;
lookAt.Y = 0;
}
sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags;
sp.RotateToLookAt(lookAt);
sp.Velocity = Vector3.Zero;
sp.Teleport(position);

View File

@ -1927,6 +1927,31 @@ namespace OpenSim.Region.Framework.Scenes
return true;
}
public void RotateToLookAt(Vector3 lookAt)
{
if(ParentID == 0)
{
float n = lookAt.X * lookAt.X + lookAt.Y * lookAt.Y;
if(n < 0.0001f)
{
Rotation = Quaternion.Identity;
return;
}
n = lookAt.X/(float)Math.Sqrt(n);
float angle = (float)Math.Acos(n);
angle *= 0.5f;
float s = (float)Math.Sin(angle);
if(lookAt.Y < 0)
s = -s;
Rotation = new Quaternion(
0f,
0f,
s,
(float)Math.Cos(angle)
);
}
}
/// <summary>
/// Complete Avatar's movement into the region.
/// </summary>
@ -1963,10 +1988,10 @@ namespace OpenSim.Region.Framework.Scenes
bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
Vector3 look = Lookat;
look.Z = 0f;
if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01))
{
look = Velocity;
look.Z = 0;
look.Normalize();
if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) )
look = new Vector3(0.99f, 0.042f, 0);
@ -2000,11 +2025,12 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF);
}
if(!gotCrossUpdate)
RotateToLookAt(look);
// Tell the client that we're totally ready
ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
if (!string.IsNullOrEmpty(m_callbackURI))