aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorMic Bowman2010-11-23 16:08:10 -0800
committerJustin Clark-Casey (justincc)2010-11-27 01:14:36 +0000
commit541a7660e06206c9a9eb2426dee0449afb554921 (patch)
tree16a99d09acd76e0c53b37300de069e0a4c6a8163 /OpenSim/Region/Framework/Scenes
parentAnother attempt at fixing failing test for creator info. (diff)
downloadopensim-SC-541a7660e06206c9a9eb2426dee0449afb554921.zip
opensim-SC-541a7660e06206c9a9eb2426dee0449afb554921.tar.gz
opensim-SC-541a7660e06206c9a9eb2426dee0449afb554921.tar.bz2
opensim-SC-541a7660e06206c9a9eb2426dee0449afb554921.tar.xz
Refactor appearance and avatar data sending code. Paritioning the routines into "one-to-many" and "many-to-one" makes it possible to call the right function on presence creation (both child and root) and when a child agent is promoted to root. This brings the total number of appearance sends down to one or two on login.
Cleaned up the avatar update calls in the groups code. Cleaned up some commented and debugging code, and a few formating fixes.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs231
1 files changed, 117 insertions, 114 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index db69093..4a48ac3 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -703,7 +703,9 @@ namespace OpenSim.Region.Framework.Scenes
703 // Note: This won't send data *to* other clients in that region (children don't send) 703 // Note: This won't send data *to* other clients in that region (children don't send)
704 704
705// MIC: This gets called again in CompleteMovement 705// MIC: This gets called again in CompleteMovement
706 SendInitialFullUpdateToAllClients(); 706 // SendInitialFullUpdateToAllClients();
707 SendOtherAgentsAvatarDataToMe();
708 SendOtherAgentsAppearanceToMe();
707 709
708 RegisterToEvents(); 710 RegisterToEvents();
709 SetDirectionVectors(); 711 SetDirectionVectors();
@@ -1613,7 +1615,7 @@ namespace OpenSim.Region.Framework.Scenes
1613 { 1615 {
1614 AbsolutePosition = part.AbsolutePosition; 1616 AbsolutePosition = part.AbsolutePosition;
1615 Velocity = Vector3.Zero; 1617 Velocity = Vector3.Zero;
1616 SendFullUpdateToAllClients(); 1618 SendAvatarDataToAllAgents();
1617 1619
1618 //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); 1620 //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID);
1619 } 1621 }
@@ -1688,7 +1690,7 @@ namespace OpenSim.Region.Framework.Scenes
1688 m_parentPosition = Vector3.Zero; 1690 m_parentPosition = Vector3.Zero;
1689 1691
1690 m_parentID = 0; 1692 m_parentID = 0;
1691 SendFullUpdateToAllClients(); 1693 SendAvatarDataToAllAgents();
1692 m_requestedSitTargetID = 0; 1694 m_requestedSitTargetID = 0;
1693 if (m_physicsActor != null && m_appearance != null) 1695 if (m_physicsActor != null && m_appearance != null)
1694 { 1696 {
@@ -2154,7 +2156,7 @@ namespace OpenSim.Region.Framework.Scenes
2154 RemoveFromPhysicalScene(); 2156 RemoveFromPhysicalScene();
2155 2157
2156 Animator.TrySetMovementAnimation(sitAnimation); 2158 Animator.TrySetMovementAnimation(sitAnimation);
2157 SendFullUpdateToAllClients(); 2159 SendAvatarDataToAllAgents();
2158 // This may seem stupid, but Our Full updates don't send avatar rotation :P 2160 // This may seem stupid, but Our Full updates don't send avatar rotation :P
2159 // So we're also sending a terse update (which has avatar rotation) 2161 // So we're also sending a terse update (which has avatar rotation)
2160 // [Update] We do now. 2162 // [Update] We do now.
@@ -2379,165 +2381,169 @@ namespace OpenSim.Region.Framework.Scenes
2379 } 2381 }
2380 2382
2381 /// <summary> 2383 /// <summary>
2382 /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) 2384 /// Do everything required once a client completes its movement into a region and becomes
2385 /// a root agent.
2383 /// </summary> 2386 /// </summary>
2384 /// <param name="remoteAvatar"></param> 2387 private void SendInitialData()
2385 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
2386 { 2388 {
2387 // 2 stage check is needed. 2389 // Moved this into CompleteMovement to ensure that m_appearance is initialized before
2388 if (remoteAvatar == null) 2390 // the inventory arrives
2389 return; 2391 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2390
2391 IClientAPI cl = remoteAvatar.ControllingClient;
2392 if (cl == null)
2393 return;
2394 2392
2395 if (m_appearance.Texture == null) 2393 // This agent just became root. We are going to tell everyone about it. The process of
2396 return; 2394 // getting other avatars information was initiated in the constructor... don't do it
2395 // again here...
2396 SendAvatarDataToAllAgents();
2397 2397
2398// MT: This is needed for sit. It's legal to send it to oneself, and the name 2398 // We have an appearance but we may not have the baked textures. Check the asset cache
2399// of the method is a misnomer 2399 // to see if all the baked textures are already here.
2400// 2400 if (m_scene.AvatarFactory != null)
2401// if (LocalId == remoteAvatar.LocalId) 2401 {
2402// { 2402 if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient))
2403// m_log.WarnFormat("[SCENEPRESENCE]: An agent is attempting to send avatar data to itself; {0}", UUID); 2403 {
2404// return; 2404// m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name);
2405// } 2405 SendAppearanceToAgent(this);
2406 2406
2407 if (IsChildAgent) 2407 // If the avatars baked textures are all in the cache, then we have a
2408 // complete appearance... send it out, if not, then we'll send it when
2409 // the avatar finishes updating its appearance
2410 SendAppearanceToAllOtherAgents();
2411 }
2412 }
2413 else
2408 { 2414 {
2409 m_log.WarnFormat("[SCENEPRESENCE]: A child agent is attempting to send out avatar data; {0}", UUID); 2415 m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name);
2410 return;
2411 } 2416 }
2412
2413 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this);
2414 m_scene.StatsReporter.AddAgentUpdates(1);
2415 } 2417 }
2416 2418
2417 /// <summary> 2419 /// <summary>
2418 /// Tell *ALL* agents about this agent 2420 /// Send this agent's avatar data to all other root and child agents in the scene
2421 /// This agent must be root. This avatar will receive its own update.
2419 /// </summary> 2422 /// </summary>
2420 public void SendInitialFullUpdateToAllClients() 2423 public void SendAvatarDataToAllAgents()
2421 { 2424 {
2422 m_perfMonMS = Util.EnvironmentTickCount(); 2425 // only send update from root agents to other clients; children are only "listening posts"
2423 int avUpdates = 0; 2426 if (IsChildAgent)
2424 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
2425 { 2427 {
2426 ++avUpdates; 2428 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent");
2427 2429 return;
2428 // Don't update ourselves 2430 }
2429 if (avatar.LocalId == LocalId) 2431
2430 return; 2432 m_perfMonMS = Util.EnvironmentTickCount();
2431
2432 // If this is a root agent, then get info about the avatar
2433 if (!IsChildAgent)
2434 {
2435 SendFullUpdateToOtherClient(avatar);
2436 }
2437 2433
2438 // If the other avatar is a root 2434 int count = 0;
2439 if (!avatar.IsChildAgent) 2435 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2440 { 2436 {
2441 avatar.SendFullUpdateToOtherClient(this); 2437 SendAvatarDataToAgent(scenePresence);
2442 avatar.SendAppearanceToOtherAgent(this); 2438 count++;
2443 avatar.Animator.SendAnimPackToClient(ControllingClient); 2439 });
2444 }
2445 });
2446 2440
2447 m_scene.StatsReporter.AddAgentUpdates(avUpdates); 2441 m_scene.StatsReporter.AddAgentUpdates(count);
2448 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2442 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2449
2450 //Animator.SendAnimPack();
2451 } 2443 }
2452 2444
2453 public void SendFullUpdateToAllClients() 2445 /// <summary>
2446 /// Send avatar data for all other root agents to this agent, this agent
2447 /// can be either a child or root
2448 /// </summary>
2449 public void SendOtherAgentsAvatarDataToMe()
2454 { 2450 {
2455 m_perfMonMS = Util.EnvironmentTickCount(); 2451 m_perfMonMS = Util.EnvironmentTickCount();
2456 2452
2457 // only send update from root agents to other clients; children are only "listening posts"
2458 if (IsChildAgent)
2459 {
2460 m_log.Warn("[SCENEPRESENCE] attempt to send update from a childagent");
2461 return;
2462 }
2463
2464 int count = 0; 2453 int count = 0;
2465 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 2454 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2466 { 2455 {
2467 if (sp.IsChildAgent) 2456 // only send information about root agents
2468 return; 2457 if (scenePresence.IsChildAgent)
2469 SendFullUpdateToOtherClient(sp); 2458 return;
2470 ++count; 2459
2471 }); 2460 // only send information about other root agents
2461 if (scenePresence.UUID == UUID)
2462 return;
2463
2464 scenePresence.SendAvatarDataToAgent(this);
2465 count++;
2466 });
2467
2472 m_scene.StatsReporter.AddAgentUpdates(count); 2468 m_scene.StatsReporter.AddAgentUpdates(count);
2473 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2469 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2474
2475 Animator.SendAnimPack();
2476 } 2470 }
2477 2471
2478 /// <summary> 2472 /// <summary>
2479 /// Do everything required once a client completes its movement into a region 2473 /// Send avatar data to an agent.
2480 /// </summary> 2474 /// </summary>
2481 public void SendInitialData() 2475 /// <param name="avatar"></param>
2476 private void SendAvatarDataToAgent(ScenePresence avatar)
2482 { 2477 {
2483 // Moved this into CompleteMovement to ensure that m_appearance is initialized before 2478// m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
2484 // the inventory arrives
2485 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2486 2479
2487 m_controllingClient.SendAvatarDataImmediate(this); 2480 avatar.ControllingClient.SendAvatarDataImmediate(this);
2488 if (m_scene.AvatarFactory != null) 2481 Animator.SendAnimPackToClient(avatar.ControllingClient);
2489 { 2482 }
2490 if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient)) 2483
2491 { 2484 /// <summary>
2492// m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2485 /// Send this agent's appearance to all other root and child agents in the scene
2493 m_controllingClient.SendAppearance( 2486 /// This agent must be root.
2494 m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes()); 2487 /// </summary>
2495 } 2488 public void SendAppearanceToAllOtherAgents()
2496 } 2489 {
2497 else 2490 // only send update from root agents to other clients; children are only "listening posts"
2491 if (IsChildAgent)
2498 { 2492 {
2499 m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name); 2493 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent");
2494 return;
2500 } 2495 }
2496
2497 m_perfMonMS = Util.EnvironmentTickCount();
2498
2499 int count = 0;
2500 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2501 {
2502 if (scenePresence.UUID == UUID)
2503 return;
2501 2504
2502 SendInitialFullUpdateToAllClients(); 2505 SendAppearanceToAgent(scenePresence);
2506 count++;
2507 });
2508
2509 m_scene.StatsReporter.AddAgentUpdates(count);
2510 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2503 } 2511 }
2504 2512
2505 /// <summary> 2513 /// <summary>
2506 /// 2514 /// Send appearance from all other root agents to this agent. this agent
2515 /// can be either root or child
2507 /// </summary> 2516 /// </summary>
2508 public void SendAppearanceToAllOtherAgents() 2517 public void SendOtherAgentsAppearanceToMe()
2509 { 2518 {
2510// DEBUG ON
2511// m_log.WarnFormat("[SCENEPRESENCE]: Send appearance from {0} to all other agents", m_uuid);
2512// DEBUG OFF
2513 m_perfMonMS = Util.EnvironmentTickCount(); 2519 m_perfMonMS = Util.EnvironmentTickCount();
2514 2520
2521 int count = 0;
2515 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2522 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2516 { 2523 {
2517 if (scenePresence.UUID != UUID) 2524 // only send information about root agents
2518 { 2525 if (scenePresence.IsChildAgent)
2519 SendAppearanceToOtherAgent(scenePresence); 2526 return;
2520 } 2527
2528 // only send information about other root agents
2529 if (scenePresence.UUID == UUID)
2530 return;
2531
2532 scenePresence.SendAppearanceToAgent(this);
2533 count++;
2521 }); 2534 });
2522 2535
2536 m_scene.StatsReporter.AddAgentUpdates(count);
2523 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2537 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2524 } 2538 }
2525 2539
2526 /// <summary> 2540 /// <summary>
2527 /// Send appearance data to an agent that isn't this one. 2541 /// Send appearance data to an agent.
2528 /// </summary> 2542 /// </summary>
2529 /// <param name="avatar"></param> 2543 /// <param name="avatar"></param>
2530 public void SendAppearanceToOtherAgent(ScenePresence avatar) 2544 private void SendAppearanceToAgent(ScenePresence avatar)
2531 { 2545 {
2532 if (LocalId == avatar.LocalId)
2533 {
2534 m_log.WarnFormat("[SCENE PRESENCE]: An agent is attempting to send appearance data to itself; {0}", UUID);
2535 return;
2536 }
2537
2538// DEBUG ON
2539// m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); 2546// m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
2540// DEBUG OFF
2541 2547
2542 avatar.ControllingClient.SendAppearance( 2548 avatar.ControllingClient.SendAppearance(
2543 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); 2549 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
@@ -3050,9 +3056,6 @@ namespace OpenSim.Region.Framework.Scenes
3050 3056
3051 public void CopyFrom(AgentData cAgent) 3057 public void CopyFrom(AgentData cAgent)
3052 { 3058 {
3053// DEBUG ON
3054 m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM");
3055// DEBUG OFF
3056 m_originRegionID = cAgent.RegionID; 3059 m_originRegionID = cAgent.RegionID;
3057 3060
3058 m_callbackURI = cAgent.CallbackURI; 3061 m_callbackURI = cAgent.CallbackURI;