From b98613091cd6dc2f914fb5ab38ca33cdff21fc24 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 27 Oct 2011 00:42:21 -0700 Subject: Added new ForEachRootScenePresence to Scene since almost every delegate passed to ForEachScenePresence checks for !IsChildAgent first. It consolidates child and root handling for coming refactors. --- OpenSim/Region/Framework/Scenes/Scene.cs | 60 +++++++++++++------------ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 16 ++++++- OpenSim/Region/Framework/Scenes/SceneManager.cs | 9 ++-- 3 files changed, 50 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e43185d..302103a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -893,22 +893,17 @@ namespace OpenSim.Region.Framework.Scenes try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - //agent.ControllingClient.new - //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - - List old = new List(); - old.Add(otherRegion.RegionHandle); - agent.DropOldNeighbours(old); - if (m_teleportModule != null) - m_teleportModule.EnableChildAgent(agent, otherRegion); - } - } - ); + ForEachRootScenePresence(delegate(ScenePresence agent) + { + //agent.ControllingClient.new + //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + + List old = new List(); + old.Add(otherRegion.RegionHandle); + agent.DropOldNeighbours(old); + if (m_teleportModule != null) + m_teleportModule.EnableChildAgent(agent, otherRegion); + }); } catch (NullReferenceException) { @@ -1043,16 +1038,11 @@ namespace OpenSim.Region.Framework.Scenes GridRegion r = new GridRegion(region); try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - if (m_teleportModule != null) - m_teleportModule.EnableChildAgent(agent, r); - } - } - ); + ForEachRootScenePresence(delegate(ScenePresence agent) + { + if (m_teleportModule != null) + m_teleportModule.EnableChildAgent(agent, r); + }); } catch (NullReferenceException) { @@ -1456,11 +1446,10 @@ namespace OpenSim.Region.Framework.Scenes /// Stats on the Simulator's performance private void SendSimStatsPackets(SimStats stats) { - ForEachScenePresence( + ForEachRootScenePresence( delegate(ScenePresence agent) { - if (!agent.IsChildAgent) - agent.ControllingClient.SendSimStats(stats); + agent.ControllingClient.SendSimStats(stats); } ); } @@ -4290,6 +4279,19 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// Performs action on all ROOT (not child) scene presences. + /// This is just a shortcut function since frequently actions only appy to root SPs + /// + /// + public void ForEachRootScenePresence(Action action) + { + if(m_sceneGraph != null) + { + m_sceneGraph.ForEachRootScenePresence(action); + } + } + + /// /// Performs action on all scene presences. /// /// diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index caec704..542bd51 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1190,7 +1190,21 @@ namespace OpenSim.Region.Framework.Scenes } } } - + + /// + /// Performs action on all ROOT (not child) scene presences. + /// This is just a shortcut function since frequently actions only appy to root SPs + /// + /// + public void ForEachRootScenePresence(Action action) + { + ForEachScenePresence(delegate(ScenePresence sp) + { + if (!sp.IsChildAgent) + action(sp); + }); + } + /// /// Performs action on all scene presences. This can ultimately run the actions in parallel but /// any delegates passed in will need to implement their own locking on data they reference and diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index a58b87d..3bfd866 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -458,9 +458,9 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { - if (!scenePresence.IsChildAgent && (name == null || scenePresence.Name == name)) + if (name == null || scenePresence.Name == name) { m_log.DebugFormat("Packet debug for {0} {1} set to {2}", scenePresence.Firstname, @@ -481,10 +481,9 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { - if (!scenePresence.IsChildAgent) - avatars.Add(scenePresence); + avatars.Add(scenePresence); }); } ); -- cgit v1.1 From 06577d7299f38c342c9b241c691e647e5329837e Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 27 Oct 2011 01:25:12 -0700 Subject: Continuation of previous checkin. Found more places where ForEachScenePresence can be changed to ForEachRootScenePresence. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 ++-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 53 ++++++++++------------ 2 files changed, 26 insertions(+), 36 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c8ecc9b..3a4f52e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1440,10 +1440,9 @@ namespace OpenSim.Region.Framework.Scenes if (volume < 0) volume = 0; - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) + m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); + sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); }); } @@ -2676,10 +2675,8 @@ namespace OpenSim.Region.Framework.Scenes } } - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) + m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (sp.IsChildAgent) - return; if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100)) sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); }); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ee6c708..3834b79 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2598,19 +2598,15 @@ namespace OpenSim.Region.Framework.Scenes public void SendOtherAgentsAvatarDataToMe() { int count = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - // only send information about root agents - if (scenePresence.IsChildAgent) - return; - - // only send information about other root agents - if (scenePresence.UUID == UUID) - return; + m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + { + // only send information about other root agents + if (scenePresence.UUID == UUID) + return; - scenePresence.SendAvatarDataToAgent(this); - count++; - }); + scenePresence.SendAvatarDataToAgent(this); + count++; + }); m_scene.StatsReporter.AddAgentUpdates(count); } @@ -2644,13 +2640,14 @@ namespace OpenSim.Region.Framework.Scenes int count = 0; m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - if (scenePresence.UUID == UUID) - return; + { + // only send information to other root agents + if (scenePresence.UUID == UUID) + return; - SendAppearanceToAgent(scenePresence); - count++; - }); + SendAppearanceToAgent(scenePresence); + count++; + }); m_scene.StatsReporter.AddAgentUpdates(count); } @@ -2664,19 +2661,15 @@ namespace OpenSim.Region.Framework.Scenes //m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} ({1})", Name, UUID); int count = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - // only send information about root agents - if (scenePresence.IsChildAgent) - return; - - // only send information about other root agents - if (scenePresence.UUID == UUID) - return; + m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + { + // only send information about other root agents + if (scenePresence.UUID == UUID) + return; - scenePresence.SendAppearanceToAgent(this); - count++; - }); + scenePresence.SendAppearanceToAgent(this); + count++; + }); m_scene.StatsReporter.AddAgentUpdates(count); } -- cgit v1.1