From 86e5f82cb12dc5e854fe33526aee0ce899715410 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 11 Oct 2007 10:50:55 +0000 Subject: Some changes to the sending of updates of SceneObjects to clients, that I did a few weeks ago but never committed (and never completely finished what I had planned). --- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 105 ++++++++++++++------- 1 file changed, 70 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 428b771..22a0754 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -35,6 +35,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Region.Physics.Manager; +using OpenSim.Region.Environment.Types; namespace OpenSim.Region.Environment.Scenes { @@ -89,11 +90,13 @@ namespace OpenSim.Region.Environment.Scenes //public List InterestList = new List(); - // private Queue m_fullGroupUpdates = new Queue(); - // private Queue m_terseGroupUpdates = new Queue(); + // private string m_currentQuadNode = " "; - private readonly Queue m_fullPartUpdates = new Queue(); - private readonly Queue m_tersePartUpdates = new Queue(); + // private Queue m_fullPartUpdates = new Queue(); + //private Queue m_tersePartUpdates = new Queue(); + + private UpdateQueue m_partsUpdateQueue = new UpdateQueue(); + private Dictionary m_updateTimes = new Dictionary(); #region Properties @@ -277,53 +280,69 @@ namespace OpenSim.Region.Environment.Scenes #endregion - public void AddTersePart(SceneObjectPart part) - { - m_tersePartUpdates.Enqueue(part); - } - - public void AddFullPart(SceneObjectPart part) + public void QueuePartForUpdate(SceneObjectPart part) { - m_fullPartUpdates.Enqueue(part); + //if (InterestList.Contains(part.ParentGroup)) + //{ + lock (m_partsUpdateQueue) + { + m_partsUpdateQueue.Enqueue(part); + } + // } } public void SendPrimUpdates() { - if (m_tersePartUpdates.Count > 0) - { - bool terse = true; - int terseCount = 0; + // if (m_scene.QuadTree.GetNodeID(this.AbsolutePosition.X, this.AbsolutePosition.Y) != m_currentQuadNode) + //{ + // this.UpdateQuadTreeNode(); + //this.RefreshQuadObject(); + //} - while (terse) + if (m_partsUpdateQueue.Count > 0) + { + bool runUpdate = true; + int updateCount = 0; + while (runUpdate) { - SceneObjectPart part = m_tersePartUpdates.Dequeue(); - part.SendTerseUpdate(m_controllingClient); - terseCount++; - - if ((m_tersePartUpdates.Count < 1) | (terseCount > 30)) + SceneObjectPart part = m_partsUpdateQueue.Dequeue(); + if (m_updateTimes.ContainsKey(part.UUID)) + { + ScenePartUpdate update = m_updateTimes[part.UUID]; + if (update.LastFullUpdateTime < part.TimeStampFull) + { + //need to do a full update + part.SendFullUpdate(this.ControllingClient); + update.LastFullUpdateTime = (uint)Util.UnixTimeSinceEpoch(); + updateCount++; + } + else if (update.LastTerseUpdateTime < part.TimeStampTerse) + { + part.SendTerseUpdate(this.ControllingClient); + update.LastTerseUpdateTime = (uint)Util.UnixTimeSinceEpoch(); + updateCount++; + } + } + else { - terse = false; + //never been sent to client before so do full update + part.SendFullUpdate(this.ControllingClient); + ScenePartUpdate update = new ScenePartUpdate(); + update.FullID = part.UUID; + update.LastFullUpdateTime = (uint)Util.UnixTimeSinceEpoch(); + m_updateTimes.Add(part.UUID, update); + updateCount++; } - } - } - if (m_fullPartUpdates.Count > 0) - { - bool full = true; - int fullCount = 0; - while (full) - { - SceneObjectPart part = m_fullPartUpdates.Dequeue(); - part.SendFullUpdate(m_controllingClient); - fullCount++; - if ((m_fullPartUpdates.Count < 1) | (fullCount > 40)) + if (m_partsUpdateQueue.Count < 1 | updateCount > 60) { - full = false; + runUpdate = false; } } } } + #region Status Methods public void MakeAvatarPhysical(LLVector3 pos, bool isFlying) @@ -901,6 +920,22 @@ namespace OpenSim.Region.Environment.Scenes } } + public class ScenePartUpdate + { + public LLUUID FullID; + public uint LastFullUpdateTime; + public uint LastTerseUpdateTime; + + public ScenePartUpdate() + { + FullID = LLUUID.Zero; + LastFullUpdateTime = 0; + LastTerseUpdateTime = 0; + } + + } + + public override void SetText(string text, Vector3 color, double alpha) { throw new Exception("Can't set Text on avatar."); -- cgit v1.1