diff options
author | Dan Lake | 2010-03-19 05:51:16 -0700 |
---|---|---|
committer | John Hurliman | 2010-03-19 15:16:35 -0700 |
commit | 859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046 (patch) | |
tree | dcce6c74d201b52c1a04ec9ec2cb90ce068fc020 /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Inconsistent locking of ScenePresence array in SceneGraph. Fixed by eliminati... (diff) | |
download | opensim-SC_OLD-859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046.zip opensim-SC_OLD-859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046.tar.gz opensim-SC_OLD-859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046.tar.bz2 opensim-SC_OLD-859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046.tar.xz |
Cleaned up access to scenepresences in scenegraph. GetScenePresences and GetAvatars have been removed to consolidate locking and iteration within SceneGraph. All callers which used these to then iterate over presences have been refactored to instead pass their delegates to Scene.ForEachScenePresence(Action<ScenePresence>).
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 766f6d3..b5f6217 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2396,35 +2396,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
2396 | 2396 | ||
2397 | List<Vector3> CoarseLocations = new List<Vector3>(); | 2397 | List<Vector3> CoarseLocations = new List<Vector3>(); |
2398 | List<UUID> AvatarUUIDs = new List<UUID>(); | 2398 | List<UUID> AvatarUUIDs = new List<UUID>(); |
2399 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 2399 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
2400 | for (int i = 0; i < avatars.Count; i++) | ||
2401 | { | 2400 | { |
2402 | // Requested by LibOMV. Send Course Location on self. | 2401 | if (sp.IsChildAgent) |
2403 | //if (avatars[i] != this) | 2402 | return; |
2404 | //{ | 2403 | |
2405 | if (avatars[i].ParentID != 0) | 2404 | if (sp.ParentID != 0) |
2405 | { | ||
2406 | // sitting avatar | ||
2407 | SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID); | ||
2408 | if (sop != null) | ||
2406 | { | 2409 | { |
2407 | // sitting avatar | 2410 | CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos); |
2408 | SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); | 2411 | AvatarUUIDs.Add(sp.UUID); |
2409 | if (sop != null) | ||
2410 | { | ||
2411 | CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos); | ||
2412 | AvatarUUIDs.Add(avatars[i].UUID); | ||
2413 | } | ||
2414 | else | ||
2415 | { | ||
2416 | // we can't find the parent.. ! arg! | ||
2417 | CoarseLocations.Add(avatars[i].m_pos); | ||
2418 | AvatarUUIDs.Add(avatars[i].UUID); | ||
2419 | } | ||
2420 | } | 2412 | } |
2421 | else | 2413 | else |
2422 | { | 2414 | { |
2423 | CoarseLocations.Add(avatars[i].m_pos); | 2415 | // we can't find the parent.. ! arg! |
2424 | AvatarUUIDs.Add(avatars[i].UUID); | 2416 | CoarseLocations.Add(sp.m_pos); |
2417 | AvatarUUIDs.Add(sp.UUID); | ||
2425 | } | 2418 | } |
2426 | //} | 2419 | } |
2427 | } | 2420 | else |
2421 | { | ||
2422 | CoarseLocations.Add(sp.m_pos); | ||
2423 | AvatarUUIDs.Add(sp.UUID); | ||
2424 | } | ||
2425 | }); | ||
2428 | 2426 | ||
2429 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); | 2427 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); |
2430 | 2428 | ||
@@ -2498,13 +2496,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2498 | m_perfMonMS = Util.EnvironmentTickCount(); | 2496 | m_perfMonMS = Util.EnvironmentTickCount(); |
2499 | 2497 | ||
2500 | // only send update from root agents to other clients; children are only "listening posts" | 2498 | // only send update from root agents to other clients; children are only "listening posts" |
2501 | List<ScenePresence> avatars = m_scene.GetAvatars(); | 2499 | int count = 0; |
2502 | foreach (ScenePresence avatar in avatars) | 2500 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
2503 | { | 2501 | { |
2504 | SendFullUpdateToOtherClient(avatar); | 2502 | if (sp.IsChildAgent) |
2505 | 2503 | return; | |
2506 | } | 2504 | SendFullUpdateToOtherClient(sp); |
2507 | m_scene.StatsReporter.AddAgentUpdates(avatars.Count); | 2505 | ++count; |
2506 | }); | ||
2507 | m_scene.StatsReporter.AddAgentUpdates(count); | ||
2508 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2508 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2509 | 2509 | ||
2510 | Animator.SendAnimPack(); | 2510 | Animator.SendAnimPack(); |