diff options
author | Dan Lake | 2010-06-08 16:30:51 -0700 |
---|---|---|
committer | John Hurliman | 2010-06-08 16:44:18 -0700 |
commit | ca2abc43ad440a99f17b43d32de89e77fdeef00e (patch) | |
tree | ac8787b8db9c38d4875cc4123245006084e35609 /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-ca2abc43ad440a99f17b43d32de89e77fdeef00e.zip opensim-SC-ca2abc43ad440a99f17b43d32de89e77fdeef00e.tar.gz opensim-SC-ca2abc43ad440a99f17b43d32de89e77fdeef00e.tar.bz2 opensim-SC-ca2abc43ad440a99f17b43d32de89e77fdeef00e.tar.xz |
Refactor SendCoarseLocations for better performance. Instead of computing list of all locations fresh for every scene presence on every frame, we will instead compute the list once every 50 frames and send to all connected presences at that time. Also, we only add 60 items to the list when there are more than 60 presences in the scene. For 1000 users, this change yields a 99.8% reduction in list processing and a 98% reduction in network bandwidth for coarse locations.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 56 |
1 files changed, 5 insertions, 51 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 45375b0..15b9446 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
65 | public ScriptControlled eventControls; | 65 | public ScriptControlled eventControls; |
66 | } | 66 | } |
67 | 67 | ||
68 | public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence); | 68 | public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs); |
69 | 69 | ||
70 | public class ScenePresence : EntityBase, ISceneEntity | 70 | public class ScenePresence : EntityBase, ISceneEntity |
71 | { | 71 | { |
@@ -173,8 +173,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
173 | 173 | ||
174 | public string JID = String.Empty; | 174 | public string JID = String.Empty; |
175 | 175 | ||
176 | // Agent moves with a PID controller causing a force to be exerted. | ||
177 | private bool m_newCoarseLocations = true; | ||
178 | private float m_health = 100f; | 176 | private float m_health = 100f; |
179 | 177 | ||
180 | // Default AV Height | 178 | // Default AV Height |
@@ -2296,12 +2294,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2296 | 2294 | ||
2297 | SendPrimUpdates(); | 2295 | SendPrimUpdates(); |
2298 | 2296 | ||
2299 | if (m_newCoarseLocations) | ||
2300 | { | ||
2301 | SendCoarseLocations(); | ||
2302 | m_newCoarseLocations = false; | ||
2303 | } | ||
2304 | |||
2305 | if (m_isChildAgent == false) | 2297 | if (m_isChildAgent == false) |
2306 | { | 2298 | { |
2307 | // PhysicsActor actor = m_physicsActor; | 2299 | // PhysicsActor actor = m_physicsActor; |
@@ -2375,12 +2367,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2375 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2367 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2376 | } | 2368 | } |
2377 | 2369 | ||
2378 | public void SendCoarseLocations() | 2370 | public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
2379 | { | 2371 | { |
2380 | SendCourseLocationsMethod d = m_sendCourseLocationsMethod; | 2372 | SendCourseLocationsMethod d = m_sendCourseLocationsMethod; |
2381 | if (d != null) | 2373 | if (d != null) |
2382 | { | 2374 | { |
2383 | d.Invoke(m_scene.RegionInfo.originRegionID, this); | 2375 | d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); |
2384 | } | 2376 | } |
2385 | } | 2377 | } |
2386 | 2378 | ||
@@ -2390,50 +2382,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2390 | m_sendCourseLocationsMethod = d; | 2382 | m_sendCourseLocationsMethod = d; |
2391 | } | 2383 | } |
2392 | 2384 | ||
2393 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p) | 2385 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
2394 | { | 2386 | { |
2395 | m_perfMonMS = Util.EnvironmentTickCount(); | 2387 | m_perfMonMS = Util.EnvironmentTickCount(); |
2396 | 2388 | m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); | |
2397 | List<Vector3> CoarseLocations = new List<Vector3>(); | ||
2398 | List<UUID> AvatarUUIDs = new List<UUID>(); | ||
2399 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) | ||
2400 | { | ||
2401 | if (sp.IsChildAgent) | ||
2402 | return; | ||
2403 | |||
2404 | if (sp.ParentID != 0) | ||
2405 | { | ||
2406 | // sitting avatar | ||
2407 | SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID); | ||
2408 | if (sop != null) | ||
2409 | { | ||
2410 | CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos); | ||
2411 | AvatarUUIDs.Add(sp.UUID); | ||
2412 | } | ||
2413 | else | ||
2414 | { | ||
2415 | // we can't find the parent.. ! arg! | ||
2416 | CoarseLocations.Add(sp.m_pos); | ||
2417 | AvatarUUIDs.Add(sp.UUID); | ||
2418 | } | ||
2419 | } | ||
2420 | else | ||
2421 | { | ||
2422 | CoarseLocations.Add(sp.m_pos); | ||
2423 | AvatarUUIDs.Add(sp.UUID); | ||
2424 | } | ||
2425 | }); | ||
2426 | |||
2427 | m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); | ||
2428 | |||
2429 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2389 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2430 | } | 2390 | } |
2431 | 2391 | ||
2432 | public void CoarseLocationChange() | ||
2433 | { | ||
2434 | m_newCoarseLocations = true; | ||
2435 | } | ||
2436 | |||
2437 | /// <summary> | 2392 | /// <summary> |
2438 | /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) | 2393 | /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) |
2439 | /// </summary> | 2394 | /// </summary> |
@@ -2668,7 +2623,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2668 | { | 2623 | { |
2669 | posLastSignificantMove = AbsolutePosition; | 2624 | posLastSignificantMove = AbsolutePosition; |
2670 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); | 2625 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); |
2671 | m_scene.NotifyMyCoarseLocationChange(); | ||
2672 | } | 2626 | } |
2673 | 2627 | ||
2674 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m | 2628 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m |