aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs275
1 files changed, 160 insertions, 115 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4526a59..d88526f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -445,8 +445,36 @@ namespace OpenSim.Region.Framework.Scenes
445 PhysicsActor actor = m_physicsActor; 445 PhysicsActor actor = m_physicsActor;
446 if (actor != null) 446 if (actor != null)
447 m_pos = actor.Position; 447 m_pos = actor.Position;
448 else
449 {
450 // Obtain the correct position of a seated avatar.
451 // In addition to providing the correct position while
452 // the avatar is seated, this value will also
453 // be used as the location to unsit to.
454 //
455 // If m_parentID is not 0, assume we are a seated avatar
456 // and we should return the position based on the sittarget
457 // offset and rotation of the prim we are seated on.
458 //
459 // Generally, m_pos will contain the position of the avatar
460 // in the sim unless the avatar is on a sit target. While
461 // on a sit target, m_pos will contain the desired offset
462 // without the parent rotation applied.
463 if (m_parentID != 0)
464 {
465 SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
466 if (part != null)
467 {
468 return m_parentPosition + (m_pos * part.GetWorldRotation());
469 }
470 else
471 {
472 return m_parentPosition + m_pos;
473 }
474 }
475 }
448 476
449 return m_parentPosition + m_pos; 477 return m_pos;
450 } 478 }
451 set 479 set
452 { 480 {
@@ -703,7 +731,9 @@ namespace OpenSim.Region.Framework.Scenes
703 // Note: This won't send data *to* other clients in that region (children don't send) 731 // Note: This won't send data *to* other clients in that region (children don't send)
704 732
705// MIC: This gets called again in CompleteMovement 733// MIC: This gets called again in CompleteMovement
706 SendInitialFullUpdateToAllClients(); 734 // SendInitialFullUpdateToAllClients();
735 SendOtherAgentsAvatarDataToMe();
736 SendOtherAgentsAppearanceToMe();
707 737
708 RegisterToEvents(); 738 RegisterToEvents();
709 SetDirectionVectors(); 739 SetDirectionVectors();
@@ -1613,7 +1643,7 @@ namespace OpenSim.Region.Framework.Scenes
1613 { 1643 {
1614 AbsolutePosition = part.AbsolutePosition; 1644 AbsolutePosition = part.AbsolutePosition;
1615 Velocity = Vector3.Zero; 1645 Velocity = Vector3.Zero;
1616 SendFullUpdateToAllClients(); 1646 SendAvatarDataToAllAgents();
1617 1647
1618 //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); 1648 //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID);
1619 } 1649 }
@@ -1688,7 +1718,7 @@ namespace OpenSim.Region.Framework.Scenes
1688 m_parentPosition = Vector3.Zero; 1718 m_parentPosition = Vector3.Zero;
1689 1719
1690 m_parentID = 0; 1720 m_parentID = 0;
1691 SendFullUpdateToAllClients(); 1721 SendAvatarDataToAllAgents();
1692 m_requestedSitTargetID = 0; 1722 m_requestedSitTargetID = 0;
1693 if (m_physicsActor != null && m_appearance != null) 1723 if (m_physicsActor != null && m_appearance != null)
1694 { 1724 {
@@ -2154,7 +2184,7 @@ namespace OpenSim.Region.Framework.Scenes
2154 RemoveFromPhysicalScene(); 2184 RemoveFromPhysicalScene();
2155 2185
2156 Animator.TrySetMovementAnimation(sitAnimation); 2186 Animator.TrySetMovementAnimation(sitAnimation);
2157 SendFullUpdateToAllClients(); 2187 SendAvatarDataToAllAgents();
2158 // This may seem stupid, but Our Full updates don't send avatar rotation :P 2188 // 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) 2189 // So we're also sending a terse update (which has avatar rotation)
2160 // [Update] We do now. 2190 // [Update] We do now.
@@ -2379,165 +2409,183 @@ namespace OpenSim.Region.Framework.Scenes
2379 } 2409 }
2380 2410
2381 /// <summary> 2411 /// <summary>
2382 /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) 2412 /// Do everything required once a client completes its movement into a region and becomes
2413 /// a root agent.
2383 /// </summary> 2414 /// </summary>
2384 /// <param name="remoteAvatar"></param> 2415 private void SendInitialData()
2385 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
2386 { 2416 {
2387 // 2 stage check is needed. 2417 // Moved this into CompleteMovement to ensure that m_appearance is initialized before
2388 if (remoteAvatar == null) 2418 // the inventory arrives
2389 return; 2419 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2390
2391 IClientAPI cl = remoteAvatar.ControllingClient;
2392 if (cl == null)
2393 return;
2394
2395 if (m_appearance.Texture == null)
2396 return;
2397 2420
2398// MT: This is needed for sit. It's legal to send it to oneself, and the name 2421 bool cachedappearance = false;
2399// of the method is a misnomer
2400//
2401// if (LocalId == remoteAvatar.LocalId)
2402// {
2403// m_log.WarnFormat("[SCENEPRESENCE]: An agent is attempting to send avatar data to itself; {0}", UUID);
2404// return;
2405// }
2406 2422
2407 if (IsChildAgent) 2423 // We have an appearance but we may not have the baked textures. Check the asset cache
2424 // to see if all the baked textures are already here.
2425 if (m_scene.AvatarFactory != null)
2408 { 2426 {
2409 m_log.WarnFormat("[SCENEPRESENCE]: A child agent is attempting to send out avatar data; {0}", UUID); 2427 cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient);
2410 return; 2428 }
2429 else
2430 {
2431 m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name);
2411 } 2432 }
2412 2433
2413 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); 2434 // If we aren't using a cached appearance, then clear out the baked textures
2414 m_scene.StatsReporter.AddAgentUpdates(1); 2435 if (! cachedappearance)
2436 {
2437 m_appearance.ResetAppearance();
2438 if (m_scene.AvatarFactory != null)
2439 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
2440 }
2441
2442 // This agent just became root. We are going to tell everyone about it. The process of
2443 // getting other avatars information was initiated in the constructor... don't do it
2444 // again here... this comes after the cached appearance check because the avatars
2445 // appearance goes into the avatar update packet
2446 SendAvatarDataToAllAgents();
2447 SendAppearanceToAgent(this);
2448
2449 // If we are using the the cached appearance then send it out to everyone
2450 if (cachedappearance)
2451 {
2452 m_log.InfoFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name);
2453
2454 // If the avatars baked textures are all in the cache, then we have a
2455 // complete appearance... send it out, if not, then we'll send it when
2456 // the avatar finishes updating its appearance
2457 SendAppearanceToAllOtherAgents();
2458 }
2415 } 2459 }
2416 2460
2417 /// <summary> 2461 /// <summary>
2418 /// Tell *ALL* agents about this agent 2462 /// Send this agent's avatar data to all other root and child agents in the scene
2463 /// This agent must be root. This avatar will receive its own update.
2419 /// </summary> 2464 /// </summary>
2420 public void SendInitialFullUpdateToAllClients() 2465 public void SendAvatarDataToAllAgents()
2421 { 2466 {
2422 m_perfMonMS = Util.EnvironmentTickCount(); 2467 // only send update from root agents to other clients; children are only "listening posts"
2423 int avUpdates = 0; 2468 if (IsChildAgent)
2424 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
2425 { 2469 {
2426 ++avUpdates; 2470 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent");
2427 2471 return;
2428 // Don't update ourselves 2472 }
2429 if (avatar.LocalId == LocalId) 2473
2430 return; 2474 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 2475
2438 // If the other avatar is a root 2476 int count = 0;
2439 if (!avatar.IsChildAgent) 2477 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2440 { 2478 {
2441 avatar.SendFullUpdateToOtherClient(this); 2479 SendAvatarDataToAgent(scenePresence);
2442 avatar.SendAppearanceToOtherAgent(this); 2480 count++;
2443 avatar.Animator.SendAnimPackToClient(ControllingClient); 2481 });
2444 }
2445 });
2446 2482
2447 m_scene.StatsReporter.AddAgentUpdates(avUpdates); 2483 m_scene.StatsReporter.AddAgentUpdates(count);
2448 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2484 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2449
2450 //Animator.SendAnimPack();
2451 } 2485 }
2452 2486
2453 public void SendFullUpdateToAllClients() 2487 /// <summary>
2488 /// Send avatar data for all other root agents to this agent, this agent
2489 /// can be either a child or root
2490 /// </summary>
2491 public void SendOtherAgentsAvatarDataToMe()
2454 { 2492 {
2455 m_perfMonMS = Util.EnvironmentTickCount(); 2493 m_perfMonMS = Util.EnvironmentTickCount();
2456 2494
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; 2495 int count = 0;
2465 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 2496 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2466 { 2497 {
2467 if (sp.IsChildAgent) 2498 // only send information about root agents
2468 return; 2499 if (scenePresence.IsChildAgent)
2469 SendFullUpdateToOtherClient(sp); 2500 return;
2470 ++count; 2501
2471 }); 2502 // only send information about other root agents
2503 if (scenePresence.UUID == UUID)
2504 return;
2505
2506 scenePresence.SendAvatarDataToAgent(this);
2507 count++;
2508 });
2509
2472 m_scene.StatsReporter.AddAgentUpdates(count); 2510 m_scene.StatsReporter.AddAgentUpdates(count);
2473 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2511 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2474
2475 Animator.SendAnimPack();
2476 } 2512 }
2477 2513
2478 /// <summary> 2514 /// <summary>
2479 /// Do everything required once a client completes its movement into a region 2515 /// Send avatar data to an agent.
2480 /// </summary> 2516 /// </summary>
2481 public void SendInitialData() 2517 /// <param name="avatar"></param>
2518 public void SendAvatarDataToAgent(ScenePresence avatar)
2482 { 2519 {
2483 // Moved this into CompleteMovement to ensure that m_appearance is initialized before 2520// 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 2521
2487 m_controllingClient.SendAvatarDataImmediate(this); 2522 avatar.ControllingClient.SendAvatarDataImmediate(this);
2488 if (m_scene.AvatarFactory != null) 2523 Animator.SendAnimPackToClient(avatar.ControllingClient);
2489 { 2524 }
2490 if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient)) 2525
2491 { 2526 /// <summary>
2492// m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2527 /// Send this agent's appearance to all other root and child agents in the scene
2493 m_controllingClient.SendAppearance( 2528 /// This agent must be root.
2494 m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes()); 2529 /// </summary>
2495 } 2530 public void SendAppearanceToAllOtherAgents()
2496 } 2531 {
2497 else 2532 // only send update from root agents to other clients; children are only "listening posts"
2533 if (IsChildAgent)
2498 { 2534 {
2499 m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name); 2535 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent");
2536 return;
2500 } 2537 }
2538
2539 m_perfMonMS = Util.EnvironmentTickCount();
2501 2540
2502 SendInitialFullUpdateToAllClients(); 2541 int count = 0;
2542 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2543 {
2544 if (scenePresence.UUID == UUID)
2545 return;
2546
2547 SendAppearanceToAgent(scenePresence);
2548 count++;
2549 });
2550
2551 m_scene.StatsReporter.AddAgentUpdates(count);
2552 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2503 } 2553 }
2504 2554
2505 /// <summary> 2555 /// <summary>
2506 /// 2556 /// Send appearance from all other root agents to this agent. this agent
2557 /// can be either root or child
2507 /// </summary> 2558 /// </summary>
2508 public void SendAppearanceToAllOtherAgents() 2559 public void SendOtherAgentsAppearanceToMe()
2509 { 2560 {
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(); 2561 m_perfMonMS = Util.EnvironmentTickCount();
2514 2562
2563 int count = 0;
2515 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2564 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2516 { 2565 {
2517 if (scenePresence.UUID != UUID) 2566 // only send information about root agents
2518 { 2567 if (scenePresence.IsChildAgent)
2519 SendAppearanceToOtherAgent(scenePresence); 2568 return;
2520 } 2569
2570 // only send information about other root agents
2571 if (scenePresence.UUID == UUID)
2572 return;
2573
2574 scenePresence.SendAppearanceToAgent(this);
2575 count++;
2521 }); 2576 });
2522 2577
2578 m_scene.StatsReporter.AddAgentUpdates(count);
2523 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2579 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2524 } 2580 }
2525 2581
2526 /// <summary> 2582 /// <summary>
2527 /// Send appearance data to an agent that isn't this one. 2583 /// Send appearance data to an agent.
2528 /// </summary> 2584 /// </summary>
2529 /// <param name="avatar"></param> 2585 /// <param name="avatar"></param>
2530 public void SendAppearanceToOtherAgent(ScenePresence avatar) 2586 public void SendAppearanceToAgent(ScenePresence avatar)
2531 { 2587 {
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); 2588// m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
2540// DEBUG OFF
2541 2589
2542 avatar.ControllingClient.SendAppearance( 2590 avatar.ControllingClient.SendAppearance(
2543 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); 2591 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
@@ -3050,9 +3098,6 @@ namespace OpenSim.Region.Framework.Scenes
3050 3098
3051 public void CopyFrom(AgentData cAgent) 3099 public void CopyFrom(AgentData cAgent)
3052 { 3100 {
3053// DEBUG ON
3054 m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM");
3055// DEBUG OFF
3056 m_originRegionID = cAgent.RegionID; 3101 m_originRegionID = cAgent.RegionID;
3057 3102
3058 m_callbackURI = cAgent.CallbackURI; 3103 m_callbackURI = cAgent.CallbackURI;