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 --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 5 ++++- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 24 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 476b3d5..6a011b4 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -2339,7 +2339,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP } /// - /// + /// Send a terse positional/rotation/velocity update about an avatar to the client. This avatar can be that of + /// the client itself. /// /// /// @@ -2352,6 +2353,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (rotation.X == rotation.Y && rotation.Y == rotation.Z && rotation.Z == rotation.W && rotation.W == 0) rotation = Quaternion.Identity; + //m_log.DebugFormat("[CLIENT]: Sending rotation {0} for {1} to {2}", rotation, localID, Name); + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateAvatarImprovedBlock(localID, position, velocity, rotation); ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); 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