From 5fd17491509fb4b939666cdc37951e213f054242 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Fri, 11 Nov 2011 17:16:52 -0800 Subject: Remove SceneViewer from ScenePresence to reduce quadruple queueing of prim update to only triple queuing. Existing method was: 1. Schedule prim for update, adding to scene update list 2. Update on SOGs during heartbeat queues update onto each SceneViewer 3. Update on SPs during heartbeat queues update onto each IClientAPI 4. ProcessEntityUpdates queues updates into UDP send stack Now the SceneViewer has been eliminated so updates are scheduled at any time and then put onto the IClientAPI priority queues immediately during SceneGraph.UpdateObjectGroups. --- OpenSim/Region/Application/OpenSim.cs | 18 -- .../Region/Framework/Interfaces/ISceneViewer.cs | 50 ---- OpenSim/Region/Framework/Scenes/Scene.cs | 10 + .../Region/Framework/Scenes/SceneObjectGroup.cs | 24 -- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 68 +----- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 28 --- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 251 --------------------- 7 files changed, 22 insertions(+), 427 deletions(-) delete mode 100644 OpenSim/Region/Framework/Interfaces/ISceneViewer.cs delete mode 100644 OpenSim/Region/Framework/Scenes/SceneViewer.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 0cad8a9..ee26e4f 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -1049,24 +1049,6 @@ namespace OpenSim MainConsole.Instance.Output(handlers.ToString()); break; - case "pending-objects": - System.Text.StringBuilder pending = new System.Text.StringBuilder("Pending objects:\n"); - m_sceneManager.ForEachScene( - delegate(Scene scene) - { - scene.ForEachScenePresence( - delegate(ScenePresence sp) - { - pending.AppendFormat("{0}: {1} {2} pending\n", - scene.RegionInfo.RegionName, sp.Name, sp.SceneViewer.GetPendingObjectsCount()); - } - ); - } - ); - - MainConsole.Instance.Output(pending.ToString()); - break; - case "modules": MainConsole.Instance.Output("The currently loaded shared modules are:"); foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) diff --git a/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs b/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs deleted file mode 100644 index e715e70..0000000 --- a/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.Framework.Interfaces -{ - /// - /// Sends scheduled updates to it's associated ScenePresence. - /// - public interface ISceneViewer - { -// void Reset(); - void Close(); - - /// - /// Add the part to the queue of parts for which we need to send an update to the client - /// - /// - void QueuePartForUpdate(SceneObjectPart part); - - void SendPrimUpdates(); - int GetPendingObjectsCount(); - } -} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3b90c16..ce5b493 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2540,6 +2540,16 @@ namespace OpenSim.Region.Framework.Scenes if (vialogin) EventManager.TriggerOnClientLogin(client); } + + // Send all scene object to the new client + Util.FireAndForget(delegate + { + Entities.ForEach(delegate(EntityBase e) + { + if (e != null && e is SceneObjectGroup) + ((SceneObjectGroup)e).SendFullUpdateToClient(client); + }); + }); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4355394..9587d5f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1760,30 +1760,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public void ScheduleFullUpdateToAvatar(ScenePresence presence) - { -// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); - - RootPart.AddFullUpdateToAvatar(presence); - - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - if (part != RootPart) - part.AddFullUpdateToAvatar(presence); - } - } - - public void ScheduleTerseUpdateToAvatar(ScenePresence presence) - { -// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); - - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].AddTerseUpdateToAvatar(presence); - } - /// /// Schedule a full update for this scene object /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4e1383c..f693b36 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1373,25 +1373,6 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Debug("Aprev: " + prevflag.ToString() + " curr: " + Flags.ToString()); } - /// - /// Tell all scene presences that they should send updates for this part to their clients - /// - public void AddFullUpdateToAllAvatars() - { - ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) - { - AddFullUpdateToAvatar(avatar); - }); - } - - /// - /// Tell the scene presence that it should send updates for this part to its client - /// - public void AddFullUpdateToAvatar(ScenePresence presence) - { - presence.SceneViewer.QueuePartForUpdate(this); - } - public void AddNewParticleSystem(Primitive.ParticleSystem pSystem) { m_particleSystem = pSystem.GetBytes(); @@ -1402,20 +1383,6 @@ namespace OpenSim.Region.Framework.Scenes m_particleSystem = new byte[0]; } - /// Terse updates - public void AddTerseUpdateToAllAvatars() - { - ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) - { - AddTerseUpdateToAvatar(avatar); - }); - } - - public void AddTerseUpdateToAvatar(ScenePresence presence) - { - presence.SceneViewer.QueuePartForUpdate(this); - } - public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim) { byte[] data = new byte[16]; @@ -2650,8 +2617,6 @@ namespace OpenSim.Region.Framework.Scenes //ParentGroup.RootPart.m_groupPosition = newpos; } ScheduleTerseUpdate(); - - //SendTerseUpdateToAllClients(); } public void PreloadSound(string sound) @@ -2834,6 +2799,13 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup == null) return; + // This was pulled from SceneViewer. Attachments always receive full updates. + // I could not verify if this is a requirement but this maintains existing behavior + if (ParentGroup.IsAttachment) + { + ScheduleFullUpdate(); + } + if (UpdateFlag == UpdateRequired.NONE) { ParentGroup.HasGroupChanged = true; @@ -2928,23 +2900,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Send a full update to all clients except the one nominated. - /// - /// - public void SendFullUpdateToAllClientsExcept(UUID agentID) - { - if (ParentGroup == null) - return; - - ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) - { - // Ugly reference :( - if (avatar.UUID != agentID) - SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID)); - }); - } - - /// /// Sends a full update to the client /// /// @@ -3020,7 +2975,8 @@ namespace OpenSim.Region.Framework.Scenes !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { - AddTerseUpdateToAllAvatars(); + + SendTerseUpdateToAllClients(); ClearUpdateSchedule(); // Update the "last" values @@ -3035,7 +2991,7 @@ namespace OpenSim.Region.Framework.Scenes } case UpdateRequired.FULL: { - AddFullUpdateToAllAvatars(); + SendFullUpdateToAllClients(); break; } } @@ -3140,9 +3096,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendTerseUpdateToAllClients() { - ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) + ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) { - SendTerseUpdateToClient(avatar.ControllingClient); + SendTerseUpdateToClient(client); }); } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3fee642..a4cb7cf 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -135,7 +135,6 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; - //private int m_lastTerseSent; private Vector3? m_forceToApply; private int m_userFlags; @@ -644,14 +643,6 @@ namespace OpenSim.Region.Framework.Scenes set { m_health = value; } } - private ISceneViewer m_sceneViewer; - - public ISceneViewer SceneViewer - { - get { return m_sceneViewer; } - private set { m_sceneViewer = value; } - } - public void AdjustKnownSeeds() { Dictionary seeds; @@ -755,7 +746,6 @@ namespace OpenSim.Region.Framework.Scenes AttachmentsSyncLock = new Object(); m_sendCourseLocationsMethod = SendCoarseLocationsDefault; - SceneViewer = new SceneViewer(this); Animator = new ScenePresenceAnimator(this); PresenceType = type; DrawDistance = world.DefaultDrawDistance; @@ -866,16 +856,6 @@ namespace OpenSim.Region.Framework.Scenes return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID); } - /// - /// Send updates to the client about prims which have been placed on the update queue. We don't - /// necessarily send updates for all the parts on the queue, e.g. if an updates with a more recent - /// timestamp has already been sent. - /// - public void SendPrimUpdates() - { - SceneViewer.SendPrimUpdates(); - } - #region Status Methods /// @@ -2412,10 +2392,6 @@ namespace OpenSim.Region.Framework.Scenes const float ROTATION_TOLERANCE = 0.01f; const float VELOCITY_TOLERANCE = 0.001f; const float POSITION_TOLERANCE = 0.05f; - //const int TIME_MS_TOLERANCE = 3000; - - if (!sendingPrims) - Util.FireAndForget(delegate { sendingPrims = true; SendPrimUpdates(); sendingPrims = false; }); if (IsChildAgent == false) { @@ -2427,7 +2403,6 @@ namespace OpenSim.Region.Framework.Scenes if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) - //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { SendTerseUpdateToAllClients(); @@ -2435,7 +2410,6 @@ namespace OpenSim.Region.Framework.Scenes m_lastPosition = m_pos; m_lastRotation = Rotation; m_lastVelocity = Velocity; - //m_lastTerseSent = Environment.TickCount; } // followed suggestion from mic bowman. reversed the two lines below. @@ -3418,8 +3392,6 @@ namespace OpenSim.Region.Framework.Scenes // unsetting the elapsed callback should be enough to allow for cleanup however. // m_reprioritizationTimer.Dispose(); - SceneViewer.Close(); - RemoveFromPhysicalScene(); Animator.Close(); Animator = null; diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs deleted file mode 100644 index d6bb81c..0000000 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using OpenMetaverse; -using log4net; -using OpenSim.Framework; -using OpenSim.Framework.Client; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes.Types; - -namespace OpenSim.Region.Framework.Scenes -{ - public class SceneViewer : ISceneViewer - { - /// - /// Is this scene viewer enabled? - /// - private bool IsEnabled { get; set; } - - /// - /// The scene presence serviced by this viewer. - /// - protected ScenePresence m_presence; - - /// - /// The queue of parts for which we need to send out updates. - /// - protected UpdateQueue m_partsUpdateQueue = new UpdateQueue(); - - /// - /// The queue of objects for which we need to send out updates. - /// - protected Queue m_pendingObjects; - - /// - /// The last update assocated with a given part update. - /// - protected Dictionary m_updateTimes = new Dictionary(); - - public SceneViewer(ScenePresence presence) - { - m_presence = presence; - IsEnabled = true; - } - - public void QueuePartForUpdate(SceneObjectPart part) - { - if (!IsEnabled) - return; - - lock (m_partsUpdateQueue) - { - m_partsUpdateQueue.Enqueue(part); - } - } - - public void SendPrimUpdates() - { - if (m_pendingObjects == null) - { - m_pendingObjects = new Queue(); - - lock (m_pendingObjects) - { - EntityBase[] entities = m_presence.Scene.Entities.GetEntities(); - foreach (EntityBase e in entities) - { - if (e != null && e is SceneObjectGroup) - m_pendingObjects.Enqueue((SceneObjectGroup)e); - } - } - } - - lock (m_pendingObjects) - { - // We must do this under lock so that we don't suffer a race condition if another thread closes the - // viewer - if (!IsEnabled) - return; - - while (m_pendingObjects != null && m_pendingObjects.Count > 0) - { - SceneObjectGroup g = m_pendingObjects.Dequeue(); - // Yes, this can really happen - if (g == null) - continue; - - // This is where we should check for draw distance - // do culling and stuff. Problem with that is that until - // we recheck in movement, that won't work right. - // So it's not implemented now. - // - - // Don't even queue if we have sent this one - // - if (!m_updateTimes.ContainsKey(g.UUID)) - g.ScheduleFullUpdateToAvatar(m_presence); - } - - while (m_partsUpdateQueue.Count > 0) - { - SceneObjectPart part = m_partsUpdateQueue.Dequeue(); - - if (part.ParentGroup.IsDeleted) - continue; - - if (m_updateTimes.ContainsKey(part.UUID)) - { - ScenePartUpdate update = m_updateTimes[part.UUID]; - - // We deal with the possibility that two updates occur at - // the same unix time at the update point itself. - if ((update.LastFullUpdateTime < part.TimeStampFull) || part.ParentGroup.IsAttachment) - { - // m_log.DebugFormat( - // "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}", - // part.Name, part.UUID, part.TimeStampFull); - - part.SendFullUpdate(m_presence.ControllingClient, - m_presence.GenerateClientFlags(part.UUID)); - - // We'll update to the part's timestamp rather than - // the current time to avoid the race condition - // whereby the next tick occurs while we are doing - // this update. If this happened, then subsequent - // updates which occurred on the same tick or the - // next tick of the last update would be ignored. - update.LastFullUpdateTime = part.TimeStampFull; - } - else if (update.LastTerseUpdateTime <= part.TimeStampTerse) - { - // m_log.DebugFormat( - // "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", - // part.Name, part.UUID, part.TimeStampTerse); - - part.SendTerseUpdateToClient(m_presence.ControllingClient); - - update.LastTerseUpdateTime = part.TimeStampTerse; - } - } - else - { - //never been sent to client before so do full update - ScenePartUpdate update = new ScenePartUpdate(); - update.FullID = part.UUID; - update.LastFullUpdateTime = part.TimeStampFull; - m_updateTimes.Add(part.UUID, update); - - // Attachment handling - // - if (part.ParentGroup.RootPart.Shape.PCode == 9 && part.ParentGroup.RootPart.Shape.State != 0) - { - if (part != part.ParentGroup.RootPart) - continue; - - part.ParentGroup.SendFullUpdateToClient(m_presence.ControllingClient); - continue; - } - - part.SendFullUpdate(m_presence.ControllingClient, - m_presence.GenerateClientFlags(part.UUID)); - } - } - } - } - -// public void Reset() -// { -// if (m_pendingObjects == null) -// return; -// -// lock (m_pendingObjects) -// { -// if (m_pendingObjects != null) -// { -// m_pendingObjects.Clear(); -// m_pendingObjects = null; -// } -// } -// } - - public void Close() - { - lock (m_pendingObjects) - { - // We perform this under the m_pendingObjects lock in order to avoid a race condition with another - // thread on SendPrimUpdates() - IsEnabled = false; - - lock (m_updateTimes) - { - m_updateTimes.Clear(); - } - - lock (m_partsUpdateQueue) - { - m_partsUpdateQueue.Clear(); - } - } - } - - public int GetPendingObjectsCount() - { - if (m_pendingObjects != null) - lock (m_pendingObjects) - return m_pendingObjects.Count; - - return 0; - } - - public class ScenePartUpdate - { - public UUID FullID; - public uint LastFullUpdateTime; - public uint LastTerseUpdateTime; - - public ScenePartUpdate() - { - FullID = UUID.Zero; - LastFullUpdateTime = 0; - LastTerseUpdateTime = 0; - } - } - } -} -- cgit v1.1