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); m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
sp.ControllingClient.SendTeleportStart(teleportFlags); 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.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags; sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags;
sp.RotateToLookAt(lookAt);
sp.Velocity = Vector3.Zero; sp.Velocity = Vector3.Zero;
sp.Teleport(position); sp.Teleport(position);

View File

@ -1927,6 +1927,31 @@ namespace OpenSim.Region.Framework.Scenes
return true; 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> /// <summary>
/// Complete Avatar's movement into the region. /// Complete Avatar's movement into the region.
/// </summary> /// </summary>
@ -1963,10 +1988,10 @@ namespace OpenSim.Region.Framework.Scenes
bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
Vector3 look = Lookat; Vector3 look = Lookat;
look.Z = 0f;
if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01)) if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01))
{ {
look = Velocity; look = Velocity;
look.Z = 0;
look.Normalize(); look.Normalize();
if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) ) if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) )
look = new Vector3(0.99f, 0.042f, 0); 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); 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 // Tell the client that we're totally ready
ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
if (!string.IsNullOrEmpty(m_callbackURI)) if (!string.IsNullOrEmpty(m_callbackURI))