diff options
author | UbitUmarov | 2016-08-28 14:59:02 +0100 |
---|---|---|
committer | UbitUmarov | 2016-08-28 14:59:02 +0100 |
commit | 386a13d5d63b32c7c332e7526cdd143e649d7c18 (patch) | |
tree | aca0bfc6d1b63ca699d16126964b34b44987ed80 /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | mantis: 8006 remove duplication of attach script events. This is a temporary ... (diff) | |
download | opensim-SC_OLD-386a13d5d63b32c7c332e7526cdd143e649d7c18.zip opensim-SC_OLD-386a13d5d63b32c7c332e7526cdd143e649d7c18.tar.gz opensim-SC_OLD-386a13d5d63b32c7c332e7526cdd143e649d7c18.tar.bz2 opensim-SC_OLD-386a13d5d63b32c7c332e7526cdd143e649d7c18.tar.xz |
mantis: rotate avatar to lookAt o login/teleports. Some cases may still be wrong
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 50ee9d4..cb7422b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1927,6 +1927,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
1927 | return true; | 1927 | return true; |
1928 | } | 1928 | } |
1929 | 1929 | ||
1930 | public void RotateToLookAt(Vector3 lookAt) | ||
1931 | { | ||
1932 | if(ParentID == 0) | ||
1933 | { | ||
1934 | float n = lookAt.X * lookAt.X + lookAt.Y * lookAt.Y; | ||
1935 | if(n < 0.0001f) | ||
1936 | { | ||
1937 | Rotation = Quaternion.Identity; | ||
1938 | return; | ||
1939 | } | ||
1940 | n = lookAt.X/(float)Math.Sqrt(n); | ||
1941 | float angle = (float)Math.Acos(n); | ||
1942 | angle *= 0.5f; | ||
1943 | float s = (float)Math.Sin(angle); | ||
1944 | if(lookAt.Y < 0) | ||
1945 | s = -s; | ||
1946 | Rotation = new Quaternion( | ||
1947 | 0f, | ||
1948 | 0f, | ||
1949 | s, | ||
1950 | (float)Math.Cos(angle) | ||
1951 | ); | ||
1952 | } | ||
1953 | } | ||
1954 | |||
1930 | /// <summary> | 1955 | /// <summary> |
1931 | /// Complete Avatar's movement into the region. | 1956 | /// Complete Avatar's movement into the region. |
1932 | /// </summary> | 1957 | /// </summary> |
@@ -1963,10 +1988,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1963 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1988 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1964 | 1989 | ||
1965 | Vector3 look = Lookat; | 1990 | Vector3 look = Lookat; |
1991 | look.Z = 0f; | ||
1966 | if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01)) | 1992 | if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01)) |
1967 | { | 1993 | { |
1968 | look = Velocity; | 1994 | look = Velocity; |
1969 | look.Z = 0; | ||
1970 | look.Normalize(); | 1995 | look.Normalize(); |
1971 | if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) ) | 1996 | if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) ) |
1972 | look = new Vector3(0.99f, 0.042f, 0); | 1997 | look = new Vector3(0.99f, 0.042f, 0); |
@@ -2000,11 +2025,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2000 | m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF); | 2025 | m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF); |
2001 | } | 2026 | } |
2002 | 2027 | ||
2028 | if(!gotCrossUpdate) | ||
2029 | RotateToLookAt(look); | ||
2003 | 2030 | ||
2004 | // Tell the client that we're totally ready | 2031 | // Tell the client that we're totally ready |
2005 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | 2032 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); |
2006 | 2033 | ||
2007 | |||
2008 | m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | 2034 | m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); |
2009 | 2035 | ||
2010 | if (!string.IsNullOrEmpty(m_callbackURI)) | 2036 | if (!string.IsNullOrEmpty(m_callbackURI)) |