From b70a28537350908e8cbf5fe254315fa760a2ee4e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 14 Oct 2008 20:28:34 +0000 Subject: * Send an avatar update to other clients when an avatar rotates, as well as when it moves * This should fix a long standing issue where you often wouldn't see other people simply turn around without moving at all * Arguably lastPhysRot (to mirror lastPhysPos) is not a good name, may change variable names later --- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 981b15c..d87a7e2 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -142,7 +142,16 @@ namespace OpenSim.Region.Environment.Scenes protected ulong crossingFromRegion = 0; private readonly Vector3[] Dir_Vectors = new Vector3[6]; + + /// + /// The avatar position last sent to clients + /// private Vector3 lastPhysPos = Vector3.Zero; + + /// + /// The avatar body rotation last sent to clients + /// + private Quaternion lastPhysRot = Quaternion.Identity; // Position of agent's camera in world (region cordinates) protected Vector3 m_CameraCenter = Vector3.Zero; @@ -1581,7 +1590,9 @@ namespace OpenSim.Region.Environment.Scenes m_updateCount = 0; } } - else if ((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02)) // physics-related movement + else if ((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) + || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02) + || lastPhysRot != m_bodyRot) { // Send Terse Update to all clients updates lastPhysPos and m_lastVelocity // doing the above assures us that we know what we sent the clients last @@ -1628,6 +1639,7 @@ namespace OpenSim.Region.Environment.Scenes m_lastVelocity = m_velocity; lastPhysPos = AbsolutePosition; + lastPhysRot = m_bodyRot; m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); @@ -2540,7 +2552,10 @@ namespace OpenSim.Region.Environment.Scenes (float)info.GetValue("lastPhysPos.X", typeof(float)), (float)info.GetValue("lastPhysPos.Y", typeof(float)), (float)info.GetValue("lastPhysPos.Z", typeof(float))); - + + // Possibly we should store lastPhysRot. But there may well be not much point since rotation changes + // wouldn't carry us across borders anyway + m_CameraCenter = new Vector3( (float)info.GetValue("m_CameraCenter.X", typeof(float)), @@ -2686,7 +2701,10 @@ namespace OpenSim.Region.Environment.Scenes // Vector3 info.AddValue("lastPhysPos.X", lastPhysPos.X); info.AddValue("lastPhysPos.Y", lastPhysPos.Y); - info.AddValue("lastPhysPos.Z", lastPhysPos.Z); + info.AddValue("lastPhysPos.Z", lastPhysPos.Z); + + // Possibly we should retrieve lastPhysRot. But there may well be not much point since rotation changes + // wouldn't carry us across borders anyway // Vector3 info.AddValue("m_CameraCenter.X", m_CameraCenter.X); -- cgit v1.1