diff options
author | Diva Canto | 2013-07-20 12:20:35 -0700 |
---|---|---|
committer | Diva Canto | 2013-07-21 09:00:42 -0700 |
commit | d5a1779465b6d875ebe5822ce6f15df3378b759f (patch) | |
tree | 6c794ccabc5c3cbbc27bdfe94c6f4147f2c2aa99 /OpenSim/Region/ClientStack/Linden | |
parent | Fixed the stats in show client stats. Also left some comments with observatio... (diff) | |
download | opensim-SC-d5a1779465b6d875ebe5822ce6f15df3378b759f.zip opensim-SC-d5a1779465b6d875ebe5822ce6f15df3378b759f.tar.gz opensim-SC-d5a1779465b6d875ebe5822ce6f15df3378b759f.tar.bz2 opensim-SC-d5a1779465b6d875ebe5822ce6f15df3378b759f.tar.xz |
Manage AgentUpdates more sanely:
- The existing event to scene has been split into 2: OnAgentUpdate and OnAgentCameraUpdate, to better reflect the two types of updates that the viewer sends. We can run one without the other, which is what happens when the avie is still but the user is camming around
- Added thresholds (as opposed to equality) to determine whether the update is significant or not. I thin these thresholds are ok, but we can play with them later
- Ignore updates of HeadRotation, which were problematic and aren't being used up stream
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 214 |
1 files changed, 108 insertions, 106 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 66a8ea7..6c58aac 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -96,6 +96,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
96 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; | 96 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; |
97 | public event UpdateAgent OnPreAgentUpdate; | 97 | public event UpdateAgent OnPreAgentUpdate; |
98 | public event UpdateAgent OnAgentUpdate; | 98 | public event UpdateAgent OnAgentUpdate; |
99 | public event UpdateAgent OnAgentCameraUpdate; | ||
99 | public event AgentRequestSit OnAgentRequestSit; | 100 | public event AgentRequestSit OnAgentRequestSit; |
100 | public event AgentSit OnAgentSit; | 101 | public event AgentSit OnAgentSit; |
101 | public event AvatarPickerRequest OnAvatarPickerRequest; | 102 | public event AvatarPickerRequest OnAvatarPickerRequest; |
@@ -357,9 +358,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
357 | /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods | 358 | /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods |
358 | /// cannot retain a reference to it outside of that method. | 359 | /// cannot retain a reference to it outside of that method. |
359 | /// </remarks> | 360 | /// </remarks> |
360 | private AgentUpdateArgs m_lastAgentUpdateArgs = new AgentUpdateArgs(); | ||
361 | |||
362 | private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs(); | 361 | private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs(); |
362 | private float qdelta1; | ||
363 | private float qdelta2; | ||
364 | private float vdelta1; | ||
365 | private float vdelta2; | ||
366 | private float vdelta3; | ||
367 | private float vdelta4; | ||
363 | 368 | ||
364 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); | 369 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); |
365 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers | 370 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers |
@@ -5571,57 +5576,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5571 | 5576 | ||
5572 | #region Scene/Avatar | 5577 | #region Scene/Avatar |
5573 | 5578 | ||
5579 | private const float QDELTA = 0.01f; | ||
5580 | private const float VDELTA = 0.01f; | ||
5581 | |||
5574 | /// <summary> | 5582 | /// <summary> |
5575 | /// This checks the update significance against the last update made. | 5583 | /// This checks the update significance against the last update made. |
5576 | /// </summary> | 5584 | /// </summary> |
5577 | /// <remarks>Can only be called by one thread at a time</remarks> | 5585 | /// <remarks>Can only be called by one thread at a time</remarks> |
5578 | /// <returns>/returns> | 5586 | /// <returns></returns> |
5579 | /// <param name='x'></param> | 5587 | /// <param name='x'></param> |
5580 | public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) | 5588 | public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) |
5581 | { | 5589 | { |
5582 | // These should be ordered from most-likely to | 5590 | return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x); |
5583 | // least likely to change. I've made an initial | 5591 | } |
5584 | // guess at that. | 5592 | |
5593 | /// <summary> | ||
5594 | /// This checks the movement/state update significance against the last update made. | ||
5595 | /// </summary> | ||
5596 | /// <remarks>Can only be called by one thread at a time</remarks> | ||
5597 | /// <returns></returns> | ||
5598 | /// <param name='x'></param> | ||
5599 | public bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) | ||
5600 | { | ||
5601 | qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2); | ||
5602 | qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2); | ||
5603 | if ( | ||
5604 | (qdelta1 > QDELTA) || | ||
5605 | // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack | ||
5606 | //(qdelta2 > QDELTA * 10) || | ||
5607 | (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) || | ||
5608 | (x.Far != m_thisAgentUpdateArgs.Far) || | ||
5609 | (x.Flags != m_thisAgentUpdateArgs.Flags) || | ||
5610 | (x.State != m_thisAgentUpdateArgs.State) | ||
5611 | ) | ||
5612 | { | ||
5613 | //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", | ||
5614 | // qdelta1, qdelta2); | ||
5615 | //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3} (Thread {4})", | ||
5616 | // x.ControlFlags, x.Flags, x.Far, x.State, Thread.CurrentThread.Name); | ||
5617 | return true; | ||
5618 | } | ||
5619 | |||
5620 | return false; | ||
5621 | } | ||
5622 | |||
5623 | /// <summary> | ||
5624 | /// This checks the camera update significance against the last update made. | ||
5625 | /// </summary> | ||
5626 | /// <remarks>Can only be called by one thread at a time</remarks> | ||
5627 | /// <returns></returns> | ||
5628 | /// <param name='x'></param> | ||
5629 | public bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) | ||
5630 | { | ||
5631 | vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis); | ||
5632 | vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter); | ||
5633 | vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); | ||
5634 | vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis); | ||
5585 | if ( | 5635 | if ( |
5586 | /* These 4 are the worst offenders! We should consider ignoring most of them. | 5636 | /* These 4 are the worst offenders! |
5587 | * With Singularity, there is a bug where sometimes the spam on these doesn't stop */ | 5637 | * With Singularity, there is a bug where sometimes the spam on these doesn't stop */ |
5588 | (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || | 5638 | (vdelta1 > VDELTA) || |
5589 | (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || | 5639 | (vdelta2 > VDELTA) || |
5590 | (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || | 5640 | (vdelta3 > VDELTA) || |
5591 | (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || | 5641 | (vdelta4 > VDELTA) |
5592 | /* */ | ||
5593 | (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || | ||
5594 | (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || | ||
5595 | (x.Far != m_lastAgentUpdateArgs.Far) || | ||
5596 | (x.Flags != m_lastAgentUpdateArgs.Flags) || | ||
5597 | (x.State != m_lastAgentUpdateArgs.State) || | ||
5598 | (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || | ||
5599 | (x.SessionID != m_lastAgentUpdateArgs.SessionID) || | ||
5600 | (x.AgentID != m_lastAgentUpdateArgs.AgentID) | ||
5601 | ) | 5642 | ) |
5602 | { | 5643 | { |
5603 | //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", | 5644 | //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", |
5604 | // x.CameraAtAxis, x.CameraCenter); | 5645 | // x.CameraAtAxis, x.CameraCenter); |
5605 | //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", | 5646 | //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", |
5606 | // x.CameraLeftAxis, x.CameraUpAxis); | 5647 | // x.CameraLeftAxis, x.CameraUpAxis); |
5607 | //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", | ||
5608 | // x.BodyRotation, x.HeadRotation); | ||
5609 | //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}", | ||
5610 | // x.ControlFlags, x.Flags, x.Far, x.State); | ||
5611 | |||
5612 | m_lastAgentUpdateArgs.AgentID = x.AgentID; | ||
5613 | m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; | ||
5614 | m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; | ||
5615 | m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter; | ||
5616 | m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; | ||
5617 | m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; | ||
5618 | m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags; | ||
5619 | m_lastAgentUpdateArgs.Far = x.Far; | ||
5620 | m_lastAgentUpdateArgs.Flags = x.Flags; | ||
5621 | m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation; | ||
5622 | m_lastAgentUpdateArgs.SessionID = x.SessionID; | ||
5623 | m_lastAgentUpdateArgs.State = x.State; | ||
5624 | |||
5625 | return true; | 5648 | return true; |
5626 | } | 5649 | } |
5627 | 5650 | ||
@@ -5629,75 +5652,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5629 | } | 5652 | } |
5630 | 5653 | ||
5631 | private bool HandleAgentUpdate(IClientAPI sener, Packet packet) | 5654 | private bool HandleAgentUpdate(IClientAPI sener, Packet packet) |
5632 | { | 5655 | { |
5633 | if (OnAgentUpdate != null) | 5656 | // We got here, which means that something in agent update was significant |
5634 | { | ||
5635 | AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; | ||
5636 | 5657 | ||
5637 | // Now done earlier | 5658 | AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; |
5638 | // #region Packet Session and User Check | 5659 | AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; |
5639 | // if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId) | 5660 | |
5640 | // { | 5661 | if (x.AgentID != AgentId || x.SessionID != SessionId) |
5641 | // PacketPool.Instance.ReturnPacket(packet); | 5662 | return false; |
5642 | // return false; | 5663 | |
5643 | // } | 5664 | // Before we update the current m_thisAgentUpdateArgs, let's check this again |
5644 | // #endregion | 5665 | // to see what exactly changed |
5645 | // | 5666 | bool movement = CheckAgentMovementUpdateSignificance(x); |
5646 | // bool update = false; | 5667 | bool camera = CheckAgentCameraUpdateSignificance(x); |
5647 | AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; | 5668 | |
5648 | // | 5669 | m_thisAgentUpdateArgs.AgentID = x.AgentID; |
5649 | // if (m_lastAgentUpdateArgs != null) | 5670 | m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; |
5650 | // { | 5671 | m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; |
5651 | // // These should be ordered from most-likely to | 5672 | m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; |
5652 | // // least likely to change. I've made an initial | 5673 | m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; |
5653 | // // guess at that. | 5674 | m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; |
5654 | // update = | 5675 | m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; |
5655 | // ( | 5676 | m_thisAgentUpdateArgs.Far = x.Far; |
5656 | // (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || | 5677 | m_thisAgentUpdateArgs.Flags = x.Flags; |
5657 | // (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || | 5678 | m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; |
5658 | // (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || | 5679 | m_thisAgentUpdateArgs.SessionID = x.SessionID; |
5659 | // (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || | 5680 | m_thisAgentUpdateArgs.State = x.State; |
5660 | // (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || | 5681 | |
5661 | // (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || | 5682 | UpdateAgent handlerAgentUpdate = OnAgentUpdate; |
5662 | // (x.Far != m_lastAgentUpdateArgs.Far) || | 5683 | UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; |
5663 | // (x.Flags != m_lastAgentUpdateArgs.Flags) || | 5684 | UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate; |
5664 | // (x.State != m_lastAgentUpdateArgs.State) || | 5685 | |
5665 | // (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || | 5686 | // Was there a significant movement/state change? |
5666 | // (x.SessionID != m_lastAgentUpdateArgs.SessionID) || | 5687 | if (movement) |
5667 | // (x.AgentID != m_lastAgentUpdateArgs.AgentID) | 5688 | { |
5668 | // ); | 5689 | if (handlerPreAgentUpdate != null) |
5669 | // } | 5690 | OnPreAgentUpdate(this, m_thisAgentUpdateArgs); |
5670 | // | 5691 | |
5671 | // if (update) | 5692 | if (handlerAgentUpdate != null) |
5672 | // { | 5693 | OnAgentUpdate(this, m_thisAgentUpdateArgs); |
5673 | //// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); | 5694 | } |
5674 | 5695 | // Was there a significant camera(s) change? | |
5675 | m_thisAgentUpdateArgs.AgentID = x.AgentID; | 5696 | if (camera) |
5676 | m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; | 5697 | if (handlerAgentCameraUpdate != null) |
5677 | m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; | 5698 | handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs); |
5678 | m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; | 5699 | |
5679 | m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; | 5700 | handlerAgentUpdate = null; |
5680 | m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; | 5701 | handlerPreAgentUpdate = null; |
5681 | m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; | 5702 | handlerAgentCameraUpdate = null; |
5682 | m_thisAgentUpdateArgs.Far = x.Far; | ||
5683 | m_thisAgentUpdateArgs.Flags = x.Flags; | ||
5684 | m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; | ||
5685 | m_thisAgentUpdateArgs.SessionID = x.SessionID; | ||
5686 | m_thisAgentUpdateArgs.State = x.State; | ||
5687 | |||
5688 | UpdateAgent handlerAgentUpdate = OnAgentUpdate; | ||
5689 | UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; | ||
5690 | |||
5691 | if (handlerPreAgentUpdate != null) | ||
5692 | OnPreAgentUpdate(this, m_thisAgentUpdateArgs); | ||
5693 | |||
5694 | if (handlerAgentUpdate != null) | ||
5695 | OnAgentUpdate(this, m_thisAgentUpdateArgs); | ||
5696 | |||
5697 | handlerAgentUpdate = null; | ||
5698 | handlerPreAgentUpdate = null; | ||
5699 | // } | ||
5700 | } | ||
5701 | 5703 | ||
5702 | PacketPool.Instance.ReturnPacket(packet); | 5704 | PacketPool.Instance.ReturnPacket(packet); |
5703 | 5705 | ||