From 932a1321167814ab13a21121a9b9a8bf2eca1641 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 20 Feb 2008 00:08:04 +0000 Subject: * Made a quickupdate method to run through only entities that have scheduled themselves for updates looking for changes. This runs 10 times a second. * Set the massively slow UpdateEntities method to run every 2 seconds instead of 10 times a second. This method runs through *all* of the entities can calls the virtual update(). * Documented some of the code in the scene.Update method. --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 33 ++++++++++++++++++++++ OpenSim/Region/Environment/Scenes/Scene.cs | 15 +++++++++- .../Region/Environment/Scenes/SceneObjectGroup.cs | 5 ++++ .../Region/Environment/Scenes/SceneObjectPart.cs | 3 ++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 57b8ae7..38bcb03 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -62,6 +62,7 @@ namespace OpenSim.Region.Environment.Scenes protected RegionInfo m_regInfo; protected Scene m_parentScene; protected PermissionManager PermissionsMngr; + protected List m_updateList = new List(); protected int m_numRootAgents = 0; protected int m_numPrim = 0; protected int m_numChildAgents = 0; @@ -146,6 +147,15 @@ namespace OpenSim.Region.Environment.Scenes } } + internal void UpdatePresences() + { + List updateScenePresences = GetScenePresences(); + foreach (ScenePresence pres in updateScenePresences) + { + pres.Update(); + } + } + internal float UpdatePhysics(double elapsed) { lock (m_syncRoot) @@ -194,6 +204,29 @@ namespace OpenSim.Region.Environment.Scenes } } + internal void AddToUpdateList(EntityBase obj) + { + lock (m_updateList) + { + if (!m_updateList.Contains(obj)) + { + m_updateList.Add(obj); + } + } + } + + internal void ProcessUpdates() + { + lock (m_updateList) + { + for (int i = 0; i < m_updateList.Count; i++) + { + m_updateList[i].Update(); + } + m_updateList.Clear(); + } + } + public void AddPhysicalPrim(int number) { m_physicalPrim++; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 7af3f5b..36e98cf 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -120,7 +120,9 @@ namespace OpenSim.Region.Environment.Scenes private int m_update_physics = 1; private int m_update_entitymovement = 1; - private int m_update_entities = 1; + private int m_update_entities = 20; // Run through all objects checking for updates + private int m_update_entitiesquick = 1; // Run through objects that have scheduled updates checking for updates + private int m_update_presences = 1; // Update scene presence movements private int m_update_events = 1; private int m_update_backup = 200; private int m_update_terrain = 50; @@ -706,9 +708,19 @@ namespace OpenSim.Region.Environment.Scenes physicsMS += physicsMS2; otherMS = System.Environment.TickCount; + // run through all entities looking for updates (slow) if (m_frame % m_update_entities == 0) m_innerScene.UpdateEntities(); + // run through entities that have scheduled themselves for + // updates looking for updates(faster) + if (m_frame % m_update_entitiesquick == 0) + m_innerScene.ProcessUpdates(); + + // Run through scenepresences looking for updates + if (m_frame % m_update_presences == 0) + m_innerScene.UpdatePresences(); + if (m_frame % m_update_events == 0) UpdateEvents(); @@ -1167,6 +1179,7 @@ namespace OpenSim.Region.Environment.Scenes } // if not phantom, add to physics sceneOb.ApplyPhysics(m_physicalPrim); + m_innerScene.AddToUpdateList(sceneOb); return sceneOb; } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 519858b..91b9a61 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -765,6 +765,11 @@ namespace OpenSim.Region.Environment.Scenes } } + public void QueueForUpdateCheck() + { + m_scene.m_innerScene.AddToUpdateList(this); + } + /// /// /// diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 00cabf8..a522380 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -1079,6 +1079,7 @@ namespace OpenSim.Region.Environment.Scenes if (m_parentGroup != null) { m_parentGroup.HasGroupChanged = true; + m_parentGroup.QueueForUpdateCheck(); } TimeStampFull = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 2; @@ -1120,9 +1121,11 @@ namespace OpenSim.Region.Environment.Scenes if (m_parentGroup != null) { m_parentGroup.HasGroupChanged = true; + m_parentGroup.QueueForUpdateCheck(); } TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 1; + } } -- cgit v1.1